From fae31308e0f077a4af5490c8836eccfcf0e1cb15 Mon Sep 17 00:00:00 2001 From: Jonas Tobias Hopusch Date: Sun, 2 Jan 2022 18:32:46 +0100 Subject: [PATCH 1/2] Add java module config to project --- build.gradle.kts | 8 +++++--- src/main/java/module-info.java | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 src/main/java/module-info.java diff --git a/build.gradle.kts b/build.gradle.kts index 9dd27a7..e595380 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -22,9 +22,10 @@ java { tasks.jar { manifest { attributes( - "Implementation-Title" to "de.jotoho.waituntil", - "Implementation-Version" to "${project.version}", - "Main-Class" to "de.jotoho.waituntil.Main" + "Implementation-Title" to project.name, + "Implementation-Version" to project.version, + "Main-Class" to "de.jotoho.waituntil.Main", + "Main-Module" to "de.jotoho.waituntil.main" ) } } @@ -32,4 +33,5 @@ tasks.jar { application { // Define the main class for the application. mainClass.set("de.jotoho.waituntil.Main") + mainModule.set("de.jotoho.waituntil.main") } diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java new file mode 100644 index 0000000..72e6d14 --- /dev/null +++ b/src/main/java/module-info.java @@ -0,0 +1,2 @@ +module de.jotoho.waituntil.main { +} \ No newline at end of file From d09cd0f37e6bb610ccb95a747e8c068484cf1b90 Mon Sep 17 00:00:00 2001 From: Jonas Tobias Hopusch Date: Sun, 2 Jan 2022 18:33:17 +0100 Subject: [PATCH 2/2] Determine application version by calling git describe --- build.gradle.kts | 11 ++++++++++- settings.gradle.kts | 2 +- src/main/java/de/jotoho/waituntil/Main.java | 18 +++++++++++++++--- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index e595380..c5bd21b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,8 +6,17 @@ plugins { id("com.github.johnrengelman.shadow") version "latest.release" } +fun versionBanner(): String { + val os = org.apache.commons.io.output.ByteArrayOutputStream() + project.exec { + commandLine = "git describe --always --dirty".split(" ") + standardOutput = os + } + return String(os.toByteArray()).trim() +} + group = "de.jotoho" -version = "0.1.1" +version = versionBanner() repositories { // Use Maven Central for resolving dependencies. diff --git a/settings.gradle.kts b/settings.gradle.kts index bfe2fb2..599ab7a 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -7,4 +7,4 @@ * in the user manual at https://docs.gradle.org/7.2/userguide/multi_project_builds.html */ -rootProject.name = "de.jotoho.waituntil" +rootProject.name = "waituntil" diff --git a/src/main/java/de/jotoho/waituntil/Main.java b/src/main/java/de/jotoho/waituntil/Main.java index a891ef3..9179c3f 100644 --- a/src/main/java/de/jotoho/waituntil/Main.java +++ b/src/main/java/de/jotoho/waituntil/Main.java @@ -1,6 +1,7 @@ package de.jotoho.waituntil; -import java.util.*; +import java.util.HashSet; +import java.util.Map; import static de.jotoho.waituntil.GlobalConf.applicationOutputLanguage; @@ -35,8 +36,19 @@ public final class Main { } } else if (options.contains("version")) { final var thisPackage = Main.class.getPackage(); - final var appVersion = thisPackage.getImplementationVersion() != null ? thisPackage.getImplementationVersion() :"UNKNOWN"; - System.out.println("de.jotoho.waituntil version " + appVersion); + final var appVersion = thisPackage.getImplementationVersion() != null + ? thisPackage.getImplementationVersion() + : "version unknown"; + System.out.println("waituntil " + appVersion); + System.out.println(""" + + This program is free software: you can redistribute it and/or modify it under the terms of the + GNU General Public License as published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details."""); } else if (words.size() == 1) { final var target = TimeCalculator.calculateAndAnnounceTargetTime(words.iterator().next()); Sleep.waitUntilTimeStamp(target);