我有以下的Java/Maven的模塊結構:Maven的耳朵 - boundleFileName版本號爲
myapp
|-application <- this is an ear assembler module
|-commons
|-restapi
我想組裝包含與boundled文物的正確版本號重命名文物的耳朵。
myapp-1.0.ear
|-myapp-commons-1.1.jar
|-myapp-restapi-1.2.war
我知道artifacts的名稱與java模塊的名稱相似。因爲我不想在模塊名稱之前使用'myapp'前綴,所以我需要重命名工件的最終名稱,如:myapp- [modulename] - [modulversion] .jar | war。
我的問題是,如果我使用'bundleFileName'配置,那麼我不能手動添加版本號信息。
主POM:
<groupId>a.b.myapp</groupId>
<artifactId>myapp</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<modelVersion>4.0.0</modelVersion>
<modules>
<module>application</module>
<module>commons</module>
<module>restapi</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>a.b.myapp</groupId>
<artifactId>restapi</artifactId>
<version>1.2</version>
<type>war</type>
</dependency>
</dependencies>
</dependencyManagement>
application.pom(EAR模塊):
<parent>
<artifactId>myapp</artifactId>
<groupId>a.b.myapp</groupId>
<version>1.0</version>
</parent>
<artifactId>application</artifactId>
<version>1.0</version>
<packaging>ear</packaging>
<modelVersion>4.0.0</modelVersion>
<dependencies>
<dependency>
<groupId>a.b.myapp</groupId>
<artifactId>restapi</artifactId>
<type>war</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.10.1</version>
<configuration>
<finalName>${parent.artifactId}-${artifactId}-${version}</finalName> <-- MY-APPLICATION-1.0.EAR
<modules>
<webModule>
<groupId>com.remal.gombi</groupId>
<artifactId>restapi</artifactId>
<bundleFileName>${parent.groupId}-${artifactId}-${????}.war</bundleFileName> <- MYAPP-RESTAPI-???.WAR
</webModule>
</modules>
</configuration>
</plugin>
</plugins>
</build>
restapi.pom
<parent>
<artifactId>myapp</artifactId>
<groupId>a.b.myapp</groupId>
<version>1.0</version>
</parent>
<artifactId>restapi</artifactId>
<version>1.2</version>
<packaging>war</packaging>
<modelVersion>4.0.0</modelVersion>
我不能夠得到的版本信息bundleFileName標籤之間的'restapi'模塊。 如果不使用bundleFileName屬性,那麼耳朵內的war文件的名稱將是restapi-1.2.war而不是myapp-restapi-1.2.war。
你能幫我嗎?
看起來你正在使用多模塊構建,但你似乎在你的反應堆中有不同的版本。此外,在你的耳朵模塊,默認情況下是沒有意義的。特別是因爲你定義了一個依賴於戰爭模塊......它有一個不同的版本。所以在這種情況下,您需要硬編碼模塊名稱,否則您需要相應地更改artifactId。也許你可以向[Maven EAR插件](https://issues.apache.org/jira/browse/MEAR)發出功能請求。 – khmarbaise