maven-assembly-plugin有什么好处呢?
英文原文:The Assembly Plugin for Maven is primarily intended to allow users to aggregate the project output along with its dependencies,
modules, site documentation, and other files into a single distributable archive.
中文翻译:Assembly 插件的主要作用是,允许用户将项目输出与它的依赖项、模块、站点文档、和其他文件一起组装成一个可分发的归档文件。
本文以dtsf模块为例
先看这个package.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>reader-mysql</id> <formats> <format>dir</format>//打出来的是一个文件夹 </formats> <includeBaseDirectory>false</includeBaseDirectory> <dependencySets> <dependencySet> <useProjectArtifact>true</useProjectArtifact> <outputDirectory>/</outputDirectory> <includes> <include>com.suning.dtsf:dtsf-worker-reader-replformysql</include> </includes> </dependencySet> <dependencySet> <useProjectArtifact>false</useProjectArtifact> <outputDirectory>/lib</outputDirectory> <scope>runtime</scope> <useTransitiveFiltering>true</useTransitiveFiltering> <excludes> <exclude>com.suning.dtsf:dtsf-worker-api</exclude> <exclude>fastjson*</exclude> <exclude>lz4*</exclude> <exclude>slf4j*</exclude> <exclude>log4j</exclude> <exclude>connect-api*</exclude> <exclude>kafka-clients*</exclude> <exclude>commons-logging*</exclude> <exclude>simpleclient*</exclude> </excludes> </dependencySet> </dependencySets> </assembly>
再看 真的pom文件
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <parent> <artifactId>dtsf-worker</artifactId> <groupId>com.suning.dtsf</groupId> <version>RDRS-V3.8.0.rc</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>dtsf-worker-reader-replformysql</artifactId> <dependencies> ... </dependencies> <build> <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <!--<version>2.2.1</version>--> <configuration> <descriptors> <descriptor>src/main/assembly/package.xml</descriptor> </descriptors> <finalName>reader-replformysql</finalName> <appendAssemblyId>false</appendAssemblyId> <outputDirectory>${project.parent.parent.build.directory}/dtsf-worker/plugin/reader </outputDirectory> </configuration> <executions> <execution> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project>