我一直在尝试使用 Maven Shade Plugin 获取 jar,但我仍然没有成功。
这是我的项目结构:
MainModule
-Module1
-src
-pom.xml
-Module2
-src
-pom.xml
-pom.xml
模块 1(pom.xml):
<parent>
<artifactId>MainModule</artifactId>
<groupId>com.plugintest</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>Module1</artifactId>
模块 2(pom.xml):
<parent>
<artifactId>MainModule</artifactId>
<groupId>com.plugintest</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>Module1</artifactId>
主模块(pom.xml):
<groupId>com.plugintest</groupId>
<artifactId>MainModule</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
<module>Module1</module>
<module>Module2</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
根据这段代码,我得到 2 个 jar 文件(Module1-version.jar 和 Module2-version.jar)。但这不是我想要的。我希望获得 1 个 jar 文件(MainModule-version.jar),其中包含另一个(Module1 和 Module2)。
为什么这个 Shade 插件不起作用?