toobee
toobee

Reputation: 2752

Maven Shade Plugin: Cannot create instance of

I am trying to use Maven Shade the first time and got stuck. I get an error messages which says:

        Unable to parse configuration of mojo org.apache.maven.plugins:maven-shade-plugin:2.3:
    shade for parameter outputFile: Cannot create instance of interface org.apache.maven.plugins.shade.resource.ResourceTransformer:
org.apache.maven.plugins.shade.resource.ResourceTransformer.<init>() -> [Help 1]

I added this template for a pom.xml-extension to use Maven-Shade to my pom.xml and just entered my test project's main-class.

I am not familiar with maven and in particular with this plugin - can anyone help with this?

 <build>
 <plugins>
 <plugin>
 <groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-shade-plugin</artifactId>
 <version>2.3</version>
 <executions>
    <execution>
    <phase>package</phase>
     <goals>
     <goal>shade</goal>
     </goals>
     <configuration>
     <transformers>
     <!-- Set the main class of the executable JAR -->
         <transformer
         implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
         <mainClass>de.mavenShadeTest.MyMain</mainClass>
        </transformer>
     <!-- Merge the uimaFIT configuration files -->
     <transformer
     implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
     <resource>
     META-INF/org.apache.uima.fit/fsindexes.txt
     </resource>
    </transformer>
    <transformer
    implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
    <resource>
    META-INF/org.apache.uima.fit/types.txt
    </resource>
    </transformer>
    <transformer
    implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
    <resource>
    META-INF/org.apache.uima.fit/typepriorities.txt
    </resource>
    </transformer>
 <!-- Prevent huge shaded artifacts from being deployed to a Maven 
 repository (remove if not desired) -->
 <outputFile>
 ${project.build.directory}/${artifactId}-${version}-standalone.jar
 </outputFile>
 </transformers>
 </configuration>
 </execution>
 </executions>
 </plugin>
 </plugins>
 </build>

Upvotes: 2

Views: 4935

Answers (1)

Joe
Joe

Reputation: 31110

You've added outputFile within the transformers element, rather than outside:

</transformer>
 <!-- Prevent huge shaded artifacts from being deployed to a Maven 
 repository (remove if not desired) -->
 <outputFile>
 ${project.build.directory}/${artifactId}-${version}-standalone.jar
 </outputFile>
 </transformers>
 </configuration>

Move it outside, so it's directly under configuration:

 </transformers>
 <outputFile>
 ${project.build.directory}/${artifactId}-${version}-standalone.jar
 </outputFile>
 </configuration>

Upvotes: 2

Related Questions