我已经创建了我的项目的war包装,并且在同一个pom.xml文件中,我已经包含了下面的插件来创建jar。一切正常,它会创建jar和war文件。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>make-a-jar</id>
<phase>compile</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
现在我的问题是,我如何合并两个罐子?我想将一个jar的内容包含在上面创建的jar中。意味着在maven中创建其他jar时将一个jar的内容复制到另一个jar中。
答案 0 :(得分:-1)
这解决了我的问题,
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>${project.artifactId}</id>
<phase>generate-sources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>groupId_for_jar_to_copy</groupId>
<artifactId>artifactId_for_jar_to_copy</artifactId>
<version>version_for_jar_to_copy</version>
<type>jar</type>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}/classes</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>make-a-jar</id>
<phase>compile</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<finalName>jar_file_name</finalName>
</configuration>
</execution>
</executions>
</plugin>