【发布时间】:2012-10-02 23:13:00
【问题描述】:
我有一个带有父模块和两个子模块的 Maven 项目:Service 和 API。 Service 模块是一个 WAR,包含项目的所有源文件,而 API 模块的存在纯粹是为了构建一个包含来自 Service 模块的类子集的 jar,并将该 jar 部署到本地 maven回购。
我尝试了 maven-dependency-plugin 和 maven-assembly-plugin 的组合来复制 Service 战争并将其包含在已部署的 API JAR 中,但我正在努力寻找一种方法来加入只是来自 Service 模块的一组特定类,而不是在整个胖 WAR 中。
来自API的pom.xml:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<excludeGroupIds>...</excludeGroupIds>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
<configuration>
<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>
</configuration>
</plugin>
</plugins>
我曾考虑使用来自Service 模块的pom 的maven-jar-plugin 构建苗条JAR,但这似乎是一种不好的做法。有什么建议吗?
【问题讨论】:
标签: java maven jar dependencies war