[Comment Edited] (MNG-6016) Maven incorrectly builds POM when you override Shade transformers in a child

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Comment Edited] (MNG-6016) Maven incorrectly builds POM when you override Shade transformers in a child

JIRA jira@apache.org

    [ https://issues.apache.org/jira/browse/MNG-6016?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16053547#comment-16053547 ]

Frank Wein edited comment on MNG-6016 at 6/19/17 7:56 AM:
----------------------------------------------------------

I also observe this problem with a project of myself. Did someone already have a chance to test this with Maven 3.5?


was (Author: fwein):
I also observe this problem with a project of myself. Did someone already have a change to test this with Maven 3.5?

> Maven incorrectly builds POM when you override Shade transformers in a child
> ----------------------------------------------------------------------------
>
>                 Key: MNG-6016
>                 URL: https://issues.apache.org/jira/browse/MNG-6016
>             Project: Maven
>          Issue Type: Bug
>          Components: Inheritance and Interpolation, POM
>    Affects Versions: 3.3.9
>            Reporter: Steven Schlansker
>
> Consider the project: https://github.com/stevenschlansker/maven-configure-transformer-bug/
> Simple 2 module project.  Parent defines some Shade plugin configuration, notably a {{ResourceTransformer}} with a {{mainClass}} declaration.
> Child then tries to add a {{PropertiesMergingResourceTransformer}}, but somehow the {{mainClass}} declaration from the parent gets merged into this other transformer, causing a build failure:
> {quote}
> [ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:2.4.3:shade (assemble-app) on project maven-configure-transformer-bug-child: Unable to parse configuration of mojo org.apache.maven.plugins:maven-shade-plugin:2.4.3:shade for parameter mainClass: Cannot find 'mainClass' in class org.springframework.boot.maven.PropertiesMergingResourceTransformer -> [Help 1]
> {quote}
> The effective POM shows that something extremely unintuitive is going on with model merging:
> {code}
>       <plugin>
>         <artifactId>maven-shade-plugin</artifactId>
>         <version>2.4.3</version>
>         <executions>
>           <execution>
>             <id>assemble-app</id>
>             <phase>package</phase>
>             <goals>
>               <goal>shade</goal>
>             </goals>
>             <configuration>
>               <transformers>
>                 <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
>                   <resource>META-INF/spring.handlers</resource>
>                 </transformer>
>                 <transformer implementation="org.springframework.boot.maven.PropertiesMergingResourceTransformer">
>                   <resource>META-INF/spring.factories</resource>
>                   <mainClass>foo</mainClass>
>                   <collectSections>true</collectSections>
>                 </transformer>
>                 <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
>                   <resource>META-INF/spring.schemas</resource>
>                 </transformer>
>                 <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
>                 <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer" />
>               </transformers>
>             </configuration>
>           </execution>
>         </executions>
>         <dependencies>
>           <dependency>
>             <groupId>org.springframework.boot</groupId>
>             <artifactId>spring-boot-maven-plugin</artifactId>
>             <version>1.3.3.RELEASE</version>
>             <scope>compile</scope>
>           </dependency>
>         </dependencies>
>         <configuration>
>           <transformers>
>             <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
>               <resource>META-INF/spring.handlers</resource>
>             </transformer>
>             <transformer implementation="org.springframework.boot.maven.PropertiesMergingResourceTransformer">
>               <resource>META-INF/spring.factories</resource>
>               <mainClass>foo</mainClass>
>               <collectSections>true</collectSections>
>             </transformer>
>             <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
>               <resource>META-INF/spring.schemas</resource>
>             </transformer>
>             <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
>             <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer" />
>           </transformers>
>         </configuration>
>       </plugin>
> {code}
> It is possible to escape this by adding {{combine.self="override"}} to the {{<transformers>}} node.  But I think the configuration ending up on the wrong transformer is a bug, and the fact that it causes duplicate configuration sections is also extremely confusing.  And somewhere in the shuffle the original {{CollectingManifestResourceTransformer}} is lost entirely.  (Note that it's not even on the plugin path, so referencing it should be an error!)



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
Loading...