maven-assembly-plugin : 是maven中针对打包任务而提供的标准插件
(1)、在pom.xml 文件里面的配置说明
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <executions>
- <execution>
- <id>make-zip</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- <configuration>
- <descriptors>
- <descriptor>src/main/resources/zip.xml</descriptor>
- </descriptors>
- </configuration>
- </execution>
- </executions>
- </plugin>
(2)、zip.xml 文件配置如下
- <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>release</id>
- <formats>
- <format>zip</format>
- </formats>
- <fileSets>
- <fileSet>
- <directory>${project.basedir}\src\main\config</directory>
-
- <excludes>
- <exclude>*.xml</exclude>
- </excludes>
- <outputDirectory>\</outputDirectory>
- </fileSet>
- </fileSets>
-
- <dependencySets>
- <dependencySet>
- <useProjectArtifact>true</useProjectArtifact>
- <outputDirectory>lib</outputDirectory>
- <scope>runtime</scope>
- </dependencySet>
- </dependencySets>
- </assembly>
(3)、zip.xml 格式属性说明
打包的文件格式
可以有:tar.zip war zip
<formats>
<format>zip</format>
</formats>
需要打包的路径
<directory>${project.basedir}</directory>
打包后输出的路径
<outputDirectory>/</outputDirectory>
打包需要包含的文件
<excludes>
<exclude>junit:junit</exclude>
<exclude>commons-lang:commons-lang</exclude>
<exclude>commons-logging:commons-logging</exclude>
</excludes>
当前项目构件是否包含在这个依赖集合里。
<useProjectArtifact>true</useProjectArtifact>
依赖包打包到目录下
<dependencySets>
<dependencySet>
<outputDirectory>lib</outputDirectory><!-- 将scope为runtime的依赖包打包到lib目录下。 -->
<useProjectArtifact>true</useProjectArtifact>
<scope>runtime</scope>
</dependencySet>
</dependencySets>