Merge branch 'modularize' into master

This branch introduces some configuration that enables Java 9 modules in this project,
adds a GPL copyright disclaimer to the output of --version flag
and makes changes to gradle that make the application version dynamically assigned using git
information and the "git describe" command.

Closes #16
This commit is contained in:
Jonas Tobias Hopusch 2022-01-02 18:34:23 +01:00
commit 3566b52698
Failed to generate hash of commit
4 changed files with 33 additions and 8 deletions

View file

@ -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.
@ -22,9 +31,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 +42,5 @@ tasks.jar {
application {
// Define the main class for the application.
mainClass.set("de.jotoho.waituntil.Main")
mainModule.set("de.jotoho.waituntil.main")
}

View file

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

View file

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

View file

@ -0,0 +1,2 @@
module de.jotoho.waituntil.main {
}