开发者

Token for Maven package name

I use maven/hudson to build my project. One of the goals run by hudson is mvn package so I have a full distribution produced on every build. Is there a way (maybe an argument to package?) that I can app开发者_运维知识库end the build number to the name of archive that's produced?

thanks,

Jeff


Try the following. It should only activate if the BUILD_NUMBER property is set, so you'll still generate correctly named builds when not using hudson.

<profiles>
    <profile>
        <id>hudson-build</id>
        <activation>
            <property>
                <name>BUILD_NUMBER</name>
            </property>
        </activation>
        <build>
            <finalName>${artifactId}-${version}-${BUILD_NUMBER}</finalName>
        </build>
    </profile>
</profiles>

I'd suggest putting this into a base pom.xml that can then be referenced as a parent to your other pom.xml configs.

For a list of other properties that hudson passes on to maven builds, see http://weblogs.java.net/blog/johnsmart/archive/2008/03/using_hudson_en.html.


You can pass an arbitrary property to a Maven build using -D[key]=[value], for example -DbuildNumber=1234 then configure the version in your pom as `1.0.0-${buildNumber}. This approach goes against the general Maven principle though. You'd be better to use Maven's SNAPSHOT processing. SNAPSHOT is a keyword to Maven to update the dependency each time.

You could also use the buildnumber-maven-plugin to automatically add a number to the build version each time. See this answer for some details. The buildnumber plugin can be set to produce a revision based on the SCM revision, a timestamp, or on a sequence.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜