您可以把常用的部件库中的项目和使用dependency:unpack或dependency:unpack-dependencies
如需要解压它们你的项目布局将是这样的:
root
|____ common-lib (jar, contains common java code)
|____ common-gui (jar, contains only non-java stuff like js, jsp, css etc)
|____ client1 (war)
|____ client2 (war)
客户端1和客户端2将各有一个普通compile
依赖于共同-lib下,但只有一个provided
依赖于通用的GUI(如果你使用dependency:unpack
它不必是项目依赖的话)
现在你会添加如下代码到客户端项目:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack-common-gui-elements</id>
<phase>prepare-package</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.yourcompany</groupId>
<artifactId>common-gui</artifactId>
<version>${project.version}</version>
<type>jar</type>
<!-- war assembly directory -->
<outputDirectory>
${project.build.directory}/${project.build.finalName}
</outputDirectory>
<includes>**/*.jsp,**/*.css,**/*.js</includes>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
这样,你可以重复使用您的组件,但你总是可以自己选择你发布的组件客户。
感谢您的回答!特别是Maven的依赖插件似乎很有用。我已经使用Maven WAR插件和它的覆盖图来介绍另一种解决方案。然后你可以添加对另一场战争的依赖,并重新使用那些部分(例如普通战争)。远程资源插件似乎主要用于许可证分发,但也可能完成这项工作。 – velaia 2010-09-22 07:46:04
您应该将这些注释添加到您所指的答案中或编辑您的原始问题。另外:StackOverflow版本的“感谢您的答案”是点击向上箭头,althogh口头表示感谢也感谢:-) – 2010-09-22 07:55:34