maven-assembly-plugin插件打jar包时排出指定的依赖
Posted 记录
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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>
以上是关于maven-assembly-plugin插件打jar包时排出指定的依赖的主要内容,如果未能解决你的问题,请参考以下文章