gpt4 book ai didi

java - 如何使用 Maven Shade 插件捆绑来自不同模块的类

转载 作者:行者123 更新时间:2023-12-01 16:59:54 29 4
gpt4 key购买 nike

我想生成一个包含包“com.x”和来自另一个包“com.y”的类(比方说,Utils.class)的jar。我可以将完整的包 com.y 捆绑在阴影 jar 中,但我只想要一个类。它似乎不适用于我下面的。我也尝试过提供类的路径:com/bar/cli/pol/Utils.class,但没有任何运气。

   <dependencies>
<dependency>
<groupId>com.x</groupId>
<artifactId>foo</artifactId>
</dependency>
<dependency>
<groupId>com.y</groupId>
<artifactId>bar</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>com.x:foo</include>
<include>com.y:bar:**/Utils.class</include>
</includes>
</artifactSet>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

最佳答案

我通过执行以下操作来实现此目的:

<configuration>
<finalName>myshadedjar</finalName>
<artifactSet>
<includes>
<include>com.x:foo</include>
<include>com.y:bar</include>
</includes>
</artifactSet>
<filters>
<filter>
<artifact>com.y:bar</artifact>
<includes>
<include>com/bar/cli/pol/Utils.class</include>
</includes>
</filter>
</filters>

关于java - 如何使用 Maven Shade 插件捆绑来自不同模块的类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61526011/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com