如何使用 maven shade 插件从不同模块捆绑 类
How to bundle classes from different modules using maven shade plugin
我想生成一个包含包 'com.x' 和来自另一个包 'com.y' 的 class(比方说,Utils.class)的 jar。我可以将完整的包 com.y 捆绑在阴影罐中,但我只想要一个 class。它似乎不适用于我在下面。我也尝试过提供 class 的路径: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>
我想生成一个包含包 'com.x' 和来自另一个包 'com.y' 的 class(比方说,Utils.class)的 jar。我可以将完整的包 com.y 捆绑在阴影罐中,但我只想要一个 class。它似乎不适用于我在下面。我也尝试过提供 class 的路径: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>