我发现只有在特定顺序中将jar添加到类路径中时,Confluent Kafka Connect插件才有效。
因此,我正在尝试构建一个包含jar的单个阴影jar,以相同的顺序选择冲突的类。
我的问题是如何控制将罐子添加到阴影罐中的顺序?
我发现Maven按以下顺序处理jar:
我相信这个基于订单罐的列表在下面的列表中列出(列表包括用于识别;我已经截断它,因为它不是特别有启发性):
[INFO] --- maven-shade-plugin:2.1:shade (default) @ kafka-connect-plus ---
[INFO] Including org.apache.hadoop:hadoop-common:jar:2.7.3 in the shaded jar.
[INFO] Excluding com.google.guava:guava:jar:11.0.2 from the shaded jar.
[INFO] Excluding org.apache.commons:commons-math3:jar:3.1.1 from the shaded jar.
[INFO] Excluding xmlenc:xmlenc:jar:0.52 from the shaded jar.
[INFO] Excluding commons-httpclient:commons-httpclient:jar:3.1 from the shaded jar.
[INFO] Excluding commons-codec:commons-codec:jar:1.4 from the shaded jar.
[INFO] Excluding commons-net:commons-net:jar:3.1 from the shaded jar.
[INFO] Excluding javax.servlet:servlet-api:jar:2.5 from the shaded jar.
[INFO] Excluding org.mortbay.jetty:jetty:jar:6.1.26 from the shaded jar.
[INFO] Excluding org.mortbay.jetty:jetty-util:jar:6.1.26 from the shaded jar.
[INFO] Excluding javax.servlet.jsp:jsp-api:jar:2.1 from the shaded jar.
我的阴影插件片段:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>org.apache.hadoop:hadoop-common</include>
<include>org.apache.avro:avro-ipc</include>
<include>org.apache.parquet:parquet-avro</include>
<include>io.confluent:kafka-avro-serializer</include>
<include>org.apache.avro:avro</include>
<include>org.apache.avro:avro-mapred</include>
<include>io.confluent:kafka-connect-avro-converter</include>
<include>io.confluent:kafka-schema-registry-client</include>
<include>io.confluent:common-utils</include>
<include>io.confluent:common-config</include>
</includes>
</artifactSet>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
(这还不是一个完整的罐子清单)。
从上面可以看出,jar处理的顺序不符合include
标签的顺序。
答案 0 :(得分:0)
再次阅读我的问题,我意识到上面的过程完成了我想要的,一旦我完成了将直接依赖项列入白名单的过程:我依赖于它们在依赖项部分中指定的顺序。