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>
  • 相关阅读:
    调试某狐木马驱动被杀后系统卡死开机
    情景剧:C/C++中的未定义行为(undefined behavior)
    汇编概念辨析(Intel/AT&T syntax、GAS、NASM)
    软考准考证打印设置(IE1909)
    基于redis的分布式锁 RedissonLock解锁异常解决
    深入理解synchronized
    单利模式
    归并排序
    旧电脑硬盘回收
    萤石、乐橙、3D
  • 原文地址:https://www.cnblogs.com/juniorMa/p/14332686.html
Copyright © 2011-2022 走看看