diff --git a/examples/java/example.mustache b/examples/java/example.mustache new file mode 100644 index 0000000..a44fd5d --- /dev/null +++ b/examples/java/example.mustache @@ -0,0 +1,33 @@ +/* + * This file is automatically generated. + * Do not modify! -- ALL CHANGES WILL BE ERASED! + */ +package {{packageName}}; + +import java.util.Date; + +public final class {{className}} { + public final static String PROJECT = "{{project}}"; + public final static Date BUILDDATE = new Date({{epoch}}L); + public final static int MAJOR = {{major}}; + public final static int MINOR = {{minor}}; + public final static int PATCH = {{patch}}; + public final static String PRERELEASE = "{{preRelease}}"; + public final static String BUILDMETA = "{{buildMeta}}"; + + /** + * The full semantic version string. + */ + public final static String VERSION = Integer.toString(MAJOR) + '.' + + Integer.toString(MINOR) + '.' + + Integer.toString(PATCH) + + ((!PRERELEASE.isEmpty()) ? "-" + PRERELEASE : "") + + ((!BUILDMETA.isEmpty()) ? "+" + BUILDMETA : ""); + + /** + * Disables the default constructor. + */ + private {{className}}() { + throw new UnsupportedOperationException("Illegal constructor call."); + } +} diff --git a/examples/kotlin/example.mustache b/examples/kotlin/example.mustache new file mode 100644 index 0000000..1d3a14a --- /dev/null +++ b/examples/kotlin/example.mustache @@ -0,0 +1,36 @@ +/* + * This file is automatically generated. + * Do not modify! -- ALL CHANGES WILL BE ERASED! + */ +package {{packageName}} + +import java.util.Date + +/** + * Provides semantic version information. + * + * @author Semantic Version Annotation Processor + */ +object {{className}} { + @JvmField + val PROJECT = "{{project}}" + @JvmField + val BUILDDATE = Date({{epoch}}L) + @JvmField + val MAJOR = {{major}} + @JvmField + val MINOR = {{minor}} + @JvmField + val PATCH = {{patch}} + @JvmField + val PRERELEASE = "{{preRelease}}" + @JvmField + val BUILDMETA = "{{buildMeta}}" + + /** + * The full semantic version string. + */ + @JvmField + val VERSION = ("$MAJOR.$MINOR.$PATCH" + if (PRERELEASE.isNotEmpty()) "-$PRERELEASE" else "" + + if (BUILDMETA.isNotEmpty()) "+$BUILDMETA" else "") +} diff --git a/src/main/resources/semver.mustache b/src/main/resources/semver.mustache index 48b9a87..20c08ce 100644 --- a/src/main/resources/semver.mustache +++ b/src/main/resources/semver.mustache @@ -27,15 +27,12 @@ public final class {{className}} { * The full semantic version string. */ public final static String VERSION = Integer.toString(MAJOR) + SEPARATOR + Integer.toString(MINOR) + SEPARATOR - + Integer.toString(PATCH) + preReleaseWithPrefix() + buildMetaWithPrefix(); + + Integer.toString(PATCH) + preReleaseWithPrefix() + buildMetaWithPrefix(); /** * Disables the default constructor. - * - * @throws UnsupportedOperationException If the constructor is called. */ - private {{className}}() - throws UnsupportedOperationException { + private {{className}}() { throw new UnsupportedOperationException("Illegal constructor call."); }