[英]maven assembly plugin including jars dependencies and external files
我正在尝试使用Assembly插件来包括依赖项以及
这是我的程序集插件
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4.1</version>
<executions>
<execution>
<id>create-executable-jar</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<descriptorRef>
jar-with-dependencies
</descriptorRef>
</descriptorRefs>
<descriptors>
<descriptor>src/assembly/assembly.xml</descriptor>
</descriptors>
<archive>
<manifest>
<mainClass>com.sarm.myproject.XMLParser.LPUnMarshaller</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
这是我的assembly.xml描述符,因为它为此描述符创建了一个不同的jar,所以我使ID与descritpor ref相同。 所以我有两个描述符,一个是带有依赖关系的jar描述符,一个是下面的描述符,在这种情况下,正在创建两个jar,第二个jar覆盖了先前的jar。 怎么把这两个放在同一个罐子里。
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>jar-with-dependencies</id>
<formats>
<format>jar</format>
</formats>
<fileSets>
<fileSet>
<directory>${basedir}</directory>
<includes>
<include>*.xml</include>
</includes>
<excludes>
<exclude>30000dests.xml</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>${basedir}/test</directory>
<includes>
<include>*.xml</include>
</includes>
</fileSet>
</fileSets>
</assembly>
编辑:我尝试了其他方法,并且看到如果我使用assembly.xml作为描述符,则会在创建的其他任何默认jar旁边创建一个新jar。 所以我最终得到了两个罐子。 默认的jar是可执行文件,就像配置jar插件一样。 即使程序集插件配置为具有manifest.mf且具有我的主类名称,通过assmbly.xml创建的jar也不可执行,并且具有我的项目名称文件夹,其中包含可执行jar。
我使用mvn clean install构建项目和jar文件。
您应该创建两个产生两个jar的模块。 通常,maven将为每个模块生成一个jar文件,并将模块名称作为jar名称。 Maven建议每个模块都有一个输出工件。
如果您对复制代码有疑问。 您可以通过拥有父pom来继承相关内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.