maven assembly plugin

本文详细介绍了如何使用Maven Assembly插件构建发布包,包括配置方法、自定义assembly descriptor及常见元素说明。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

官方介绍: https://maven.apache.org/plugins/maven-assembly-plugin/

用于将工程构建后整合为发布包

使用步骤:

pom中Assembly插件配置

Assembly Plugin有预置的assembly descriptor,在插件jar包中,分别是bin.xml jar-with-dependencies.xml project.xml src.xml,通过descriptorRefs标签直接使用,可配置多个

jar包名称的classifier就是从这里来

Notice the artifact classifier, between the end of the version and the beginning of the file extension, jar-with-dependencies. This is the id of the assembly descriptor used to create this artifact.

自定义descriptor,通过descriptors标签指定路径

配置示例:

<plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.6</version>
    <executions>
        <execution>
            <id>assemble-vertx-module</id>
            <phase>package</phase>
            <goals>
                <goal>single</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <descriptors>
            <descriptor>src/assembly/assemble-vertx-module.xml</descriptor>
        </descriptors>
    </configuration>
</plugin>

descriptor编写

常用元素:

id : 会作为artifact’s classifier

formats : “zip” “tar” “jar”等

includeBaseDirectory : zip包是否需要一个根目录${project.build.finalName},默认为true,设置为false后打开zip包可直接看到内容

fileSet: 文件夹单位

directory:

outputDirectory: 

fileMode:文件UNIX权限,默认644

directoryMode:文件夹UNIX权限,默认755

lineEnding:文件换行符 "unix" 

file : 单个文件

source

outputDirectory

destName:默认与原文件名相同

fileMode:文件UNIX权限,默认644

lineEnding:文件换行符 "unix" 

dependencySets:依赖

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值