Embed Mercurial working directory change identifier, e.g. (838cb9c0367e), in the properties file via Maven?

We use Maven for our builds and Mercurial for our change kits. Although our software already has a major version, we really would like to know that Mercurial changeet is used to create any server that runs our software.

Does anyone know of a way in Maven to grab a working set of changes in Mercurial and get it in a properties file or something like that so that we can display it somewhere in our application when system administrators perform a “health check” against which version is currently working?

+5
source share
4 answers

Combine this with yours pom.xml:

<project>
  <build>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
      </resource>
    </resources>

    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>buildnumber-maven-plugin</artifactId>
        <executions>
          <execution>
            <phase>validate</phase>
            <goals>
              <goal>hgchangeset</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

Then create a file .propertiesin src/main/resourcesa set of properties of both ${changeSet}. For instance:

revision = ${changeSet}
modificationTime = ${changeSetDate}
+5
source

You can do an update binding that outputs the identifier of the changeset to a file without converting .properties:

[hooks]
update = echo changesetid=$HG_PARENT1 > version.properties

The advantage of this approach is that you can easily adjust this value if necessary, and the assembly remains independent of the version control system (or its absence).

- Maven, , Buildnumber Maven (hgchangeset) Maven Mercurial Build Number Plugin?

+6

( , f.e) hg id -i . hg log --template "..." tip

0

Maven antrun <exec> <java>, . .

0

All Articles