Created
March 10, 2011 18:37
-
-
Save f440/864611 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -r 2c2961c1252f src/main/java/org/apache/maven/plugin/BuildNumberMojo.java | |
--- a/src/main/java/org/apache/maven/plugin/BuildNumberMojo.java Sun Oct 31 15:19:32 2010 +0100 | |
+++ b/src/main/java/org/apache/maven/plugin/BuildNumberMojo.java Fri Mar 11 03:22:29 2011 +0900 | |
@@ -20,19 +20,24 @@ | |
private MavenProject mavenProject; | |
public void execute() throws MojoExecutionException { | |
- String buildNumber = "unavailable"; | |
String[] hgLogCommand = new String[] { | |
- "hg", "log", "-l", "1", "--template", "{node}" }; | |
+ "hg", "log", "-l", "1", "--template", "{rev}\1{node}\1{branches}" }; | |
+ String buildInfo = ""; | |
+ String[] buildInfoList = new String[3]; | |
try { | |
Process child = Runtime.getRuntime().exec( hgLogCommand ); | |
- buildNumber = IOUtils.toString( child.getInputStream() ); | |
- getLog().debug( "set buildNumber to " + buildNumber ); | |
+ buildInfo = IOUtils.toString( child.getInputStream() ); | |
+ buildInfoList= buildInfo.split(Character.toString('\1')); | |
+ getLog().debug( "set buildInfo to " + buildInfo ); | |
} catch( IOException e ) { | |
- getLog().warn( "buildNumber set to '" + buildNumber + | |
+ getLog().warn( "buildInfo set to '" + buildInfo + | |
"', can't execute hg log command.", e ); | |
+ buildInfoList = new String[] {"unknown", "unkown", "unknown"}; | |
} | |
- mavenProject.getProperties().put( "buildNumber", buildNumber ); | |
+ mavenProject.getProperties().put( "rev", buildInfoList[0] ); | |
+ mavenProject.getProperties().put( "node", buildInfoList[1] ); | |
+ mavenProject.getProperties().put( "branches", buildInfoList[2] ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment