(1)、在pom.xml 文件裏面的配置說明
Java代碼
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions> <!--執行器 mvn assembly:assembly-->
<execution>
<id>make-zip</id><!--名字任意 -->
<phase>package</phase><!-- 綁定到package生命週期階段上 -->
<goals>
<goal>single</goal><!-- 只運行一次 -->
</goals>
<configuration>
<descriptors> <!--描述文件路徑-->
<descriptor>src/main/resources/zip.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
<formats>
<format>tar.gz</format>
</formats>
<fileSets>
<fileSet>
<directory>src/main/config</directory> //需要打包的路徑
<outputDirectory>\</outputDirectory> //打包後輸出的路徑
下面代碼表示歸檔時包括some/path,不包括some/path1
<includes>
<include>some/path</include>
</includes>
<excludes>
<exclude>some/path1</exclude>
</excludes>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
<useProjectArtifact>true</useProjectArtifact>
<outputDirectory>lib</outputDirectory>
· <!-- 過濾 -->
· <excludes>
· <exclude>*.xml</exclude>
· </excludes>
<!-- 將scope爲runtime的依賴包打包到lib目錄下。 -->
<scope>runtime</scope>
</dependencySet>
</dependencySets>
</assembly>
format設置包輸出的格式,目前還支持zip,tar,tar.gz,tar.bz2,jar,dir,war格式
fileSet定義代碼目錄中與輸出目錄的映射
directory和outputDirectory將src/main/config目錄下的文件打包到根目錄(/)下
dependencySets節點下爲依賴設置