使用方法
描述符文件元素介绍(assembly.xml)
id
formats
dependencySets
fileSets
files

当你使用 Maven 对项目打包时,你需要了解以下 3 个打包 plugin,它们分别是

下面我们就简单介绍一下 maven-assembly-plugin。

使用方法
使用 descriptorRefs(官方提供的定制化打包方式),官方提供的 descriptorRef 有 bin, jar-with-dependencies, src, project。【不建议使用】

<project>
  [...]
  <build>
    [...]
    <plugins>
      <plugin>
        <!-- NOTE: We don't need a groupId specification because the group is
             org.apache.maven.plugins ...which is assumed by default.
         -->
        <artifactId>maven-assembly-plugin</artifactId>
        <version>3.0.0</version>
        <configuration>
          <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
          </descriptorRefs>
        </configuration>
        [...]
</project>

使用 descriptors,指定打包文件 src/assembly/src.xml,在该配置文件内指定打包操作。

<project>
  [...]
  <build>
    [...]
    <plugins>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>3.0.0</version>
        <configuration>
          <descriptors>
            <descriptor>src/assembly/src.xml</descriptor>
          </descriptors>
        </configuration>
        [...]
</project>

描述符文件元素介绍(assembly.xml)
id
<id>dist-beta.9</id>

id 标识符,添加到生成文件名称的后缀符。如果指定 id 的话,目标文件则是 {artifactId}-{id}.tar.gz

formats
maven-assembly-plugin 支持的打包格式有zip、tar、tar.gz (or tgz)、tar.bz2 (or tbz2)、jar、dir、war,可以同时指定多个打包格式

<formats>
    <format>tar.gz</format>
    <format>dir</format>
  </formats>

dependencySets
用来定制工程依赖 jar 包的打包方式,核心元素如下表所示。

<dependencySets>
        <dependencySet>
            <outputDirectory>lib</outputDirectory>
            <useTransitiveDependencies>true</useTransitiveDependencies>
            <unpack>false</unpack>
            <scope>runtime</scope>
            <useProjectArtifact>false</useProjectArtifact>
        </dependencySet>
</dependencySets>

fileSets
管理一组文件的存放位置,核心元素如下表所示。

<fileSets>
    <fileSet>
      <includes>
        <include>bin/**</include>
      </includes>
      <fileMode>0755</fileMode>
    </fileSet>

<fileSet>
      <includes>
        <include>/conf/**</include>
        <include>logs</include>
      </includes>
    </fileSet>

</fileSets>

files
可以指定目的文件名到指定目录,其他和 fileSets 相同,核心元素如下表所示。


<files>
    <file>
      <source>README.txt</source>
      <outputDirectory>/</outputDirectory>
    </file>
</files>

maven-assembly-plugin 快速入门(maven assembly 插件)相关推荐

  1. Spring MVC 4快速入门Maven原型已改进

    Spring Boot使Spring入门非常容易. 但是仍然有人对不使用Spring Boot并以更经典的方式引导应用程序感兴趣. 几年前,我创建了一个原型(早于Spring Boot),简化了引导S ...

  2. Maven Assembly Plugin - 如何将Maven工程打成一个可执行jar包

    参考自: http://blog.csdn.net/symgdwyh/article/details/6081532 Maven Assembly Plugin http://maven.apache ...

  3. SSM框架自学(四)——Maven项目管理工具快速入门

    前言:最初Java SSM搭建Web项目时,采用的是比较繁琐的手动导入jar包的形式,我们得去对应官网上到处找各种jar包,然后下载好导入自己项目的lib目录中.下面就是一个最简单的SSM项目所需的j ...

  4. 用Maven Archetype Plugin快速创建项目

    还在用mvn archetype:create -DarchetypeArtifactId=maven-archetype-quickstart -DgroupId=com.ryanote -Dart ...

  5. Spring MVC 4快速入门Maven原型得到了改进–更多Java 8功能

    对于所有有兴趣在没有Spring Boot的情况下快速引导Spring 4应用程序的开发人员,请检查刚刚更新的我的Spring MVC 4 Quickstart Maven原型. 原型已经将Java ...

  6. canvas js 绘图插件_快速入门前端图表插件Echart

    在前端项目开发中,有很多地方会遇到绘制图表的需求,一般的图表可以通过canvas来绘制,但是遇到复杂一点的图表怎么办呢? 而且黑马的课程大纲已经把canvas课程删掉了,既然canvas有用,为什么要 ...

  7. 快速全面入门Maven(二)--Maven的生命周期

    这里写目录标题 开头说 生命周期 生命周期概念 三种标准生命周期   Clean生命周期   Default生命周期   Site生命周期 生命周期的绑定 个性化生命周期 生命周期扩展 小结 开头说 ...

  8. Thymeleaf 3 – Thymeleaf 3和Spring MVC快速入门

    Thymeleaf 3发布到达. 新版本带来了许多新功能,例如HTML5支持以及不带标记的文本模板支持– [# th:utext="${thymeleaf.version}" /] ...

  9. Maven自定义打包插件Assembly Plugin简单使用

    使用Assembly Plugin实现自定义打包 1.修改pom.xml <!-- 编译时自动打包,规则见distribution.xml文件--> <build><pl ...

  10. maven 报错 Failed to create assembly: archive cannot be empty

    背景: pom.xml 里面 plugin 的配置如下: <plugin><groupId>org.apache.maven.plugins</groupId>&l ...

最新文章

  1. LeetCode简单题之键盘行
  2. 老师买50斤小龙虾给学生上实验课,网友:我还能有心思上课?
  3. Google 首次引入数据中心液体冷却
  4. Excel单元格里面提取或去掉某些字符
  5. spring 属性占位符_Spring属性占位符配置器–一些不太明显的选项
  6. 【转贴】ListView控件学习系列2-编辑ListView
  7. JavaWeb应用项目部署到云ubuntu
  8. 基于 Intel 的 Mac,如何使用机构恢复密钥的技巧
  9. yum文件,来自网络
  10. 用户事件的存储与分析
  11. 一套包含完整前后端的系统如何在K8S中部署?
  12. Swift 开源项目汇总
  13. JavaScript学习简单总结
  14. html特殊符号的例子,CSS/HTML 开发中常用 特殊符号(常用字符实体) 相关扩展(琐碎知识点整理)...
  15. 2019 Multi-University Training Contest 6 1005 Snowy Smile —— 线段树
  16. html body与页面的距离,html - 如何在TBODY元素之间放置间距
  17. Kaldi WFST HCLG.fst 构图 学习
  18. Java-翁恺进阶 城堡游戏的前世今生
  19. 1056: 兔子繁殖问题
  20. 无偏性、有效性、一致性

热门文章

  1. vue组件封装讲解,和注意事项
  2. 信息隐藏隐写系统框架
  3. BeanCopier 详解
  4. 贪吃蛇详细教程-C++实现
  5. Java迭代器 | Iterator用法
  6. 论 Java 如何优雅的导出 Excel~
  7. jieba入门记录——nltk中文语料处理
  8. Error 1275 - 此驱动程序被阻止加载
  9. GLES3.0中文API-glViewport
  10. 管中窥豹——从C语言的一个基础问题讲起