How to display SVN version in Maven usng the build-number plugin

元气小坏坏 提交于 2019-12-19 10:01:50

问题


How do display the svn version and the timestamp using build number plugin.

Currently I have the following

<plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>buildnumber-maven-plugin</artifactId>
            <configuration>
                <format>At {0,time} on {0,date} : SVN Revision {1,number}</format>
                <items>
                    <item>timestamp</item>
                    <item>buildNumber</item>
                </items>
                <doCheck>false</doCheck>
                <doUpdate>false</doUpdate>
            </configuration>
        </plugin>
    </plugins>

Which shows up as follows: At 8:02:51 AM on Feb 2, 2011 : SVN Revision 1

But my svn revision is 1123. if I comment out the <format> and <items> I get the correct svn build number. How do I display both?

Thanks


回答1:


As the documentation says, if you use the special <item> buildNumber, it does not use the SVN Revision, but instead creates/reads a special property file.

If you do want to use the SVN revision, you need to follow the configuration specified in the first exmaple in the usage page. The other examples are meant to illustrate usages which does not make use of SVN revision, but a local build number (as in case of continuous integration builds).




回答2:


Update to version 1.2 of buildnumber-maven-plugin and use scmVersion.

<items>
    <item>timestamp</item>
    <item>scmVersion</item>
</items>

Helped greatly by this SO response.




回答3:


I ended up using buildnumber-maven-plugin without format parameter to get svn revision, and date using:

<properties>
    <maven.build.timestamp.format>yyyy-MM-dd HH:mm:ss</maven.build.timestamp.format>
    <build.date>${maven.build.timestamp}</build.date>
</properties>

then, in filtered resource:

r${buildNumber}, ${build.date}



回答4:


Does this matter?

"The buildNumber plugin will then update your local repository. This is done because 'svn info' grabs the revision out of your local repository, and is not necessarily the same as the revision in the remote repository. You should probably deal with these changes before creating a build in any case. Again, this behaviour can be suppressed with -Dmaven.buildNumber.doUpdate=false."

http://mojo.codehaus.org/buildnumber-maven-plugin/usage.html



来源:https://stackoverflow.com/questions/4874813/how-to-display-svn-version-in-maven-usng-the-build-number-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!