svpace opened a new issue, #325:
URL: https://github.com/apache/maven-compiler-plugin/issues/325

   ### Affected version
   
   3.14.0
   
   ### Bug description
   
   Not quite sure if this should be reported here or in the Maven Jira. But as 
it seems to be related to #180 reporting here first. Please let me know if I 
should report there.
   
   When a parent POM or `pluginManagement` defines a set of annotation 
processors with versions, and the child POM or `plugins` defines another set of 
processors without versions (relying on `dependencyManagement`), the version is 
inherited from the processor defined at the corresponding position in the list 
instead of the dependency management.
   
   The following POM shows the issue:
   ```xml
   <?xml version="1.0" encoding="UTF-8"?>
   <project xmlns="http://maven.apache.org/POM/4.0.0";
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
                 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
        <modelVersion>4.0.0</modelVersion>
   
        <groupId>com.example</groupId>
        <artifactId>maven-compiler-plugin-issue</artifactId>
        <version>1.0.0-SNAPSHOT</version>
   
        <properties>
                <maven.compiler.source>17</maven.compiler.source>
                <maven.compiler.target>17</maven.compiler.target>
                
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        </properties>
   
        <dependencyManagement>
                <dependencies>
                        <dependency>
                                <groupId>org.mapstruct</groupId>
                                <artifactId>mapstruct-processor</artifactId>
                                <version>1.6.3</version>
                        </dependency>
                </dependencies>
        </dependencyManagement>
        <build>
                <pluginManagement>
                        <plugins>
                                <plugin>
                                        
<groupId>org.apache.maven.plugins</groupId>
                                        
<artifactId>maven-compiler-plugin</artifactId>
                                        <version>3.14.0</version>
                                        <configuration>
                                                <annotationProcessorPaths>
                                                        <path>
                                                                
<groupId>org.projectlombok</groupId>
                                                                
<artifactId>lombok</artifactId>
                                                                
<version>1.18.38</version>
                                                        </path>
                                                </annotationProcessorPaths>
                                        </configuration>
                                </plugin>
                        </plugins>
                </pluginManagement>
                <plugins>
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-compiler-plugin</artifactId>
                                <configuration>
                                        <annotationProcessorPaths>
                                                <path>
                                                        
<groupId>org.mapstruct</groupId>
                                                        
<artifactId>mapstruct-processor</artifactId>
                                                </path>
                                        </annotationProcessorPaths>
                                </configuration>
                        </plugin>
                </plugins>
        </build>
   </project>
   ```
   
   The resulting effective POM end up like this:
   ```xml
       <plugins>
           <plugin>
               <artifactId>maven-compiler-plugin</artifactId>
               <version>3.14.0</version>
               <executions>
                   <execution>
                       <id>default-compile</id>
                       <phase>compile</phase>
                       <goals>
                           <goal>compile</goal>
                       </goals>
                       <configuration>
                           <annotationProcessorPaths>
                               <path>
                                   <groupId>org.mapstruct</groupId>
                                   <artifactId>mapstruct-processor</artifactId>
                                   <version>1.18.38</version>
                               </path>
                           </annotationProcessorPaths>
                       </configuration>
                   </execution>
   ```
   
   If I omit the `groupId` from `plugins` it also inherits it from parent. It 
feels like Maven's list and non-list merge behavior gets mixed up and it 
replaces the list but fills in any missing fields.
   
   I am pretty sure that a `combine.children` or `combine.self` may workaround 
this, but the current way fells wrong.
   
   Let me know if you need any more infos.
   
    


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to