April 15, 2015

Maven Build-Number Auto Increment

I have been facing issues regarding Build Number Auto Increment.

I have found a solutions:

Maven Build Number Plugin

1. Define fake <scm> in the Root pom.xml


<scm>
    <connection>scm:svn:http://none</connection>
    <developerConnection>scm:svn:https://none</developerConnection>
    <url>scm:svn:https://none</url>
</scm>

2. Add buildnumber-maven-plugin to each maven module project pom.xml file


<build>
...
    <plugins>
    ...
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>buildnumber-maven-plugin</artifactId>
            <version>1.3</version>
            <executions>
                <execution>
                    <phase>validate</phase>
                    <goals>
                        <goal>create</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <format>{0}</format>
                <items>
                    <item>buildNumber</item>
                </items>
                <!-- doCheck and doUpdate actually talk to repository if it's true, Check would check that there are no local changes. Update would update it -->
                <docheck>false</docheck>
                <doupdate>false</doupdate>
            </configuration>
        </plugin>
    </plugins>
</build>

3. Build application several time and Run:

$ mvn install

Download the example from here

No comments: