码迷,mamicode.com
首页 > 编程语言 > 详细

maven-assembly-plugin插件打jar包时排出指定的依赖

时间:2020-03-02 17:36:23      阅读:87      评论:0      收藏:0      [点我收藏+]

标签:encoding   oop   pos   ack   pen   github   ali   jetty   nio   

pom.xml

<?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">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.unionpay.bigdataTest</groupId>
    <artifactId>kafka-tool-recordkryo</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <dependencies>

        <!-- Provided by kafkatool2 -->
        <dependency>
            <groupId>com.kafkatool</groupId>
            <artifactId>kafkatool</artifactId>
            <version>2.0.7</version>
            <scope>system</scope>
            <systemPath>${basedir}/lib/ofjar.jar</systemPath>
        </dependency>

        <!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.62</version>
        </dependency>

        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.15</version>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>javax.jms</groupId>
                    <artifactId>jms</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.sun.jdmk</groupId>
                    <artifactId>jmxtools</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.sun.jmx</groupId>
                    <artifactId>jmxri</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.25</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.9</version>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>log4j</groupId>
                    <artifactId>log4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.0.0</version>
                <configuration>
                    <descriptors> <!--描述文件路径-->
                        <descriptor>src/main/assembly/package.xml</descriptor>
                    </descriptors>
                    <!--
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    -->
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

src/main/assembly/package.xml

<?xml version="1.0" encoding="UTF-8" ?>
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
    <id>jar-with-dependencies</id>
    <formats>
        <format>jar</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>
    <dependencySets>
        <dependencySet>
            <outputDirectory>/</outputDirectory>
            <useProjectArtifact>true</useProjectArtifact>
            <unpack>true</unpack>
            <scope>runtime</scope>
            <excludes>
                <!-- 排除这些在kafkatool2/lib存在的相关依赖-->
                <exclude>com.google.code.gson:gson</exclude>
                <exclude>org.apache.zookeeper:zookeeper</exclude>
                <!-- 这些应该用不到-->
                <exclude>org.apache.hadoop:hadoop-annotations</exclude>
                <exclude>org.apache.hadoop:hadoop-auth</exclude>
                <exclude>org.apache.hadoop:hadoop-common</exclude>
                <exclude>org.apache.hadoop:hadoop-core</exclude>
                <exclude>org.apache.hbase:hbase-annotations</exclude>
                <exclude>org.apache.hbase:hbase-client</exclude>
                <exclude>org.apache.hbase:hbase-protocol</exclude>
                <exclude>org.apache.hbase:hbase-common</exclude>
                <exclude>org.apache.kudu:kudu-client</exclude>
                <exclude>io.netty:netty-all</exclude>
                <exclude>javax.mail:mail</exclude>
                <exclude>javax.servlet.jsp:jsp-api</exclude>
                <exclude>javax.servlet:servlet-api</exclude>
                <exclude>junit:junit</exclude>
                <exclude>tomcat:jasper-compiler</exclude>
                <exclude>tomcat:jasper-runtime</exclude>
                <exclude>hsqldb:hsqldb</exclude>
                <exclude>com.github.stephenc.findbugs:findbugs-annotations</exclude>
                <exclude>com.google.code.findbugs:jsr</exclude>
                <exclude>com.sun.jersey:jersey-core</exclude>
                <exclude>com.sun.jersey:jersey-json</exclude>
                <exclude>commons-httpclient:commons-httpclient</exclude>
                <exclude>org.apache.curator:curator-client</exclude>
                <exclude>org.apache.curator:curator-framework</exclude>
                <exclude>org.apache.curator:curator-recipes</exclude>
                <exclude>org.mortbay.jetty:jetty</exclude>
                <exclude>org.mortbay.jetty:jetty-util</exclude>
            </excludes>
        </dependencySet>
    </dependencySets>
</assembly>

maven-assembly-plugin插件打jar包时排出指定的依赖

标签:encoding   oop   pos   ack   pen   github   ali   jetty   nio   

原文地址:https://www.cnblogs.com/darange/p/12396792.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!