[英]How to build maven project both Snapshot and Release build simultaneously
I have a requirement to build both Snapshot versions and Release build at a time. 我需要一次构建Snapshot版本和Release版本。
To build snapshot versions I did like this 要构建快照版本,我这样做是
<groupId>com.abc.xyz</groupId>
<artifactId>service</artifactId>
<version>1.0.3-SNAPSHOT</version>
<distributionManagement>
<snapshotRepository>
<id>mvn-git-repo</id>
<uniqueVersion>true</uniqueVersion>
<name>maven git repository</name>
<url>file:/home/mvn-github-repo/snapshot</url>
</snapshotRepository>
</distributionManagement>
To build release versions, 要构建发行版本,
<groupId>com.abc.xyz</groupId>
<artifactId>service</artifactId>
<version>1.0.3</version>
<distributionManagement>
<repository>
<id>mvn-git-repo</id>
<uniqueVersion>true</uniqueVersion>
<name>maven git repository</name>
<url>file:/home/mvn-github-repo/release</url>
</repository>
</distributionManagement>
Is it possible to make both together, so that it should generate snapshot version and as well release version jars at a time and deploy in respective repositories.If possible what is the version I should keep in pom ? 是否可以将两者组合在一起,以便它一次生成快照版本和发行版本jar并部署在各自的存储库中。如果可能,我应该在pom中保留什么版本?
You use profile to define the version and repo, like this 您可以使用配置文件来定义版本和存储库,如下所示
<version>${buildVersion}</version>
.
.
.
<profiles>
<profile>
<id>snapshot-repo</id>
<activation>
<property>
<name>snapshot</name>
<value>true</value>
</property>
</activation>
<properties>
<buildVersion>1.0.3-SNAPSHOT</buildVersion>
</properties>
<distributionManagement>
<repository>
</repository>
<snapshotRepository>
</snapshotRepository>
</distributionManagement>
</profile>
<profile>
<id>git-repo</id>
<activation>
<property>
<name>!snapshot</name>
</property>
</activation>
<properties>
<buildVersion>1.0.3</buildVersion>
</properties>
<distributionManagement>
<repository>
</repository>
<snapshotRepository>
</snapshotRepository>
</distributionManagement>
</profile>
Then build by with -Dsnapshot=true
然后使用-Dsnapshot=true
构建
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.