Skip to content

Instantly share code, notes, and snippets.

@alexschwartz
Created November 16, 2010 23:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexschwartz/702706 to your computer and use it in GitHub Desktop.
Save alexschwartz/702706 to your computer and use it in GitHub Desktop.
Using a smart build number (Maven2 pom.xml)
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<version>${smartBuildNumber}</version>
....
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.0-beta-5-git</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
<configuration>
<doCheck>false</doCheck>
<doUpdate>false</doUpdate>
<getRevisionOnlyOnce>true</getRevisionOnlyOnce>
<revisionOnScmFailure>UNKOWN</revisionOnScmFailure>
<!-- for SVN -->
<useLastCommittedRevision>true</useLastCommittedRevision>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.groovy.maven</groupId>
<artifactId>gmaven-plugin</artifactId>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>
println "smart build number: ${buildNumber}, ${scmBranch}"
def scmBranchSave = project.properties.getProperty('scmBranch').replaceAll('/','')
project.properties.setProperty('smartBuildNumber', "$scmBranchSave-${buildNumber}")
//println "properties: ${project.properties}"
</source>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
@alexschwartz
Copy link
Author

One drawback:

  • the maven install and deploy steps are using a path containing "${smartBuildNumber}", that is, they are using the value without any property replacement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment