From b50f2bad9a19c3f9aa594232ca7ce3e4a9540437 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Sat, 7 Jul 2018 01:40:16 -0700 Subject: [PATCH] Updated example to cat the version properties file. --- .../com/example/GeneratedVersion.java | 6 ++-- examples/java/build.gradle | 5 +++- examples/java/src/main/java/App.java | 28 ++++++++++++------- examples/java/version.properties | 2 +- examples/kotlin/build.gradle.kts | 5 +++- .../src/main/kotlin/com/example/Main.kt | 15 +++++++++- examples/kotlin/version.properties | 2 +- examples/test/src/main/java/App.java | 3 +- examples/test/test.groovy | 12 +++++--- examples/version.properties | 6 ++-- 10 files changed, 58 insertions(+), 26 deletions(-) diff --git a/examples/annotation-processor/java/src/generated/com/example/GeneratedVersion.java b/examples/annotation-processor/java/src/generated/com/example/GeneratedVersion.java index cce75d1..beca5c4 100644 --- a/examples/annotation-processor/java/src/generated/com/example/GeneratedVersion.java +++ b/examples/annotation-processor/java/src/generated/com/example/GeneratedVersion.java @@ -16,10 +16,10 @@ public final class GeneratedVersion { public final static String BUILDMETA_PREFIX = "+"; public final static String PROJECT = ""; - public final static Date BUILDDATE = new Date(1530571116045L); + public final static Date BUILDDATE = new Date(1530835680171L); public final static int MAJOR = 1; - public final static int MINOR = 1; - public final static int PATCH = 0; + public final static int MINOR = 2; + public final static int PATCH = 1; public final static String PRERELEASE = ""; public final static String BUILDMETA = ""; diff --git a/examples/java/build.gradle b/examples/java/build.gradle index c391237..18922da 100644 --- a/examples/java/build.gradle +++ b/examples/java/build.gradle @@ -41,4 +41,7 @@ run { doFirst { println "Version: $version" } -} + + // args = ['example.properties'] + args = ['version.properties'] +} \ No newline at end of file diff --git a/examples/java/src/main/java/App.java b/examples/java/src/main/java/App.java index c2347df..f1550d6 100644 --- a/examples/java/src/main/java/App.java +++ b/examples/java/src/main/java/App.java @@ -1,12 +1,20 @@ -/* - * This Java source file was generated by the Gradle 'init' task. - */ -public class App { - public static void main(String[] args) { - System.out.println(new App().getGreeting()); - } +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; - public String getGreeting() { - return "Hello world."; +public class App { + public static void main(String... args) throws IOException { + if (args.length == 1) { + final Path path = Paths.get(args[0]); + if (Files.exists(path)) { + final List content = Files.readAllLines(path); + System.out.println("> cat " + path.getFileName()); + for (final String line : content) { + System.out.println(line); + } + } + } } -} +} \ No newline at end of file diff --git a/examples/java/version.properties b/examples/java/version.properties index 44266b1..f6974cf 100644 --- a/examples/java/version.properties +++ b/examples/java/version.properties @@ -1,5 +1,5 @@ #Generated by the Semver Plugin for Gradle -#Tue Jul 03 21:18:17 PDT 2018 +#Sat Jul 07 01:16:12 PDT 2018 version.prerelease= version.buildmeta= version.patch=2 diff --git a/examples/kotlin/build.gradle.kts b/examples/kotlin/build.gradle.kts index 586d170..51efc61 100644 --- a/examples/kotlin/build.gradle.kts +++ b/examples/kotlin/build.gradle.kts @@ -38,9 +38,12 @@ tasks { useTestNG() } - val run by getting { + val run by getting(JavaExec::class) { doFirst { println("Version: $version") } + + // args = listof("example.properties") + args = listOf("version.properties") } } diff --git a/examples/kotlin/src/main/kotlin/com/example/Main.kt b/examples/kotlin/src/main/kotlin/com/example/Main.kt index f6cdb3c..4ef488b 100644 --- a/examples/kotlin/src/main/kotlin/com/example/Main.kt +++ b/examples/kotlin/src/main/kotlin/com/example/Main.kt @@ -1,3 +1,16 @@ package com.example -fun main(args: Array) = println("Hello world.") \ No newline at end of file +import java.io.File + +fun main(args: Array) { + if (args.size == 1) { + File(args[0]).apply { + if (exists()) { + println("> cat $name") + forEachLine { + println(it) + } + } + } + } +} \ No newline at end of file diff --git a/examples/kotlin/version.properties b/examples/kotlin/version.properties index c682fd9..5088bec 100644 --- a/examples/kotlin/version.properties +++ b/examples/kotlin/version.properties @@ -1,5 +1,5 @@ #Generated by the Semver Plugin for Gradle -#Tue Jul 03 11:42:03 PDT 2018 +#Sat Jul 07 00:50:57 PDT 2018 version.prerelease= version.buildmeta= version.patch=0 diff --git a/examples/test/src/main/java/App.java b/examples/test/src/main/java/App.java index d1cb582..318ac03 100644 --- a/examples/test/src/main/java/App.java +++ b/examples/test/src/main/java/App.java @@ -11,8 +11,9 @@ public class App { public void cat(String name) { try { final List content = Files.readAllLines(Paths.get(name)); + System.out.println("> cat " + name); for (String line : content) { - if (!line.startsWith("#")) System.out.println(line); + System.out.println(line); } } catch (IOException e) { System.out.println(e); diff --git a/examples/test/test.groovy b/examples/test/test.groovy index 5179634..7f66d71 100644 --- a/examples/test/test.groovy +++ b/examples/test/test.groovy @@ -1,4 +1,8 @@ -f = new File("examples.properties") -println(f.absoluteFile) -println(f.exists()) -println(f.canRead()) \ No newline at end of file +if (this.args.length > 0) { + for (arg in this.args) { + f = new File(arg) + println("${f.name}\t-> exits: ${f.exists()}, canRead: ${f.canRead()} --> `${f.absoluteFile}`") + } +} else { + println("Usage: groovy ${this.class.getName()} filename") +} \ No newline at end of file diff --git a/examples/version.properties b/examples/version.properties index 69cf961..08a3e18 100644 --- a/examples/version.properties +++ b/examples/version.properties @@ -1,7 +1,7 @@ #Generated by the Semver Plugin for Gradle -#Tue Jul 03 14:16:07 PDT 2018 +#Fri Jul 06 23:36:26 PDT 2018 version.prerelease= version.buildmeta= -version.patch=0 +version.patch=1 version.major=1 -version.minor=1 +version.minor=2