我正在使用maven程序集插件构建一个带有依赖项的可执行的、单块的jar。我还使用资源筛选来设置一些自定义的、特定于车道的属性(开发、阶段、prod等)。
如何使jar的finalName包含车道名称(开发、舞台、prod等)?
我希望下面的mvn命令产生类似于这样的jars:
-> ws-client-DEV.jar
有什么我找不到的maven财产吗?如果可能的话,我想避免使用冗余命令行参数(例如- 'mvn干净安装-P DEV -Dlane=DEV')。
下面是我的组装插件配置:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2.2</version>
<executions>
<execution>
<id>jar-with-dependencies</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<finalName>ws-client</finalName>
<appendAssemblyId>false</appendAssemblyId>
<archive>
<manifest>
<mainClass>Example</mainClass>
</manifest>
</archive>
</configuration>
</plugin>发布于 2012-05-01 17:11:10
类似于Bhaskar,但稍作修改。
在标记后面,添加
<finalName>${project.artifactId}-${lane}</finalName>可以将泳道值设置为配置文件中的属性。
<profiles>
<profile>
<id>DEV</id>
<properties>
<lane>DEV</lane>
</properties>
</profile>
</profiles>然后按您所说的执行构建: mvn . -P DEV (例如mvn干净安装-P DEV)
发布于 2012-05-01 16:45:40
在标记后面,添加
<finalName>${project.artifactId}-${lane}</finalName>并将"lane“env变量设置为配置文件名。
-P、DEV、-Dlane=DEV等。
或者,您可以更有创造性地发现活动配置文件ID,如下面所描述的Maven - Can I reference profile id in profile definition?
编辑
如果你想避免多余的争论。
为什么不使用env触发相应的配置文件。属性。
等命令行
mvn -Dlane=DEV|STAGE|PROD在水壶里
<profile>
<id>DEV</id>
<activation>
<property>
<name>lane</name>
<value>DEV</value>
</property>
</activation>
<build>
// rest of the profile
</profile>舞台和产品轮廓也是一样的。
https://stackoverflow.com/questions/10400886
复制相似问题