Turned into an object for easier Java access.
This commit is contained in:
parent
5efb2a9e1d
commit
585e4d1df7
1 changed files with 36 additions and 24 deletions
|
@ -12,21 +12,33 @@ import java.util.*
|
||||||
* @author <a href="https://github.com/ethauvin/semver">Semantic Version
|
* @author <a href="https://github.com/ethauvin/semver">Semantic Version
|
||||||
* Annotation Processor</a>
|
* Annotation Processor</a>
|
||||||
*/
|
*/
|
||||||
open class {{className}}
|
object {{className}} {
|
||||||
private constructor() {
|
@JvmField
|
||||||
companion object {
|
|
||||||
val project = "{{project}}"
|
val project = "{{project}}"
|
||||||
|
|
||||||
|
@JvmField
|
||||||
val buildDate = Date({{epoch}}L)
|
val buildDate = Date({{epoch}}L)
|
||||||
|
|
||||||
|
@JvmField
|
||||||
val major = {{major}}
|
val major = {{major}}
|
||||||
|
|
||||||
|
@JvmField
|
||||||
val minor = {{minor}}
|
val minor = {{minor}}
|
||||||
|
|
||||||
|
@JvmField
|
||||||
val patch = {{patch}}
|
val patch = {{patch}}
|
||||||
|
|
||||||
|
@JvmField
|
||||||
val buildMeta = "{{buildMeta}}"
|
val buildMeta = "{{buildMeta}}"
|
||||||
|
|
||||||
|
@JvmField
|
||||||
val preRelease = "{{preRelease}}"
|
val preRelease = "{{preRelease}}"
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
val version: String
|
val version: String
|
||||||
get() = ("$major.$minor.$patch" + preReleaseWithPrefix() + buildMetaWithPrefix())
|
get() = ("$major.$minor.$patch" + preReleaseWithPrefix() + buildMetaWithPrefix())
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
fun preReleaseWithPrefix(prefix: String = "-"): String {
|
fun preReleaseWithPrefix(prefix: String = "-"): String {
|
||||||
return if (preRelease.isNotEmpty() && prefix.isNotEmpty()) {
|
return if (preRelease.isNotEmpty() && prefix.isNotEmpty()) {
|
||||||
"$prefix$preRelease"
|
"$prefix$preRelease"
|
||||||
|
@ -35,6 +47,7 @@ private constructor() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
fun buildMetaWithPrefix(prefix: String = "+"): String {
|
fun buildMetaWithPrefix(prefix: String = "+"): String {
|
||||||
return if (buildMeta.isNotEmpty() && prefix.isNotEmpty()) {
|
return if (buildMeta.isNotEmpty() && prefix.isNotEmpty()) {
|
||||||
"$prefix$buildMeta"
|
"$prefix$buildMeta"
|
||||||
|
@ -43,4 +56,3 @@ private constructor() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue