maven ear - 带版本号的 boundleFileName
maven ear - boundleFileName with version number
我有以下 java/maven 模块结构:
myapp
|-application <- this is an ear assembler module
|-commons
|-restapi
我想要 assemble 一个耳朵,其中包含重命名的工件以及绑定工件的正确版本号。
myapp-1.0.ear
|-myapp-commons-1.1.jar
|-myapp-restapi-1.2.war
我知道工件的名称与 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(耳机模块):
<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 属性,则 ear 中的 war 文件的名称将是 restapi-1.2.war 而不是 myapp-restapi-1.2.war。
你能帮帮我吗?
可能的解决方案:
在主 pom 文件中定义一个 myapp.version 属性 并在需要此信息的任何地方使用此变量。例如,您可以在 <version>
标签之间和 <build>
<finalName>
标签之间使用它。
我有以下 java/maven 模块结构:
myapp
|-application <- this is an ear assembler module
|-commons
|-restapi
我想要 assemble 一个耳朵,其中包含重命名的工件以及绑定工件的正确版本号。
myapp-1.0.ear
|-myapp-commons-1.1.jar
|-myapp-restapi-1.2.war
我知道工件的名称与 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(耳机模块):
<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 属性,则 ear 中的 war 文件的名称将是 restapi-1.2.war 而不是 myapp-restapi-1.2.war。
你能帮帮我吗?
可能的解决方案:
在主 pom 文件中定义一个 myapp.version 属性 并在需要此信息的任何地方使用此变量。例如,您可以在 <version>
标签之间和 <build>
<finalName>
标签之间使用它。