zoukankan      html  css  js  c++  java
  • Maven之如何用assembly插件打jar包

      maven-assembly-plugin有什么好处呢?

      英文原文:The Assembly Plugin for Maven is primarily intended to allow users to aggregate the project output along with its dependencies, 

                        modules, site documentation, and other files into a single distributable archive.

      中文翻译:Assembly 插件的主要作用是,允许用户将项目输出与它的依赖项、模块、站点文档、和其他文件一起组装成一个可分发的归档文件。

      本文以dtsf模块为例

      

      先看这个package.xml文件

      

    <assembly
            xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
        <id>reader-mysql</id>
        <formats>
            <format>dir</format>//打出来的是一个文件夹
        </formats>
        <includeBaseDirectory>false</includeBaseDirectory>
    
        <dependencySets>
    
            <dependencySet>
                <useProjectArtifact>true</useProjectArtifact>
                <outputDirectory>/</outputDirectory>
                <includes>
                    <include>com.suning.dtsf:dtsf-worker-reader-replformysql</include>
                </includes>
            </dependencySet>
    
            <dependencySet>
                <useProjectArtifact>false</useProjectArtifact>
                <outputDirectory>/lib</outputDirectory>
                <scope>runtime</scope>
                <useTransitiveFiltering>true</useTransitiveFiltering>
                <excludes>
                    <exclude>com.suning.dtsf:dtsf-worker-api</exclude>
                    <exclude>fastjson*</exclude>
                    <exclude>lz4*</exclude>
                    <exclude>slf4j*</exclude>
                    <exclude>log4j</exclude>
                    <exclude>connect-api*</exclude>
                    <exclude>kafka-clients*</exclude>
                    <exclude>commons-logging*</exclude>
                    <exclude>simpleclient*</exclude>
                </excludes>
            </dependencySet>
        </dependencySets>
    </assembly>

      再看 真的pom文件

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <parent>
            <artifactId>dtsf-worker</artifactId>
            <groupId>com.suning.dtsf</groupId>
            <version>RDRS-V3.8.0.rc</version>
        </parent>
        <modelVersion>4.0.0</modelVersion>
    
        <artifactId>dtsf-worker-reader-replformysql</artifactId>
        <dependencies>
            ...
        </dependencies>
    
        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <!--<version>2.2.1</version>-->
                    <configuration>
                        <descriptors>
                            <descriptor>src/main/assembly/package.xml</descriptor>
                        </descriptors>
                        <finalName>reader-replformysql</finalName>
                        <appendAssemblyId>false</appendAssemblyId>
                        <outputDirectory>${project.parent.parent.build.directory}/dtsf-worker/plugin/reader
                        </outputDirectory>
                    </configuration>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>single</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    
    
    </project>
  • 相关阅读:
    Windows Azure 上的 Symfony,适用于 PHP 开发者的强大组合
    VM Depot 镜像新增系列II – 学习管理系统,内容管理系统以及平台管理工具
    VM Depot 镜像新增系列III – 社交媒体,内容管理 与 项目协同系统
    教程:在 VM Depot 中查找 Azure 可用的虚拟机镜像
    使用 Chef 管理 Azure 资源
    微软开放技术发布开源的微软云服务器底盘管理器 (Chasis Manager) 软件
    使用 Gradle 实现 TFS 构建自动化
    携手 Google 和 Docker 为 Microsoft Azure 带来全新的开源容器技术
    VM Depot 中国上的 Bitnami 镜像更新至 Ubuntu 14.04 LTS
    Windows Azure云服务价格调整通知
  • 原文地址:https://www.cnblogs.com/juniorMa/p/14332686.html
Copyright © 2011-2022 走看看