It depends on what you use to build the war.
If you use directly the jar command, you should probably create a script that writes the date in the application.properties file and launches the war creation.
If you use ant you can do this in two steps:
- Create a class like this one:
package tests;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Date;
import java.util.Properties;
public class GeneratePropertiesFile {
public static void main(String[] args) throws IOException {
Properties properties = new Properties();
properties.setProperty("build.date", new Date().toString());
properties.store(new FileOutputStream(stagingDir + "/WEB-INF/classes/application.properties"), "");
}
}
- Write an ant build file like this:
<project name="sample" basedir="." default="buildWar">
<target name="buildProperties">
<java fork="true" failonerror="yes" classname="tests.GeneratePropertiesFile"/>
</target>
<target name="buildWar" depends="buildProperties">
<war destfile="myapp.war" webxml="src/metadata/myapp.xml">
<fileset dir="src/html/myapp"/>
<fileset dir="src/jsp/myapp"/>
<lib dir="thirdparty/libs">
<exclude name="jdbc1.jar"/>
</lib>
<classes dir="build/main"/>
</war>
</target>
</project>