Skip to content

Instantly share code, notes, and snippets.

@chimerast
Created January 24, 2017 14:01
Show Gist options
  • Save chimerast/975b26f36d3125db012e3462d5d8bd75 to your computer and use it in GitHub Desktop.
Save chimerast/975b26f36d3125db012e3462d5d8bd75 to your computer and use it in GitHub Desktop.
buildnumber-maven-plugin with hg branch
Index: pom.xml
===================================================================
--- pom.xml (revision 19341)
+++ pom.xml (working copy)
@@ -13,7 +13,7 @@
<artifactId>buildnumber-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>
<name>Build Number Maven Plugin</name>
- <version>1.2</version>
+ <version>1.2.1</version>
<inceptionYear>2007</inceptionYear>
@@ -400,5 +400,19 @@
</snapshots>
</repository>
</repositories-->
+ <distributionManagement>
+ <repository>
+ <uniqueVersion>false</uniqueVersion>
+ <id>karatachi-repository</id>
+ <name>Karatachi Project Repository</name>
+ <url>dav:https://repo.karatachi.org/mvn</url>
+ </repository>
+ <snapshotRepository>
+ <uniqueVersion>false</uniqueVersion>
+ <id>karatachi-repository</id>
+ <name>Karatachi Project Repository</name>
+ <url>dav:https://repo.karatachi.org/mvn</url>
+ </snapshotRepository>
+ </distributionManagement>
</project>
Index: src/main/java/org/codehaus/mojo/build/HgChangeSetMojo.java
===================================================================
--- src/main/java/org/codehaus/mojo/build/HgChangeSetMojo.java (revision 19341)
+++ src/main/java/org/codehaus/mojo/build/HgChangeSetMojo.java (working copy)
@@ -83,14 +83,18 @@
{
String previousChangeSet = getChangeSetProperty();
String previousChangeSetDate = getChangeSetDateProperty();
- if ( previousChangeSet == null || previousChangeSetDate == null )
+ String previousBranch = getBranchProperty();
+ if ( previousChangeSet == null || previousChangeSetDate == null || previousBranch == null )
{
String changeSet = getChangeSet();
String changeSetDate = getChangeSetDate();
+ String branch = getBranch();
getLog().info( "Setting Mercurial Changeset: " + changeSet );
getLog().info( "Setting Mercurial Changeset Date: " + changeSetDate );
+ getLog().info( "Setting Mercurial Branch: " + branch );
setChangeSetProperty( changeSet );
setChangeSetDateProperty( changeSetDate );
+ setBranchProperty( branch );
}
}
catch ( ScmException e )
@@ -108,6 +112,15 @@
return consumer.getOutput();
}
+ protected String getBranch()
+ throws ScmException, MojoExecutionException
+ {
+ HgOutputConsumer consumer = new HgOutputConsumer( logger );
+ ScmResult result = HgUtils.execute( consumer, logger, scmDirectory, new String[] { "id", "-b" } );
+ checkResult( result );
+ return consumer.getOutput();
+ }
+
protected String getChangeSetDate()
throws ScmException, MojoExecutionException
{
@@ -129,6 +142,11 @@
return getProperty( "changeSet" );
}
+ protected String getBranchProperty()
+ {
+ return getProperty( "branch" );
+ }
+
protected String getProperty( String property )
{
return project.getProperties().getProperty( property );
@@ -144,6 +162,11 @@
setProperty( "changeSet", changeSet );
}
+ private void setBranchProperty( String branch )
+ {
+ setProperty( "branch", branch );
+ }
+
private void setProperty( String property, String value )
{
if ( value != null )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment