From 585e4d1df7cafa12220248d50e581bdcc525c801 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Sat, 15 Apr 2017 09:49:36 -0700 Subject: [PATCH] Turned into an object for easier Java access. --- src/main/resources/semver-kt.mustache | 60 ++++++++++++++++----------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/src/main/resources/semver-kt.mustache b/src/main/resources/semver-kt.mustache index ed26be3..e46f7ef 100644 --- a/src/main/resources/semver-kt.mustache +++ b/src/main/resources/semver-kt.mustache @@ -12,35 +12,47 @@ import java.util.* * @author Semantic Version * Annotation Processor */ -open class {{className}} -private constructor() { - companion object { - val project = "{{project}}" +object {{className}} { + @JvmField + val project = "{{project}}" - val buildDate = Date({{epoch}}L) - val major = {{major}} - val minor = {{minor}} - val patch = {{patch}} - val buildMeta = "{{buildMeta}}" - val preRelease = "{{preRelease}}" + @JvmField + val buildDate = Date({{epoch}}L) - val version: String - get() = ("$major.$minor.$patch" + preReleaseWithPrefix() + buildMetaWithPrefix()) + @JvmField + val major = {{major}} - fun preReleaseWithPrefix(prefix: String = "-"): String { - return if (preRelease.isNotEmpty() && prefix.isNotEmpty()) { - "$prefix$preRelease" - } else { - preRelease - } + @JvmField + val minor = {{minor}} + + @JvmField + val patch = {{patch}} + + @JvmField + val buildMeta = "{{buildMeta}}" + + @JvmField + val preRelease = "{{preRelease}}" + + @JvmStatic + val version: String + get() = ("$major.$minor.$patch" + preReleaseWithPrefix() + buildMetaWithPrefix()) + + @JvmStatic + 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 - } + @JvmStatic + fun buildMetaWithPrefix(prefix: String = "+"): String { + return if (buildMeta.isNotEmpty() && prefix.isNotEmpty()) { + "$prefix$buildMeta" + } else { + buildMeta } } } \ No newline at end of file