-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Fix MavenProject#getPlugin(String) performances #2530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
impl/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
Outdated
Show resolved
Hide resolved
impl/maven-core/src/test/java/org/apache/maven/project/PluginConnectionSimpleTest.java
Outdated
Show resolved
Hide resolved
@@ -1240,7 +1240,9 @@ public String getDefaultGoal() { | |||
} | |||
|
|||
public Plugin getPlugin(String pluginKey) { | |||
return getBuild().getPluginsAsMap().get(pluginKey); | |||
org.apache.maven.api.model.Plugin plugin = |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
* 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)
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation |
* 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)
No description provided.