我正在制作一个包含项目jar和所有依赖项的额外jar,作为我的maven构建的一部分(使用maven-assembly-plugin):
在汇编XML文件中:
<dependencySet>
<unpack>false</unpack>
<scope>runtime</scope>
<useProjectArtifact>false</useProjectArtifact>
<outputDirectory>lib</outputDirectory>
</dependencySet>
在POM中:
<archive>
<manifest>
<mainClass>dk.intelligentsystems.platform.deploy.Deployer</mainClass>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
</archive>
jar包含正确的文件,但依赖项未添加到manufest Classpath属性中。我怎样才能做到这一点?
答案 0 :(得分:0)
而不是maven-assembly-plugin,我将maven-shade-plugin与maven-jar-plugin结合用于同一目的。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
<exclude>.settings/**</exclude>
<exclude>*.classpath</exclude>
<exclude>*.project</exclude>
<exclude>*.txt</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>