Reworked default velocity template.

Improved example kobalt build.
This commit is contained in:
Erik C. Thauvin 2016-07-07 23:39:18 -07:00
parent b763de695c
commit 62fe418522
18 changed files with 389 additions and 268 deletions

View file

@ -13,15 +13,15 @@ import java.util.Date;
* Annotation Processor</a>
*/
public final class GeneratedVersion {
private final static String buildmeta = "";
private final static Date date = new Date(1467521680486L);
private final static int major = 3;
private final static int minor = 1;
private final static int patch = 39;
private final static String prerelease = "beta";
private final static String project = "Example";
private final static String buildmeta = "";
private final static Date date = new Date(1467959174599L);
private final static int major = 3;
private final static int minor = 1;
private final static int patch = 45;
private final static String prerelease = "beta";
private final static String project = "Example";
/**
/**
* Disables the default constructor.
*
* @throws UnsupportedOperationException If the constructor is called.
@ -71,7 +71,7 @@ public final class GeneratedVersion {
return Integer.toString(getMajor()) + '.'
+ Integer.toString(getMinor()) + '.'
+ Integer.toString(getPatch())
+ getPreRelease() + getBuildMetadata();
+ getPreRelease(true) + getBuildMetadata(true);
}
/**
@ -101,14 +101,46 @@ public final class GeneratedVersion {
return patch;
}
/**
* Returns the pre-release version.
*
* @param isHyphen Prepend a hyphen, if <code>true</code>.
* @return The pre-release version, if any.
*/
public static String getPreRelease(final boolean isHyphen) {
if (prerelease.length() > 0) {
if (isHyphen) {
return '-' + prerelease;
} else {
return prerelease;
}
}
return "";
}
/**
* Returns the pre-release version.
*
* @return The pre-release version, if any.
*/
public static String getPreRelease() {
if (prerelease.length() > 0) {
return '-' + prerelease;
return getPreRelease(false);
}
/**
* Returns the build metadata.
*
* @param isPlus Prepend a plus sign, if <code>true</code>.
* @return The build metadata, if any.
*/
public static String getBuildMetadata(final boolean isPlus) {
if (buildmeta.length() > 0) {
if (isPlus) {
return '+' + buildmeta;
} else {
return buildmeta;
}
}
return "";
@ -120,10 +152,6 @@ public final class GeneratedVersion {
* @return The build metadata, if any.
*/
public static String getBuildMetadata() {
if (buildmeta.length() > 0) {
return '+' + buildmeta;
}
return "";
return getBuildMetadata(false);
}
}

View file

@ -47,9 +47,19 @@ public class Example
{
public static void main(final String... args)
{
final SimpleDateFormat sdf = new SimpleDateFormat("'Built on' EEE, d MMM yyyy 'at' HH:mm:ss z");
final SimpleDateFormat sdf = new SimpleDateFormat("EEE, d MMM yyyy 'at' HH:mm:ss z");
System.out.println(GeneratedVersion.getProject() + ' ' + GeneratedVersion.getVersion());
System.out.println(sdf.format(GeneratedVersion.getBuildDate()));
System.out.println("-----------------------------------------------------");
System.out.println(" " + GeneratedVersion.getProject() + ' ' + GeneratedVersion.getVersion());
System.out.println(" Built on: " + sdf.format(GeneratedVersion.getBuildDate()));
System.out.println(" Major: " + GeneratedVersion.getMajor());
System.out.println(" Minor: " + GeneratedVersion.getMinor());
System.out.println(" Patch: " + GeneratedVersion.getPatch());
System.out.println(" PreRelease: " + GeneratedVersion.getPreRelease());
System.out.println(" BuildMetaData: " + GeneratedVersion.getBuildMetadata());
System.out.println("-----------------------------------------------------");
}
}