maven assembly plugin

戚兴邦
2023-12-01

官方介绍: 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:依赖

 类似资料:

相关阅读

相关文章

相关问答