Reputation: 12786
I want a project's version number to be as the follow format for the normal release versioning:
<version>1.0-SNAPSHOT</version>
<version>1.0.1-SNAPSHOT</version>
......
On the other hand, I want to have a built artifact for every change merged like below:
<version>1.0-SNAPSHOT-${timestamp}</version>
Can I achieve this by using maven profile? something like:
<profiles>
<profile>
<id>normal</id>
<version>1.0-SNAPSHOT<version>
</proifle>
<profile>
<id>build</id>
<version>1.0-SNAPSHOT-${timestamp}<version>
</proifle>
</profiles>
so that I can build it like :
mvn package -P normal // this gives me artifact-1.0-SNAPSHOT.jar
or
mvn package -P build // this gives me artifact-1.0-SNAPSHOT-${timestamp}.jar
if profile can solve this problem, what are the other approaches?
Upvotes: 5
Views: 7019
Reputation: 18405
Use the Builder Number Plugin and/or evaluate the built-in timestamp property. Anyway, your approach is not recommended because a SNAPSHOT has always to be up to date.
Upvotes: 3
Reputation: 21831
Though I wouldn't recommend this approach, you can use profiles for this task. Here's how it can be done:
<version>${projectVersion}</version>
...
<profiles>
<profile>
<id>normal</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<projectVersion>1.0-SNAPSHOT</projectVersion>
</properties>
</profile>
<profile>
<id>build</id>
<properties>
<projectVersion>1.0-SNAPSHOT-${timestamp}</projectVersion>
</properties>
</profile>
</profiles>
Upvotes: 10