eaglei22
eaglei22

Reputation: 2831

Display Date on page for specific build in Wicket

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!

Upvotes: 0

Views: 293

Answers (1)

Apostolos
Apostolos

Reputation: 10463

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"));

Upvotes: 1

Related Questions