0

I am using the Wicket framework for an application I designed.. I am not too familiar with interacting with Maven as a lot of that was already done for me. Currently every time I build and deploy a new version of the application I manually change the date in the markup that reflects the latest version date.

What I want to be able to do is set some sort of maven property that will create a time stamp each time I build the code.

How would I go about doing this? So how would I set the maven code, and then how would I reference the property inside my markup or Java to be reflected in the markup?

Currently I see:

    <dependency>
        <groupId>org.apache.wicket</groupId>
        <artifactId>wicket-datetime</artifactId>
        <version>${wicket.version}</version>
    </dependency>

already in the pom.xml file, but not sure if that's what I would use or how would I access this in my java code.

Thanks!

Robert Niestroj
  • 15,299
  • 14
  • 76
  • 119
eaglei22
  • 2,589
  • 1
  • 38
  • 53
  • possible duplicate of http://stackoverflow.com/questions/802677/adding-the-current-date-with-maven2-filtering – Apostolos May 07 '14 at 19:47

1 Answers1

1

you can use buildnumber-maven-plugin for versioning. please check this link

It has detailed steps of how to store the build number in your MANIFEST file. Then you can access it via

String appServerHome = getServletContext().getRealPath("/");
File manifestFile = new File(appServerHome, "META-INF/MANIFEST.MF");

Manifest mf = new Manifest();
mf.read(new FileInputStream(manifestFile));
Attributes atts = mf.getMainAttributes();
System.out.println("Version: " + atts.getValue("Implementation-Version"));
System.out.println("Build: " + atts.getValue("Implementation-Build"));
Apostolos
  • 10,033
  • 5
  • 24
  • 39
  • Or you can use the `maven-war-plugin`: http://stackoverflow.com/a/11951076/534877 – Robert Niestroj May 08 '14 at 06:01
  • great! didn't know about that. no need for this extra plugin. thnx Robert. I'll introduce it to my web project too. – Apostolos May 08 '14 at 09:23
  • So in the link referenced: http://stackoverflow.com/questions/802677/adding-the-current-date-with-maven2-filtering it looks like there isn't anything written to the manifest. How would I access ${buildNumber} or one of the properties alternatives shown? – eaglei22 May 08 '14 at 22:58
  • Any ideas from anyone? – eaglei22 May 12 '14 at 13:29
  • check Robert's comment. i tried it and works fine. it writes the Build-Time entry in the manifest. try it yourself – Apostolos May 12 '14 at 17:30