Generate Build.java file with data from the build.

Currently includes build version and time, but additional build-time static
data can be easily added in the future.
This commit is contained in:
Michael Bayne
2018-09-10 14:11:40 -07:00
parent b0d2c75cee
commit 712b06f8fb
4 changed files with 71 additions and 0 deletions
+45
View File
@@ -56,6 +56,51 @@
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>gen-build</id>
<phase>generate-sources</phase>
<configuration>
<target>
<tstamp>
<format property="build_time" pattern="yyyy-MM-dd HH:mm"/>
</tstamp>
<copy file="${project.build.sourceDirectory}/com/threerings/getdown/data/Build.java.tmpl"
tofile="${project.build.sourceDirectory}/com/threerings/getdown/data/Build.java"
overwrite="true">
<filterset>
<filter token="build_time" value="${build_time}"/>
<filter token="build_version" value="${project.version}"/>
</filterset>
</copy>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<filesets>
<fileset>
<directory>${project.build.sourceDirectory}/</directory>
<includes>
<include>com/threerings/getdown/data/Build.java</include>
</includes>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
@@ -0,0 +1,22 @@
//
// Getdown - application installer, patcher and launcher
// Copyright (C) 2004-2016 Getdown authors
// https://github.com/threerings/getdown/blob/master/LICENSE
package com.threerings.getdown.data;
/**
* Contains static data provided during the build process.
*/
public class Build {
/** The date and time at which the code was built: in {@code yyyy-MM-dd HH:mm} format. */
public static String time () {
return "@build_time@";
}
/** The Maven version of the Getdown project. */
public static String version () {
return "@build_version@";
}
}