5

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?

Duncan Jones
  • 67,400
  • 29
  • 193
  • 254
coder247
  • 2,913
  • 19
  • 50
  • 70
  • Why do you have 2 executions with the same goal? Also, do you have command line svn client installed? – Andrew Logvinov Jan 17 '13 at 09:33
  • This answer says that If I need both values, I should use 2 executions. http://stackoverflow.com/questions/4319248/maven-buildnumber-plugin-svn-revision-available-only-when-not-using-format. Yes I've command line svn client. – coder247 Jan 17 '13 at 09:56
  • I checked the link you referenced. Your configuration matches neither that of the accepted answer nor [this additional answer](http://stackoverflow.com/a/12887414/944849) showing two executions. If you add the missing elements (format, items, etc), does it work? – user944849 Jan 17 '13 at 17:09
  • Reading maven-buildnumber-plugin manual, I think it only gives the scm buildnumber and revision at maven scope, there must be some extra configuration you have in your code so that you can access it on jsp (eg: web.xml, properties file or such) – gerrytan Jan 17 '13 at 22:54
  • @user944849 I tried it like that initially, but it won't work. – coder247 Jan 18 '13 at 08:00
  • @gerrytan Do you have any idea how can we get the values in pom ? – coder247 Jan 18 '13 at 08:01

1 Answers1

1

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.

coder247
  • 2,913
  • 19
  • 50
  • 70