[
https://issues.apache.org/jira/browse/MNG-7683?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17685160#comment-17685160
]
ASF GitHub Bot commented on MNG-7683:
-------------------------------------
c00ler opened a new pull request, #986:
URL: https://github.com/apache/maven/pull/986
Following this checklist to help us incorporate your
contribution quickly and easily:
- [ ] Make sure there is a [JIRA
issue](https://issues.apache.org/jira/browse/MNG) filed
for the change (usually before you start working on it). Trivial
changes like typos do not
require a JIRA issue. Your pull request should address just this
issue, without
pulling in other changes.
- [ ] Each commit in the pull request should have a meaningful subject line
and body.
- [ ] Format the pull request title like `[MNG-XXX] SUMMARY`,
where you replace `MNG-XXX` and `SUMMARY` with the appropriate JIRA
issue.
- [ ] Also format the first line of the commit message like `[MNG-XXX]
SUMMARY`.
Best practice is to use the JIRA issue title in both the pull request
title and in the first line of the commit message.
- [ ] Write a pull request description that is detailed enough to
understand what the pull request does, how, and why.
- [ ] Run `mvn clean verify` to make sure basic checks pass. A more
thorough check will
be performed on your pull request automatically.
- [ ] You have run the [Core IT][core-its] successfully.
If your pull request is about ~20 lines of code you don't need to sign an
[Individual Contributor License
Agreement](https://www.apache.org/licenses/icla.pdf) if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the [Apache License Version 2.0, January
2004](http://www.apache.org/licenses/LICENSE-2.0)
you have to acknowledge this by using the following check-box.
- [ ] I hereby declare this contribution to be licenced under the [Apache
License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
- [ ] In any other case, please file an [Apache Individual Contributor
License Agreement](https://www.apache.org/licenses/icla.pdf).
[core-its]: https://maven.apache.org/core-its/core-it-suite/
> Plugin configuration is merged incorrectly
> ------------------------------------------
>
> Key: MNG-7683
> URL: https://issues.apache.org/jira/browse/MNG-7683
> Project: Maven
> Issue Type: Bug
> Components: Inheritance and Interpolation
> Affects Versions: 4.0.0-alpha-3, 4.0.x-candidate
> Reporter: Alexey Venderov
> Priority: Major
>
> Hi,
> As was mentioned by my colleague
> [here|https://github.com/apache/maven/pull/866#discussion_r1058637665] there
> is a regression in the plugin configuration merging logic introduced in
> version {{4.0.0-alpha-3}}. The original assumption was that the issue is
> caused by
> [this|https://github.com/codehaus-plexus/plexus-utils/commit/67ac243dbc6434c03a9b1582d94aef6bf2b5cf95]
> change in the {{plexus-utils}} library. I wrote a small reproducer test:
> [https://github.com/c00ler/plexus-utils-merge-xml-reproducer/blob/main/src/test/java/com/github/avenderov/ReproducerTest.java]
> and run it with the {{plexus-utils}} versions before and after the change.
> Test passes with both versions. So it's not the change in the
> {{plexus-utils}}.
> After that, I checked Maven sources and found out that {{Maven 4}} doesn't
> use {{Xpp3Dom}} and associated utilities from the {{plexus-utils}} anymore,
> and has its own merging logic implemented
> [here|https://github.com/apache/maven/blob/master/maven-xml-impl/src/main/java/org/apache/maven/internal/xml/XmlNodeImpl.java#L207].
> The behavior of the configuration merging logic was correct (same as in
> maven 3.x) up until version {{4.0.0-alpha-2}} and then was changed in version
> {{4.0.0-alpha-3}}.
> h3. Problem description.
> We have the following {{foo-bar-plugin}} configuration in the parent pom:
> {code:xml}
> <pluginManagement>
> <plugins>
> <plugin>
> <groupId>foo.bar</groupId>
> <artifactId>foo-bar-plugin</artifactId>
> <configuration>
> <plugins>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-compiler-plugin</artifactId>
> <bar>
> <value>foo</value>
> </bar>
> </plugin>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-surefire-plugin</artifactId>
> <foo>
> <properties>
> <property>
> <name>prop1</name>
> <value>value1</value>
> </property>
> </properties>
> </foo>
> </plugin>
> </plugins>
> </configuration>
> </plugin>
> </plugins>
> </pluginManagement>
> {code}
> In the child pom, we want to make changes to the {{foo-bar-plugin}}
> configuration:
> {code:xml}
> <pluginManagement>
> <plugins>
> <plugin>
> <groupId>foo.bar</groupId>
> <artifactId>foo-bar-plugin</artifactId>
> <configuration>
> <plugins>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-compiler-plugin</artifactId>
> </plugin>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-surefire-plugin</artifactId>
> <foo>
> <properties combine.children="append">
> <property>
> <name>prop2</name>
> <value>value2</value>
> </property>
> </properties>
> </foo>
> </plugin>
> </plugins>
> </configuration>
> </plugin>
> </plugins>
> </pluginManagement>
> {code}
> The expected effective pom after merging ({{maven-compiler-plugin}}
> configuration is persisted, {{maven-surefire-plugin}} configuration is
> merged):
> {code:xml}
> <pluginManagement>
> <plugins>
> <plugin>
> <groupId>foo.bar</groupId>
> <artifactId>foo-bar-plugin</artifactId>
> <configuration>
> <plugins>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-compiler-plugin</artifactId>
> <bar>
> <value>foo</value>
> </bar>
> </plugin>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-surefire-plugin</artifactId>
> <foo>
> <properties combine.children="append">
> <property>
> <name>prop1</name>
> <value>value1</value>
> </property>
> <property>
> <name>prop2</name>
> <value>value2</value>
> </property>
> </properties>
> </foo>
> </plugin>
> </plugins>
> </configuration>
> </plugin>
> </plugins>
> </pluginManagement>
> {code}
> Instead {{Maven 4.0.0-alpha-3}} produces the following result:
> {code:xml}
> <pluginManagement>
> <plugins>
> <plugin>
> <groupId>foo.bar</groupId>
> <artifactId>foo-bar-plugin</artifactId>
> <configuration>
> <plugins>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-compiler-plugin</artifactId>
> <foo>
> <properties>
> <property>
> <name>prop1</name>
> <value>value1</value>
> </property>
> </properties>
> </foo>
> </plugin>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-surefire-plugin</artifactId>
> <foo>
> <properties combine.children="append">
> <property>
> <name>prop2</name>
> <value>value2</value>
> </property>
> </properties>
> </foo>
> </plugin>
> </plugins>
> </configuration>
> </plugin>
> </plugins>
> </pluginManagement>
> {code}
> h3. Steps to reproduce.
> We have a repository with the reproducer:
> [https://github.com/c00ler/maven-merge-xml-reproducer]:
> * the [main|https://github.com/c00ler/maven-merge-xml-reproducer] branch
> produces a diff between {{maven 3.8.7}} and {{maven 4.0.0-alpha-3}}. It shows
> the described example;
> * the
> [alpha2-alpha3|https://github.com/c00ler/maven-merge-xml-reproducer/tree/alpha2-alpha3]
> branch produces a diff between {{maven 4.0.0-alpha-2}} and {{maven
> 4.0.0-alpha-3}} that shows the change in the behavior;
> After diving a little bit deeper I found out that the problem is actually
> caused by the fact that we have two nested plugins configurations,
> {{maven-compiler-plugin}} and {{maven-surefire-plugin}}, that need to be
> merged and it causes the problem. As can be seen from the example the
> configuration from the {{maven-surefire-plugin}} is getting merged to the
> {{maven-compiler-plugin}} and overrides its configuration. In the branch
> [single-plugin-merge|https://github.com/c00ler/maven-merge-xml-reproducer/tree/single-plugin-merge]
> I've left only {{maven-surefire-plugin}} and then the configuration is
> correctly merged even in {{maven 4.0.0-alpha-3}}.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)