我一直在尝试使用Maven Shade插件获取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>
MainModule(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>
根据这段代码,我得到了两个jar文件(Module1-version.jar和Module2-version.jar)。但这不是我想要的。我希望得到一个包含其他两个模块(Module1和Module2)的jar文件(MainModule-version.jar)。
为什么Shade插件不起作用呢?