Maven build number plugin, how to save the build number in a file?

后端 未结 4 619
灰色年华
灰色年华 2020-12-24 14:01

I\'ve a Java project using Spring Framework and Git and I wanted to display a build number. I found the Build Number Maven plugin. With Git the build number is a Git hash. I

相关标签:
4条回答
  • 2020-12-24 14:12

    I could not reproduce the problem reported by the OP. In my case both command line and m2eclipse work fine and the file is generated correctly in the target/classes folder. The answer provided by @KasunBG is incorrect. The buildNumber.properties is generated only if you use the following:

            <format>{0,number}</format>
            <items>
                <item>buildNumber</item>
            </items>
    

    buildNumber.properties is used to store a number which can be incremented. For this reason ( I think ) the plugin doesn't generate this file if you use timestamp/scmVersion etc.

    0 讨论(0)
  • 2020-12-24 14:22

    The documentation page says that the properties files is stored at ${basedir}/buildNumber.properties, which is created when the buildnumber:create phase is ran.

    0 讨论(0)
  • 2020-12-24 14:25

    Store it in a filtered properties file. See Using maven to output the version number to a text file

    0 讨论(0)
  • 2020-12-24 14:27

    You shouldn't set revisionOnScmFailure option to true, it doesn't expect a boolean. Set it to revision string you want to use when SCM is unavailable, like na or like that. It doesn't matter for your case since you override the build number format but it would be more correct.

    See buildnumber-maven-plugin docs.

    0 讨论(0)
提交回复
热议问题