maven-assembly-plugin插件使用记录

1. pom.xml

<plugin>
	<artifactId>maven-assembly-plugin</artifactId>
	<configuration>
		<archive>
			<manifest>
				<!-- 主类 -->
				<mainClass>com.deem.zkui.Main</mainClass>
			</manifest>
		</archive>
		<descriptors>
			<!-- 打包描述文件 -->
			<descriptor>release.xml</descriptor>
		</descriptors>
	</configuration>
	<executions>
		<execution>
			<id>make-assembly</id>
			<phase>package</phase>
			<goals>
				<goal>single</goal>
			</goals>
		</execution>
	</executions>
</plugin>

2. release.xml

<assembly>
	<baseDirectory>zk-ui</baseDirectory>
	<formats>
		<!-- 输出类型 -->
		<format>dir</format>
		<format>tar.gz</format>
	</formats>
	<!-- 包含根目录,即解压之后,会有上面的zk-ui目录 -->
	<includeBaseDirectory>true</includeBaseDirectory>
	<fileSets>
		<fileSet>
			<!-- 输出目录,相对baseDirectory -->
			<outputDirectory>/</outputDirectory>
			<includes>
				<!-- 包含文件 -->
				<include>log4j.properties</include>
				<include>config.cfg</include>
			</includes>
		</fileSet>
	</fileSets>
	<files>
		<file>
			<!-- 包含jar包,使用此种方式不包含target目录,如果使用上面fileSet的方式,会包含target目录 -->
			<source>target/zkui-2.0-SNAPSHOT.jar</source>
		</file>
	</files>
</assembly>

3. 注意事项

经过测试,如果maven项目中有子项目。不能在父项目的pom中配置descriptor,需要新建一个子项目专门用来打包。举例:如果有父项目A,子项目B和C继承A,那么如果需要打包所有项目的jar包以及conf等目录,必须新建一个项目D继承A,在项目D中配置maven-assembly-plugin和descriptor。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值