2

How to implement auto-incrementing build number in maven project?

Current version of my project is 0.9 and I'd like this from 0.9.1 to 0.9.2 and so on every build.

I've been searching for this but I couldn't get anything to work.

I've tried this question,also tried maven build number plugin and I've tried this blog, but nothing seems to work.

I tried the maven version plugin but it changes the jar name to app-0.9.[commit_hashcode].jar but I don't want this.

I want the jar name to be app-0.9.jar and I want to access the build number from a properties file or something.

Community
  • 1
  • 1
bazi
  • 1,758
  • 5
  • 27
  • 41

1 Answers1

0

The build number plugin you referenced does support incremental numeric versions based on a properties file (in addition to versions based on SCM and timestamp). The default is to use SCM hash so you have to tell it to use an incremental number.

<configuration>
    <format>{0,number,integer}</format>
    <items>
        <item>buildNumber</item>
    </items>
</configuration>
Samuel Neff
  • 73,278
  • 17
  • 138
  • 182