标签:add eve xxx cut 前缀 set targe exec ddc
1.POM文件添加jar包生成插件
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<archive>
<manifest>
<mainClass>${mainClass}</mainClass>
<!-- 是否指定项目classpath下的依赖 -->
<addClasspath>true</addClasspath>
<!-- 指定依赖的时候声明前缀 -->
<classpathPrefix>./lib/</classpathPrefix>
<!--依赖是否使用带有时间戳的唯一版本号,如:xxx-1.3.0-20121225.012733.jar-->
<useUniqueVersions>false</useUniqueVersions>
</manifest>
</archive>
</configuration>
</plugin>
2.添加第三方依赖打包插件
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.basedir}/target/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
3.添加assembly打包插件
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<!-- 配置执行器 -->
<execution>
<id>make-assembly</id>
<phase>package</phase><!-- 绑定到package生命周期阶段上 -->
<goals>
<goal>single</goal><!-- 只运行一次 -->
</goals>
<configuration>
<finalName>${project.name}</finalName>
<!--配置描述文件路径-->
<descriptor>assembly.xml</descriptor>
</configuration>
</execution>
</executions>
</plugin>
4.添加打包描述文件assembly.xml
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
<id>dropwizard-package</id>
<!--打包格式-->
<formats>
<format>tar.gz</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<!--导入指定文件到tar.gz包-->
<fileSet>
<directory>${project.basedir}/target</directory>
<outputDirectory>./${project.name}</outputDirectory>
<directoryMode>0775</directoryMode>
<fileMode>0775</fileMode>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.basedir}/target/lib</directory>
<outputDirectory>./${project.name}/lib</outputDirectory>
<directoryMode>0775</directoryMode>
<fileMode>0775</fileMode>
</fileSet>
<fileSet>
<directory>${project.basedir}/src/main/resources</directory>
<outputDirectory>./${project.name}/conf</outputDirectory>
<directoryMode>0775</directoryMode>
<fileMode>0775</fileMode>
</fileSet>
</fileSets>
</assembly>
5.Over!!!
maven打包插件maven-assembly-plugin
标签:add eve xxx cut 前缀 set targe exec ddc
原文地址:https://www.cnblogs.com/ilovena/p/9973813.html