Java – maven buildnumber plugin SVN revision is available only when format is not used

When using maven buildnumber plugin 1.0 beta 4, it seems that I can get SVN revisions unless I use the < Format > tag in the configuration Once I use the < Format > and < item > buildnumber < / item > tags, I get an automatically incremented number, but it no longer corresponds to the SVN revision. I don't know how to get it Is there any way to use < format & gt;???? The document is not very clear

Solution

Build number Maven plugin is very weird, which may be why it is still a beta This format is only applicable to projects where you want to apply the Java message format, and in most cases, it is only useful for timestamps and text strings If you do not need a timestamp, do not use the format option when obtaining the subversion version number If you use format, as you pointed out, it will give you a build number that is always incremented by one instead of the SCM version number

If you really need a timestamp, or export other projects from the buildnumber plug-in and the subversion version, perform it as a separate operation The following is an example of using two independent execution plug-ins to obtain the subverson revision number and build timestamp:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>buildnumber-maven-plugin</artifactId>
    <version>1.0-beta-4</version>
    <executions>
        <execution>
            <id>generate-buildnumber</id>
                <phase>validate</phase>
            <goals>
                <goal>create</goal>
            </goals>
            <configuration>
                <useLastCommittedRevision>true</useLastCommittedRevision>
                <buildNumberPropertyName>buildrevision</buildNumberPropertyName>
            </configuration>
        </execution>
        <execution>
            <id>generate-timestamp</id>
            <phase>validate</phase>
            <goals>
                <goal>create</goal>
            </goals>
            <configuration>
                <format>{0,date,yyyy-MM-dd HH:mm:ss}</format>
                <items>
                    <item>timestamp</item>
                </items>
                <buildNumberPropertyName>buildDateTime</buildNumberPropertyName>
            </configuration>
        </execution>
    </executions>
</plugin>

The key to doing this is to use the buildnumberpropertyname element For more information about the usefulness of the Java message format, see the usage page of the plug - in

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>