1
我正在使用Maven Shade Plugin在包階段包含所有依賴關係。 對類很好,但不包括依賴資源。Maven Shade插件不包括依賴資源
這裏有依賴的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
這裏的樹蔭插件配置:
<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>
您是否嘗試過使用最新版本的[maven-shade-plugin](https://maven.apache.org/plugins/maven-shade-plugin/)並且沒有進行任何配置。 – khmarbaise 2013-05-14 06:46:01
我已經用一個簡單的多模塊項目測試了這個,並且使用了1.6版本和2.0版本的shade插件,我的屬性文件被複制了。你可以嘗試添加junit:junit:4.11(編譯範圍)作爲依賴關係,並查看Licence.txt是否被複制?如果它仍然無法工作,請您添加您的項目佈局和完整的POM。謝謝。 – mszalbach 2013-05-14 07:02:04
是的,複製了License.txt。我會添加更多信息。 – lilalinux 2013-05-14 07:52:08