How to display SVN version in Maven using build-number plugin

How to display svn version and timestamp using plugin with build number.

I currently 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>

It looks like this: At 8:02:51 AM on Feb 2, 2011 : SVN Revision 1

But my svn version is 1123. If I comment on <format>and <items>, I get the correct svn build number. How to display both?

thank

+3
source share
4 answers

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

SVN, , usage. , SVN, ( ).

+3

1.2 buildnumber-maven-plugin scmVersion.

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

SO.

+3

buildnumber-maven-plugin , svn-, date :

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

:

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

Does it matter?

“The buildNumber plugin will then update your local repository. This is because 'svn info' grabs the revision from your local repository and does not necessarily match the version in the remote repository. You should probably deal with these changes before creating the assembly anyway. Again, this behavior can be suppressed with -Dmaven.buildNumber.doUpdate = false. "

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

0
source

Source: https://habr.com/ru/post/1789493/


All Articles