Maven:在创建带有依赖项的jar时删除jar文件
我有4个模块 我的一般pom如下所示:Maven:在创建带有依赖项的jar时删除jar文件,maven,maven-plugin,maven-assembly-plugin,Maven,Maven Plugin,Maven Assembly Plugin,我有4个模块 我的一般pom如下所示: <artifactId>A</artifactId> <name>Modules</name> <packaging>pom</packaging> <modules> <module>B</module> <module>C</module> <module>D</module>
<artifactId>A</artifactId>
<name>Modules</name>
<packaging>pom</packaging>
<modules>
<module>B</module>
<module>C</module>
<module>D</module>
<module>E</module>
</modules>
A
模块
聚甲醛
B
C
D
E
在模块E中,我有一个主类,因此在模块E的pom中,我有:
<parent>
<artifactId>A</artifactId>
</parent>
<artifactId>E</artifactId>
<name>E</name>
<packaging>pom</packaging>
<dependencies>
<dependency>
<groupId>group</groupId>
<artifactId>C</artifactId>
</dependency>
<dependency>
<groupId>group</groupId>
<artifactId>D</artifactId>
</dependency>
<dependency>
<groupId>group</groupId>
<artifactId>B</artifactId>
</dependency>
</dependencies>
A.
E
E
聚甲醛
组
C
组
D
组
B
org.apache.maven.plugins
maven汇编插件
主类
真的
带有依赖项的jar
包裹
单一的
当我运行mvn包时;它创建了B.jar、C.jar、D.jar和E-jar-with-dependencies.jar。
我只想创建最后一个jar,因为B、C和D在E-jar-with-dependencies.jar中
可能吗?我不确定这是否有帮助,但是 创建B、C和D是正常的,因为E需要它们。 如果在根文件夹中运行
mvn包
,maven将构建所有模块,这是预期的
但是,如果您只需要E,您可以在E的目录中运行
mvn包
。不过,这将使用上一次构建的B、C和D依赖项(安装在存储库中),而无需重新编译它们。我需要构建它们,但我只想将它们添加到E上。我不再需要B.jar、C.jar和D.jar。
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>Mainclass</mainClass>
<addClasspath>true</addClasspath>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>