[
https://issues.apache.org/jira/browse/MNG-6016?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15270427#comment-15270427
]
Michael Osipov commented on MNG-6016:
-------------------------------------
The [Spring
class|https://github.com/spring-projects/spring-boot/blob/master/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/PropertiesMergingResourceTransformer.java}
does neither have {{mainClass}} nor {{collectSections}}. How is this supposed
to work?
> 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.3.4#6332)