java – maven-buildnumber-plugin svn修订版仅在不使用格式时可用

在使用maven-buildnumber-plugin 1.0 beta 4时,似乎我可以获得svn修订,除非我使用< format>标签在配置内.一旦我使用< format>和< item> buildnumber< / item>标签,我得到一个自动递增的数字,但它不再对应于svn修订,我不知道如何得到它.有没有办法使用< format&gt ;????文件不是很清楚.

解决方法

buildnumber-maven-plugin是非常古怪的,这可能是为什么它仍然是一个测试版.该格式仅适用于您希望应用 Java消息格式的项目,并且在大多数情况下,它仅对时间戳和文字字符串有用.如果您不需要时间戳,在获取Subversion版本号时不要使用format选项.如果您使用格式,那么就像您指出的那样,它会给你一个总是递增一个而不是SCM版本号的构建号.

如果您确实需要时间戳记,或者从buildnumber插件以及Subversion版本中导出其他项目,请将其作为单独的执行操作.以下是使用两个独立执行插件获取Subverison修订版本号和构建时间戳的示例:

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

进行此工作的关键是使用buildNumberPropertyName元素.有关Java消息格式的有用性的更多信息,请查看该插件Usage页面.

相关文章

应用场景 C端用户提交工单、工单创建完成之后、会发布一条工...
线程类,设置有一个公共资源 package cn.org.chris.concurre...
Java中的数字(带有0前缀和字符串)
在Java 9中使用JLink的目的是什么?
Java Stream API Filter(过滤器)
在Java中找到正数和负数数组元素的数量