您可以把常用的部件庫中的項目和使用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