Added java example.
This commit is contained in:
parent
9b90987eb2
commit
3df73b7366
4 changed files with 38 additions and 11 deletions
|
@ -27,5 +27,9 @@ dependencies {
|
|||
compileOnly 'org.apache.velocity:velocity:1.7'
|
||||
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
|
||||
}
|
||||
|
||||
task(runJava, type: JavaExec) {
|
||||
main 'com.example.Example'
|
||||
classpath sourceSets.main.runtimeClasspath
|
||||
}
|
23
src/main/java/com/example/Example.java
Normal file
23
src/main/java/com/example/Example.java
Normal file
|
@ -0,0 +1,23 @@
|
|||
package com.example;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
public class Example {
|
||||
public static void main(final String... args) {
|
||||
final SimpleDateFormat sdf = new SimpleDateFormat("EEE, d MMM yyyy 'at' HH:mm:ss z");
|
||||
|
||||
System.out.println("-- From Java ----------------------------------------");
|
||||
|
||||
System.out.println(" " + GeneratedVersion.Companion.getProject() + ' '
|
||||
+ GeneratedVersion.Companion.getVersion());
|
||||
|
||||
System.out.println(" Built on: " + sdf.format(GeneratedVersion.Companion.getBuildDate()));
|
||||
System.out.println(" Major: " + GeneratedVersion.Companion.getMajor());
|
||||
System.out.println(" Minor: " + GeneratedVersion.Companion.getMinor());
|
||||
System.out.println(" Patch: " + GeneratedVersion.Companion.getPatch());
|
||||
System.out.println(" PreRelease: " + GeneratedVersion.Companion.getPreRelease());
|
||||
System.out.println(" BuildMetaData: " + GeneratedVersion.Companion.getBuildMeta());
|
||||
|
||||
System.out.println("-----------------------------------------------------");
|
||||
}
|
||||
}
|
|
@ -16,8 +16,8 @@ class Main {
|
|||
println(" Major: ${GeneratedVersion.major}")
|
||||
println(" Minor: ${GeneratedVersion.minor}")
|
||||
println(" Patch: ${GeneratedVersion.patch}")
|
||||
println(" PreRelease: ${GeneratedVersion.preReleaseWithPrefix()}")
|
||||
println(" BuildMetaData: ${GeneratedVersion.buildMetaWithPrefix()}")
|
||||
println(" PreRelease: ${GeneratedVersion.preRelease}")
|
||||
println(" BuildMetaData: ${GeneratedVersion.buildMeta}")
|
||||
|
||||
println("-----------------------------------------------------")
|
||||
}
|
||||
|
|
16
version.vm
16
version.vm
|
@ -11,25 +11,25 @@ private constructor() {
|
|||
val major = ${major}
|
||||
val minor = ${minor}
|
||||
val patch = ${patch}
|
||||
val buildmeta = "${buildmeta}"
|
||||
val prerelease = "${prerelease}"
|
||||
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"
|
||||
return if (preRelease.isNotEmpty() && prefix.isNotEmpty()) {
|
||||
"$prefix$preRelease"
|
||||
} else {
|
||||
prerelease
|
||||
preRelease
|
||||
}
|
||||
}
|
||||
|
||||
fun buildMetaWithPrefix(prefix: String = "+"): String {
|
||||
return if (buildmeta.isNotEmpty() && prefix.isNotEmpty()) {
|
||||
"$prefix\$buildmeta"
|
||||
return if (buildMeta.isNotEmpty() && prefix.isNotEmpty()) {
|
||||
"$prefix$buildMeta"
|
||||
} else {
|
||||
buildmeta
|
||||
buildMeta
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue