Updated example to cat the version properties file.

This commit is contained in:
Erik C. Thauvin 2018-07-07 01:40:16 -07:00
parent abe1ca269c
commit b50f2bad9a
10 changed files with 58 additions and 26 deletions

View file

@ -16,10 +16,10 @@ public final class GeneratedVersion {
public final static String BUILDMETA_PREFIX = "+"; public final static String BUILDMETA_PREFIX = "+";
public final static String PROJECT = ""; 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 MAJOR = 1;
public final static int MINOR = 1; public final static int MINOR = 2;
public final static int PATCH = 0; public final static int PATCH = 1;
public final static String PRERELEASE = ""; public final static String PRERELEASE = "";
public final static String BUILDMETA = ""; public final static String BUILDMETA = "";

View file

@ -41,4 +41,7 @@ run {
doFirst { doFirst {
println "Version: $version" println "Version: $version"
} }
}
// args = ['example.properties']
args = ['version.properties']
}

View file

@ -1,12 +1,20 @@
/* import java.io.IOException;
* This Java source file was generated by the Gradle 'init' task. import java.nio.file.Files;
*/ import java.nio.file.Path;
public class App { import java.nio.file.Paths;
public static void main(String[] args) { import java.util.List;
System.out.println(new App().getGreeting());
}
public String getGreeting() { public class App {
return "Hello world."; 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<String> content = Files.readAllLines(path);
System.out.println("> cat " + path.getFileName());
for (final String line : content) {
System.out.println(line);
}
}
}
} }
} }

View file

@ -1,5 +1,5 @@
#Generated by the Semver Plugin for Gradle #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.prerelease=
version.buildmeta= version.buildmeta=
version.patch=2 version.patch=2

View file

@ -38,9 +38,12 @@ tasks {
useTestNG() useTestNG()
} }
val run by getting { val run by getting(JavaExec::class) {
doFirst { doFirst {
println("Version: $version") println("Version: $version")
} }
// args = listof("example.properties")
args = listOf("version.properties")
} }
} }

View file

@ -1,3 +1,16 @@
package com.example package com.example
fun main(args: Array<String>) = println("Hello world.") import java.io.File
fun main(args: Array<String>) {
if (args.size == 1) {
File(args[0]).apply {
if (exists()) {
println("> cat $name")
forEachLine {
println(it)
}
}
}
}
}

View file

@ -1,5 +1,5 @@
#Generated by the Semver Plugin for Gradle #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.prerelease=
version.buildmeta= version.buildmeta=
version.patch=0 version.patch=0

View file

@ -11,8 +11,9 @@ public class App {
public void cat(String name) { public void cat(String name) {
try { try {
final List<String> content = Files.readAllLines(Paths.get(name)); final List<String> content = Files.readAllLines(Paths.get(name));
System.out.println("> cat " + name);
for (String line : content) { for (String line : content) {
if (!line.startsWith("#")) System.out.println(line); System.out.println(line);
} }
} catch (IOException e) { } catch (IOException e) {
System.out.println(e); System.out.println(e);

View file

@ -1,4 +1,8 @@
f = new File("examples.properties") if (this.args.length > 0) {
println(f.absoluteFile) for (arg in this.args) {
println(f.exists()) f = new File(arg)
println(f.canRead()) println("${f.name}\t-> exits: ${f.exists()}, canRead: ${f.canRead()} --> `${f.absoluteFile}`")
}
} else {
println("Usage: groovy ${this.class.getName()} filename")
}

View file

@ -1,7 +1,7 @@
#Generated by the Semver Plugin for Gradle #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.prerelease=
version.buildmeta= version.buildmeta=
version.patch=0 version.patch=1
version.major=1 version.major=1
version.minor=1 version.minor=2