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?
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>
                        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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With