• 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>
  • 相关阅读:
    嵌入式Linux系统移植(二)——交叉编译工具集
    嵌入式linux系统移植(一)
    C语言常用关键语法精华总结
    ARM汇编常用指令
    嵌入式Linux系统移植——uboot常用命令
    VHDL的参数写在一个vhd文件里
    [PAT] 1077 Kuchiguse (20 分)Java
    [PAT] 1073 Scientific Notation (20 分)Java
    [PAT] 1069 The Black Hole of Numbers (20 分)Java
    [PAT] 1065 A+B and C (64bit) (20 分)Java
  • 原文地址:https://www.cnblogs.com/juniorMa/p/14332686.html
Copyright © 2020-2023  润新知