Moved from Gradle to bld

This commit is contained in:
Erik C. Thauvin 2023-11-08 12:10:45 -08:00
parent 22c5d30ace
commit e99fad47c7
89 changed files with 1087 additions and 907 deletions

View file

@ -0,0 +1,59 @@
package com.example;
import rife.bld.BaseProject;
import rife.bld.BuildCommand;
import rife.bld.extension.CompileKotlinOperation;
import rife.bld.extension.CompileKotlinOptions;
import rife.bld.operations.RunOperation;
import java.util.List;
import static rife.bld.dependencies.Repository.MAVEN_CENTRAL;
import static rife.bld.dependencies.Repository.MAVEN_LOCAL;
import static rife.bld.dependencies.Scope.compile;
public class ReadingTimeExampleBuild extends BaseProject {
public ReadingTimeExampleBuild() {
pkg = "com.example";
name = "ReadingTimeExample";
version = version(0, 1, 0);
mainClass = "com.example.ReadingTimeExampleKt";
javaRelease = 11;
downloadSources = true;
autoDownloadPurge = true;
repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL);
scope(compile)
.include(dependency("org.jetbrains.kotlin", "kotlin-stdlib", version(1, 9, 20)))
.include(dependency("net.thauvin.erik", "readingtime", version(0, 9, 2, "SNAPSHOT")));
}
public static void main(String[] args) {
new ReadingTimeExampleBuild().start(args);
}
@Override
public void compile() throws Exception {
new CompileKotlinOperation()
.fromProject(this)
.compileOptions(
new CompileKotlinOptions()
.jdkRelease(javaRelease)
.verbose(true)
)
.execute();
// Also compile the Java source code
super.compile();
}
@BuildCommand(value = "run-java", summary = "Runs the Java example")
public void runJava() throws Exception {
new RunOperation()
.fromProject(this)
.mainClass("com.example.ReadingTimeSample")
.execute();
}
}

View file

@ -0,0 +1,28 @@
package com.example;
import net.thauvin.erik.readingtime.ReadingTime;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
public class ReadingTimeSample {
public static void main(String[] args) {
if (args.length >= 1) {
final Path text = Path.of(args[0]);
try {
final ReadingTime rt = new ReadingTime(Files.readString(text));
rt.setPostfix("minute to read");
rt.setPlural("minutes to read");
System.out.println("It will take " + rt.calcReadingTime() + ' ' + ReadingTime.wordCount(rt.getText())
+ " words and " + ReadingTime.imgCount(rt.getText()) + " images at " + rt.getWpm()
+ " words per minute.");
} catch (IOException e) {
System.err.println("The file could not be read or found.");
}
} else {
System.err.println("Please specify a file as an argument.");
}
}
}

View file

@ -0,0 +1,25 @@
package com.example
import net.thauvin.erik.readingtime.ReadingTime
import java.io.File
fun main(args: Array<String>) {
if (args.isNotEmpty()) {
with(File(args[0])) {
if (exists() && canRead()) {
val rt = ReadingTime(readText())
rt.postfix = "minute to read"
rt.plural = "minutes to read"
println(
"It will take ${rt.calcReadingTime()} ${ReadingTime.wordCount(rt.text)} words and " +
"${ReadingTime.imgCount(rt.text)} images at ${rt.wpm} words per minute."
)
} else {
System.err.println("The file could not be read or found.")
}
}
} else {
System.err.println("Please specify a file as an argument.")
}
}

View file

@ -0,0 +1,28 @@
package com.example;
import net.thauvin.erik.readingtime.ReadingTime;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
public class ReadingTimeSample {
public static void main(String[] args) {
if (args.length >= 1) {
final Path text = Path.of(args[0]);
try {
final ReadingTime rt = new ReadingTime(Files.readString(text));
rt.setPostfix("minute to read");
rt.setPlural("minutes to read");
System.out.println("It will take " + rt.calcReadingTime() + ' ' + ReadingTime.wordCount(rt.getText())
+ " words and " + ReadingTime.imgCount(rt.getText()) + " images at " + rt.getWpm()
+ " words per minute.");
} catch (IOException e) {
System.err.println("The file could not be read or found.");
}
} else {
System.err.println("Please specify a file as an argument.");
}
}
}

View file

@ -0,0 +1,25 @@
package com.example
import net.thauvin.erik.readingtime.ReadingTime
import java.io.File
fun main(args: Array<String>) {
if (args.isNotEmpty()) {
with(File(args[0])) {
if (exists() && canRead()) {
val rt = ReadingTime(readText())
rt.postfix = "minute to read"
rt.plural = "minutes to read"
println(
"It will take ${rt.calcReadingTime()} ${ReadingTime.wordCount(rt.text)} words and " +
"${ReadingTime.imgCount(rt.text)} images at ${rt.wpm} words per minute."
)
} else {
System.err.println("The file could not be read or found.")
}
}
} else {
System.err.println("Please specify a file as an argument.")
}
}