Getting the following exception while using maven build number plugin. Is it possible to disable SCM check while using the build number plugin? Can we use this plugin to gen
I had the case, that I wanted a GIT commitId and a timestamp to be put into properties, both at the same time. Can this be done as well?
Of course:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.4</version>
<inherited>false</inherited>
<executions>
<execution>
<id>commitId</id>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
<configuration>
<buildNumberPropertyName>commitId</buildNumberPropertyName>
<shortRevisionLength>7</shortRevisionLength>
</configuration>
</execution>
<execution>
<id>buildTimestamp</id>
<phase>validate</phase>
<goals>
<goal>create-timestamp</goal>
</goals>
<configuration>
<timestampPropertyName>buildTimestamp</timestampPropertyName>
</configuration>
</execution>
</executions>
</plugin>
This work file for me. Might help with just version number and no need of scm.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.4</version>
<configuration>
<revisionOnScmFailure>no.scm.config.in.pom
</revisionOnScmFailure>
</configuration>
<executions>
<execution>
<id>buildnumber</id>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
<configuration>
<format>{0,number}</format>
<items>
<item>buildNumber</item>
</items>
<doCheck>false</doCheck>
<doUpdate>false</doUpdate>
<revisionOnScmFailure>unknownbuild</revisionOnScmFailure>
</configuration>
</execution>
</executions>
</plugin>
The following used to work, if I'm not mistaken:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.0-beta-3</version>
<configuration>
<buildNumberPropertyName>buildNumber.value</buildNumberPropertyName>
<timestampPropertyName>buildNumber.timestamp</timestampPropertyName>
<format>{0,date,yyyyMMdd-HHmm}</format>
<items>
<item>timestamp</item>
</items>
</configuration>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
All you need to do is to enclose your plugins within pluginManagement tag
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
<configuration>
<doCheck>true</doCheck>
<doUpdate>true</doUpdate>
</configuration>
</plugin>
</plugins>
</pluginManagement>
Define a dummy SCM and then use buildNumber item to get sequential build number instead of value defined by revisionOnScmFailure property.
pom.xml:
<project ...>
<scm>
<connection>scm:svn:http://127.0.0.1/dummy</connection>
<developerConnection>scm:svn:https://127.0.0.1/dummy</developerConnection>
<tag>HEAD</tag>
<url>http://127.0.0.1/dummy</url>
</scm>
<build>
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>buildnumber</id>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
<configuration>
<format>{0,number}</format>
<items>
<item>buildNumber</item>
</items>
<doCheck>false</doCheck>
<doUpdate>false</doUpdate>
<revisionOnScmFailure>unknownbuild</revisionOnScmFailure>
</configuration>
</plugin>
</plugins>
</build>
</project>
With version 1.4 the following works:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.4</version>
<configuration>
<revisionOnScmFailure>no.scm.config.in.pom</revisionOnScmFailure>
</configuration>
<executions>
<execution>
<id>create-timestamp-id</id>
<phase>validate</phase>
<goals>
<goal>create-timestamp</goal>
</goals>
<configuration>
<timestampFormat>yyyy-MM-dd HH:mm:ss.S</timestampFormat>
<timestampPropertyName>myBuildNumberVariable</timestampPropertyName>
<!-- formats the timestamp all together like 2016-04-04 14:17:05.123 and puts
it in the ${myBuildNumberVariable} buildProperty -->
</configuration>
</execution>
</executions>
</plugin>