1、添加Maven插件 pom.xml
<!--maven自定义打包插件--><plugin><artifactId>maven-assembly-plugin</artifactId><version>3.1.0</version><configuration><descriptors><!-- 配置文件路径 --><descriptor>src/main/resources/config/package.xml</descriptor></descriptors></configuration><executions><execution><id>make-assembly</id><phase>package</phase><goals><goal>single</goal></goals></execution></executions></plugin><!--maven单元测试插件--><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-surefire-plugin</artifactId><configuration><!--跳过测试--><skipTests>true</skipTests><!--忽略测试失败 --><testFailureIgnore>true</testFailureIgnore></configuration></plugin><!--maven打包git提交版本--><plugin><groupId>pl.project13.maven</groupId><artifactId>git-commit-id-plugin</artifactId><version>2.2.5</version><executions><execution><goals><goal>revision</goal></goals></execution></executions><configuration><verbose>true</verbose><generateGitPropertiesFile>true</generateGitPropertiesFile><injectAllReactorProjects>true</injectAllReactorProjects></configuration></plugin>
2、package.xml配置
<!--具体含义参见官网 /plugins/maven-assembly-plugin/assembly.html--><assembly><id>release</id><!--maven打包类型,当前为zip和tar.gz--><formats><format>tar.gz</format><format>zip</format></formats><includeBaseDirectory>false</includeBaseDirectory><fileSets><fileSet><!--需要打包的文件所在路径--><directory>src/main/resources</directory><!--需要打包的文件--><includes><include>application-prod.yml</include></includes><!--打到压缩包的路径--><outputDirectory>.</outputDirectory><fileMode>0755</fileMode></fileSet><fileSet><directory>${project.basedir}/target/classes</directory><outputDirectory>.</outputDirectory><includes><include>git.properties</include></includes><fileMode>0755</fileMode></fileSet></fileSets></assembly>
如果觉得《maven项目打包成zip文件》对你有帮助,请点赞、收藏,并留下你的观点哦!