Skip to content

Conversation

gnodet
Copy link
Contributor

@gnodet gnodet commented Jun 30, 2025

No description provided.

@cstamas
Copy link
Member

cstamas commented Jun 30, 2025

RAO is down for HW migration https://status.apache.org/

…jects

The Plugin objects returned by MavenProject.getPlugin() were disconnected
from the project model because they were created with new Plugin(plugin)
without a parent BaseObject.

This fix passes getBuild() as the parent to the Plugin constructor, ensuring
that modifications to Plugin objects (setVersion, setConfiguration, etc.)
persist in the project model.

The change maintains the performance improvement from the original PR while
fixing the connection issue, similar to how ConnectedResource works for
Resource objects.
@@ -1240,7 +1240,9 @@ public String getDefaultGoal() {
}

public Plugin getPlugin(String pluginKey) {
return getBuild().getPluginsAsMap().get(pluginKey);
org.apache.maven.api.model.Plugin plugin =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we have both org.apache.maven.model.Plugin and org.apache.maven.api.model.Plugin? I'm not sure, but this might be a symptom of too many packages, over-abstraction, or both. Do we need multiple plugin types?

Copy link
Contributor Author

@gnodet gnodet Jul 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're translating from the Maven 3 api to the Maven 4 api here. org.apache.maven.model.Plugin is the Maven 3 api, with mutable objects. org.apache.maven.api.model.Plugin is the (now underlying) Maven 4 api with immutable objects.
This is somewhat temporary, the plan is to get away with the Maven 3 api in Maven 5. But we need it to support Maven 3 plugins in Maven 4 and not break everything.

@gnodet gnodet merged commit 0b29d8f into apache:master Jul 4, 2025
19 checks passed
gnodet added a commit to gnodet/maven that referenced this pull request Jul 4, 2025
* Fix MavenProject#getPlugin(String) performances

* Fix Plugin connection: ensure getPlugin() returns connected Plugin objects

The Plugin objects returned by MavenProject.getPlugin() were disconnected
from the project model because they were created with new Plugin(plugin)
without a parent BaseObject.

This fix passes getBuild() as the parent to the Plugin constructor, ensuring
that modifications to Plugin objects (setVersion, setConfiguration, etc.)
persist in the project model.

The change maintains the performance improvement from the original PR while
fixing the connection issue, similar to how ConnectedResource works for
Resource objects.

* Do not use var keyword

* Add pointer

(cherry picked from commit 0b29d8f)
@gnodet
Copy link
Contributor Author

gnodet commented Jul 4, 2025

💚 All backports created successfully

Status Branch Result
maven-4.0.x

Questions ?

Please refer to the Backport tool documentation

gnodet added a commit that referenced this pull request Jul 4, 2025
* Fix MavenProject#getPlugin(String) performances

* Fix Plugin connection: ensure getPlugin() returns connected Plugin objects

The Plugin objects returned by MavenProject.getPlugin() were disconnected
from the project model because they were created with new Plugin(plugin)
without a parent BaseObject.

This fix passes getBuild() as the parent to the Plugin constructor, ensuring
that modifications to Plugin objects (setVersion, setConfiguration, etc.)
persist in the project model.

The change maintains the performance improvement from the original PR while
fixing the connection issue, similar to how ConnectedResource works for
Resource objects.

* Do not use var keyword

* Add pointer

(cherry picked from commit 0b29d8f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants