Search code examples
svnmaventimestamprevisionbuildnumber-maven-plugin

SVN revision number and timestamp


I'm trying to display the latest SVN revision number and timestamp on the title bar of a web application. My current code displays the revision number but not timestamp. Both are not coming together. I'm using the following code.

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>buildnumber-maven-plugin</artifactId>
  <version>1.2</version>
  <executions>

    <execution>
      <phase>validate</phase>
      <goals>
        <goal>create</goal>
      </goals>
      <configuration>
        <useLastCommittedRevision>true</useLastCommittedRevision>
      </configuration>
    </execution>

    <execution>
      <id>generate-timestamp</id>
      <phase>validate</phase>
      <goals>
        <goal>create</goal>
      </goals>
    </execution>

  </executions>
</plugin>

It displays the revision number only. From the jsp I'm accessing the value like this

${initParam['build']}

Then it shows the revision. What is the modification required to display revision and timestamp. And how can I access the timestamp value?


Solution

  • I'm using like this now:

    <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>buildnumber-maven-plugin</artifactId>
    <version>1.2</version>
    <executions>
        <execution>
            <phase>validate</phase>
            <goals>
                <goal>create</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <format>{0} - {1,date,yyyy-MM-dd HH:mm:ss}</format>
        <items>
            <item>scmVersion</item>
            <item>timestamp</item>
        </items>
    </configuration>
    

    And access the value from jsp like this:

    ${initParam['build']}
    

    This shows the SVN revision number first and then the timestamp.