我有一個多模塊項目。 每個模塊都封裝在他自己/目標文件夾中的jar/war文件中。如何在一個zip文件中打包多個模塊?
我想把每個模塊jar/war文件和一些配置文件,並把所有的東西放在一個zip文件。
如何做到這一點?我嘗試使用匯編插件,但所有我設法做到目前爲止是在各自的/目標文件夾中的每個模塊的zip,所以很沒用^^
我有一個多模塊項目。 每個模塊都封裝在他自己/目標文件夾中的jar/war文件中。如何在一個zip文件中打包多個模塊?
我想把每個模塊jar/war文件和一些配置文件,並把所有的東西放在一個zip文件。
如何做到這一點?我嘗試使用匯編插件,但所有我設法做到目前爲止是在各自的/目標文件夾中的每個模塊的zip,所以很沒用^^
首先是創建一個單獨的模塊讓我們稱之爲dist
添加到父爲新的模塊,並添加你喜歡在生成的壓縮文件中看到所有模塊作爲依賴包括類型war
,jar
等
的<packaging>pom</packaging>
應給予事業這個模塊不包含任何Java代碼需要進行編譯等。我們只想創建包含給定依賴關係的zip文件。
<project ..>
<packaging>pom</packaging>
<dependencies>
<dependency>
<groupId>module-1</groupId>
<artifactId>module-1-artifact</artifactId>
<version>${project.version}</version>
<type>war</type>
</dependency>
<dependency>
<groupId>module-2</groupId>
<artifactId>module-2-artifact</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>make-bundles</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>proj1-assembly.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
添加以下描述:
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>dist-assembly</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<outputDirectory>/</outputDirectory>
<useProjectArtifact>false</useProjectArtifact>
<unpack>false</unpack>
</dependencySet>
</dependencySets>
</assembly>
的依賴,需要以確保執行順序正確Maven的計算。
如果您需要在該zip文件中進行補充配置,則可以將這些文件添加到src/main/config
中,例如在該程序集描述符中添加fileSets部分。
不明白爲什麼不接受這個答案:)謝謝,用它,投了票。 –
可能重複[什麼是超級罐子?](http://stackoverflow.com/questions/11947037/what-is-an-uber-jar) –