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 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 = "";

View file

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

View file

@ -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<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
#Tue Jul 03 21:18:17 PDT 2018
#Sat Jul 07 01:16:12 PDT 2018
version.prerelease=
version.buildmeta=
version.patch=2

View file

@ -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")
}
}

View file

@ -1,3 +1,16 @@
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
#Tue Jul 03 11:42:03 PDT 2018
#Sat Jul 07 00:50:57 PDT 2018
version.prerelease=
version.buildmeta=
version.patch=0

View file

@ -11,8 +11,9 @@ public class App {
public void cat(String name) {
try {
final List<String> 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);

View file

@ -1,4 +1,8 @@
f = new File("examples.properties")
println(f.absoluteFile)
println(f.exists())
println(f.canRead())
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")
}

View file

@ -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