Added support for mustache instead of Velocity.

This commit is contained in:
Erik C. Thauvin 2017-04-14 22:27:07 -07:00
parent 13dec4f063
commit 5efb2a9e1d
10 changed files with 199 additions and 133 deletions

View file

@ -0,0 +1,46 @@
/*
* This file is automatically generated.
* Do not modify! -- ALL CHANGES WILL BE ERASED!
*/
package {{packageName}}
import java.util.*
/**
* Provides semantic version information.
*
* @author <a href="https://github.com/ethauvin/semver">Semantic Version
* Annotation Processor</a>
*/
open class {{className}}
private constructor() {
companion object {
val project = "{{project}}"
val buildDate = Date({{epoch}}L)
val major = {{major}}
val minor = {{minor}}
val patch = {{patch}}
val buildMeta = "{{buildMeta}}"
val preRelease = "{{preRelease}}"
val version: String
get() = ("$major.$minor.$patch" + preReleaseWithPrefix() + buildMetaWithPrefix())
fun preReleaseWithPrefix(prefix: String = "-"): String {
return if (preRelease.isNotEmpty() && prefix.isNotEmpty()) {
"$prefix$preRelease"
} else {
preRelease
}
}
fun buildMetaWithPrefix(prefix: String = "+"): String {
return if (buildMeta.isNotEmpty() && prefix.isNotEmpty()) {
"$prefix$buildMeta"
} else {
buildMeta
}
}
}
}

View file

@ -1,23 +1,8 @@
##############################################################################
##
## Available variables:
##
## $packageName - The package name. (string)
## $className - The class name. (string)
## $project - The project name. (string)
## $epoch - The build epoch/unix time. (long)
## $major - The major version. (int)
## $minor - The minor version. (int)
## $patch - The patch version. (int)
## $prerelease - The pre-release version. (string)
## $buildmeta - The build metadata version. (string)
##
##############################################################################
/*
* This file is automatically generated.
* Do not modify! -- ALL CHANGES WILL BE ERASED!
*/
package ${packageName};
package {{packageName}};
import java.util.Date;
@ -27,25 +12,26 @@ import java.util.Date;
* @author <a href="https://github.com/ethauvin/semver">Semantic Version
* Annotation Processor</a>
*/
public final class ${className} {
public final class {{className}} {
private final static String DEFAULT_PRERELEASE_PREFIX = "-";
private final static string DEFAULT_BUILDMETA_PREFIX = "+";
private final static String buildmeta = "${buildmeta}";
private final static Date date = new Date(${epoch}L);
private final static int major = ${major};
private final static int minor = ${minor};
private final static int patch = ${patch};
private final static String prerelease = "${prerelease}";
private final static String project = "${project}";
private final static String project = "{{project}}";
private final static Date date = new Date({{epoch}}L);
private final static int major = {{major}};
private final static int minor = {{minor}};
private final static int patch = {{patch}};
private final static String preRelease = "{{preRelease}}";
private final static String buildMeta = "{{buildMeta}}";
/**
* Disables the default constructor.
*
* @throws UnsupportedOperationException If the constructor is called.
*/
private ${className}()
throws UnsupportedOperationException {
private {{className}}()
throws UnsupportedOperationException {
throw new UnsupportedOperationException("Illegal constructor call.");
}
@ -87,9 +73,9 @@ public final class ${className} {
*/
public static String getVersion() {
return Integer.toString(getMajor()) + '.'
+ Integer.toString(getMinor()) + '.'
+ Integer.toString(getPatch())
+ getPreReleaseWithPrefix + getBuildMetadataWithPrefix;
+ Integer.toString(getMinor()) + '.'
+ Integer.toString(getPatch())
+ getPreReleaseWithPrefix + getBuildMetaWithPrefix;
}
/**
@ -125,7 +111,7 @@ public final class ${className} {
* @return The pre-release version, if any
*/
public static int getPreRelease() {
return prerelease;
return preRelease;
}
/**
@ -133,8 +119,8 @@ public final class ${className} {
*
* @return The build metadata, if any.
*/
public static String getBuildMetadata() {
return buildmeta;
public static String getBuildMeta() {
return buildMeta;
}
/**
@ -149,14 +135,14 @@ public final class ${className} {
/**
* Returns the pre-release version.
*
* @param prefix The refix to prepend.
* @param prefix The prefix to prepend.
* @return The pre-release version, if any.
*/
public static String getPreReleaseWithPrefix(final String prefix) {
if (prerelease.length() > 0 && prefix.length() > 0) {
return prefix + prerelease;
if (preRelease.length() > 0 && prefix.length() > 0) {
return prefix + preRelease;
} else {
return prerelease;
return preRelease;
}
}
@ -166,8 +152,8 @@ public final class ${className} {
* @param prefix The prefix to prepend.
* @return The build metadata, if any.
*/
public static String getBuildMetadataWithPrefix() {
return getBuildMetadataWithPrefix(DEFAULT_PRERELEASE_PREFIX);
public static String getBuildMetaWithPrefix() {
return getBuildMetaWithPrefix(DEFAULT_PRERELEASE_PREFIX);
}
/**
@ -176,11 +162,11 @@ public final class ${className} {
* @param prefix Prefix to prepend.
* @return The build metadata, if any.
*/
public static String getBuildMetadataWithPrefix(final String prefix) {
if (buildmeta.length() > 0 && prefix.length() > 0) {
return prefix + buildmeta;
public static String getBuildMetaWithPrefix(final String prefix) {
if (buildMeta.length() > 0 && prefix.length() > 0) {
return prefix + buildMeta;
} else {
return buildmeta;
return buildMeta;
}
}
}

View file

@ -1,4 +0,0 @@
runtime.log.logsystem.class = org.apache.velocity.runtime.log.SystemLogChute
resource.loader = file, class
file.resource.loader.class = org.apache.velocity.runtime.resource.loader.FileResourceLoader
class.resource.loader.class = org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader