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


    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>
    
  • 相关阅读:
    idea 开发中常用的36个快捷键!
    算法学习一
    elastic-job-lite使用文档
    Windows使用Fiddler对手机抓包或调试本地计算机web站点方法
    Thread.join的作用和原理
    static修饰的代码块被称作静态代码块
    【Java面试题】52 java中会存在内存泄漏吗,请简单描述。
    数据类型 Object.keys,values,entries
    数据类型 Map and Set(映射和集合)
    数组映射到对象
  • 原文地址:https://www.cnblogs.com/darange/p/12396792.html
Copyright © 2020-2023  润新知