19

I'm using shade plugin and everything works fine except for being able to set Class-Path for manifest via

 <transformer 
        implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
        <mainClass>com.generic.App</mainClass>  
        <classPath>. ./config</classPath>                           
    </transformer>

I get

 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:2.1:shade (default)              on project SpringThing: Unable to parse configuration of mojo org.apache.maven.plugins:maven-shade-plugin:2.1:shade for parameter transformer: Cannot find setter, adder nor field in org.apache.maven.plugins.shade.resource.ManifestResourceTransformer for 'classPath' -> [Help 1]

Looking at the doc

http://maven.apache.org/plugins/maven-shade-plugin/apidocs/org/apache/maven/plugins/shade/resource/ManifestResourceTransformer.html

Should be able to parse any valid manifest resource? I tried clss-path Class-Path ClassPath nothing works...

I need the classpath to set location of external app property files.

I'm using shade plugin instead of assembly because of a well known problem:

http://blog.idm.fr/2009/09/maven-assembly-plugin-and-spring-namespace-handlers.html

I can do this in assembly pretty easily by the way: (and it works)

 <manifestEntries>
  <Class-Path>. ./config</Class-Path>
 </manifestEntries>

I can't use oneJar plugin via maven because you can't set manifest entries either. (I don't think?)

Any ideas?

Tunaki
  • 132,869
  • 46
  • 340
  • 423
niken
  • 2,499
  • 3
  • 33
  • 56

1 Answers1

36

Try this and it should work with maven-shade-plugin version 2.1:

<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
 <manifestEntries>
  <Main-Class>your.main.class</Main-Class>
  <Class-Path>your/class/path/here</Class-Path>
 </manifestEntries>
</transformer>

Mark the difference in tag <Class-Path> as you had <classPath>

  • To add to this answer, I also forgot to put Class-Path in mainfestEntries, which was a silly mistake. Meant to answer my own q sooner, but forgot! Thanks for reminder. – niken Jul 29 '13 at 17:12
  • @Wrench have a look at [maven-shade-plugin/examples/resource-transformers.html](https://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html#ManifestResourceTransformer) – tomasz_kusmierczyk Dec 10 '15 at 09:38
  • It does not work for me neither. I got... [WARNING] Map in class org.apache.maven.plugins.shade.resource.ManifestResourceTransformer declares value type as: class java.util.jar.Attributes but saw: class java.lang.String at runtime [ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:2.1:shade (default) on project eigor-cli: Unable to parse configuration of mojo org.apache.maven.plugins:maven-shade-plugin:2.1:shade for parameter resource: Cannot find 'resource' in class org.apache.maven.plugins.shade.resource.ManifestResourceTransformer -> [Help 1] – danidemi Mar 31 '17 at 17:12