1

I'm using the Maven Shade Plugin to include all dependencies during package phase. That works fine for classes, but dependent resources aren't included.

Here's the layout of the dependent jar:

./config.properties <-- this is the missing resource
./META-INF
./META-INF/MANIFEST.MF
./META-INF/maven
./META-INF/maven/com.example
./META-INF/maven/com.example/bar
./META-INF/maven/com.example/bar/pom.properties
./META-INF/maven/com.example/bar/pom.xml

Here's the shade plugin configuration:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>1.6</version>
    <executions>
      <execution>
        <phase>package</phase>
        <goals>
          <goal>shade</goal>
        </goals>
        <configuration>
          <transformers>
            <transformer
              implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
              <manifestEntries>
                <Main-Class>com.example.foo.Foo</Main-Class>
                <!-- <X-Compile-Source-JDK>${maven.compile.source}</X-Compile-Source-JDK>.
                  <X-Compile-Target-JDK>${maven.compile.target}</X-Compile-Target-JDK> -->
              </manifestEntries>
            </transformer>
          </transformers>
          <filters>
            <filter>
              <!--
                Exclude files that sign a jar
                (one or multiple of the dependencies).
                One may not repack a signed jar without
                this, or you will get a
                SecurityException at program start.
              -->
              <artifact>*:*</artifact>
              <excludes>
                <exclude>META-INF/*.SF</exclude>
                <exclude>META-INF/*.RSA</exclude>
                <exclude>META-INF/*.INF</exclude> <!-- This one may not be required -->
              </excludes>
            </filter>
          </filters>
        </configuration>
      </execution>
    </executions>
  </plugin>
Tunaki
  • 132,869
  • 46
  • 340
  • 423
lilalinux
  • 2,903
  • 3
  • 43
  • 53
  • Have you tried with the up-to-date version of [maven-shade-plugin](https://maven.apache.org/plugins/maven-shade-plugin/) and without any configuration. – khmarbaise May 14 '13 at 06:46
  • 1
    I have tested this with a simple multi module project and with version 1.6 and 2.0 of the shade plugin my property files are copied. Could you try to add junit:junit:4.11 (compile scope) as dependency and see if the Licence.txt is copied? If its still not work could you please add your project layout and the complete pom. Thx. – mszalbach May 14 '13 at 07:02
  • Yes, the License.txt is copied. I'll add more info. – lilalinux May 14 '13 at 07:52
  • It's quite embarrasing, but there was a typo in the version of the dependency and that version didn't have that file :-/ Should I delete this question? – lilalinux May 14 '13 at 10:35

1 Answers1

2

It's embarrasing, but there was a typo in the version of the dependency and that version didn't have the file.

lilalinux
  • 2,903
  • 3
  • 43
  • 53