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'
|
compileOnly 'org.apache.velocity:velocity:1.7'
|
||||||
|
|
||||||
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
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(" Major: ${GeneratedVersion.major}")
|
||||||
println(" Minor: ${GeneratedVersion.minor}")
|
println(" Minor: ${GeneratedVersion.minor}")
|
||||||
println(" Patch: ${GeneratedVersion.patch}")
|
println(" Patch: ${GeneratedVersion.patch}")
|
||||||
println(" PreRelease: ${GeneratedVersion.preReleaseWithPrefix()}")
|
println(" PreRelease: ${GeneratedVersion.preRelease}")
|
||||||
println(" BuildMetaData: ${GeneratedVersion.buildMetaWithPrefix()}")
|
println(" BuildMetaData: ${GeneratedVersion.buildMeta}")
|
||||||
|
|
||||||
println("-----------------------------------------------------")
|
println("-----------------------------------------------------")
|
||||||
}
|
}
|
||||||
|
|
16
version.vm
16
version.vm
|
@ -11,25 +11,25 @@ private constructor() {
|
||||||
val major = ${major}
|
val major = ${major}
|
||||||
val minor = ${minor}
|
val minor = ${minor}
|
||||||
val patch = ${patch}
|
val patch = ${patch}
|
||||||
val buildmeta = "${buildmeta}"
|
val buildMeta = "${buildmeta}"
|
||||||
val prerelease = "${prerelease}"
|
val preRelease = "${prerelease}"
|
||||||
|
|
||||||
val version: String
|
val version: String
|
||||||
get() = ("\$major.\$minor.\$patch" + preReleaseWithPrefix() + buildMetaWithPrefix())
|
get() = ("\$major.\$minor.\$patch" + preReleaseWithPrefix() + buildMetaWithPrefix())
|
||||||
|
|
||||||
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"
|
||||||
} else {
|
} else {
|
||||||
prerelease
|
preRelease
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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"
|
||||||
} else {
|
} else {
|
||||||
buildmeta
|
buildMeta
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue