Using org.springframework.boot.maven.PropertiesMergingResourceTransformer as a transformer with maven-shade-plugin is no longer possible as of shade plugin 3.2.3. The API of org.apache.maven.plugins.shade.resource.ResourceTransformer was changed, which causes an AbstractMethodError:
Execution default of goal org.apache.maven.plugins:maven-shade-plugin:3.2.3:shade failed: An API incompatibility was encountered while executing org.apache.maven.plugins:maven-shade-plugin:3.2.3:shade: java.lang.AbstractMethodError: Receiver class org.springframework.boot.maven.PropertiesMergingResourceTransformer does not define or inherit an implementation of the resolved method 'abstract void processResource(java.lang.String, java.io.InputStream, java.util.List, long)' of interface org.apache.maven.plugins.shade.resource.ResourceTransformer.
Above error is from running maven with Java 11. Running with Java 8 produces a similar, but much less useful error:
Execution default of goal org.apache.maven.plugins:maven-shade-plugin:3.2.3:shade failed: An API incompatibility was encountered while executing org.apache.maven.plugins:maven-shade-plugin:3.2.3:shade: java.lang.AbstractMethodError: null
This happens with latest spring-boot-maven-plugin 2.2.6.RELEASE.
Comment From: wilkinsona
@zman0900 Thanks for letting us know. As things stand, anyone use Spring Boot's plugin management will be unaffected as the managed version of the Shade Plugin is 3.2.2 so hopefully the impact will be minimal at the moment.
Before we change anything in Spring Boot, I've opened MSHADE-363 to see if binary compatibility can be restored to the ResourceTransformer interface.
Comment From: wilkinsona
3.2.4 of the Shade plugin has addressed this.
Comment From: binishprab
@wilkinsona - Was this issue address in 3.2.4 - I still see the error
Unable to parse configuration of mojo org.apache.maven.plugins:maven-shade-plugin:3.2.4:shade for parameter mainClass: Cannot find 'mainClass' in class org.springframework.boot.maven.PropertiesMergingResourceTransformer -
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot-version}</version>
</dependency>
</dependencies>
<configuration>
<keepDependenciesWithProvidedScope>false</keepDependenciesWithProvidedScope>
<createDependencyReducedPom>false</createDependencyReducedPom>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<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>
</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">
<mainClass>${start-class}</mainClass>
</transformer>
</transformers>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
Comment From: wilkinsona
@binishprab that looks like a completely different error. In your case, it would appear that something's trying to configure mainClass on org.springframework.boot.maven.PropertiesMergingResourceTransformer and it has no such property. Please double-check your configuration. If it looks OK, please open a new issue with a minimal sample that reproduces the problem and we can take a look.