diff --git a/ksml-runner/src/main/java/io/axual/ksml/runner/KSMLRunner.java b/ksml-runner/src/main/java/io/axual/ksml/runner/KSMLRunner.java
index 9dea78dd..d6ce8628 100644
--- a/ksml-runner/src/main/java/io/axual/ksml/runner/KSMLRunner.java
+++ b/ksml-runner/src/main/java/io/axual/ksml/runner/KSMLRunner.java
@@ -34,12 +34,11 @@
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
+import java.util.Properties;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import java.util.jar.Attributes;
-import java.util.jar.Manifest;
import io.axual.ksml.client.serde.ResolvingDeserializer;
import io.axual.ksml.client.serde.ResolvingSerializer;
@@ -88,32 +87,14 @@ public class KSMLRunner {
public static void main(String[] args) {
try {
// Load name and version from manifest
- var executableName = "KSML Runner";
- var executableVersion = "";
- try {
- ClassLoader cl = KSMLRunner.class.getClassLoader();
-
- try (InputStream url = cl.getResourceAsStream("META-INF/MANIFEST.MF")) {
- Manifest manifest = new Manifest(url);
- Attributes attr = manifest.getMainAttributes();
- String attrName = attr.getValue("Implementation-Title");
- if (attrName != null) {
- executableName = attrName;
- }
-
- String attrVersion = attr.getValue("Implementation-Version");
- if (attrVersion != null) {
- executableVersion = attrVersion;
- }
- }
- } catch (IOException e) {
- log.info("Could not load manifest file, using default values");
- }
+ var ksmlTitle = determineTitle();
// Check if we need to output the schema and then exit
checkForSchemaOutput(args);
- log.info("Starting {} {}", executableName, executableVersion);
+ log.info("Starting {}", ksmlTitle);
+
+ // Begin loading config file
final var configFile = new File(args.length == 0 ? DEFAULT_CONFIG_FILE_SHORT : args[0]);
if (!configFile.exists()) {
log.error("Configuration file '{}' not found", configFile);
@@ -257,6 +238,34 @@ public static void main(String[] args) {
}
}
+ private static String determineTitle() {
+ var ksmlTitle = "KSML";
+
+ try {
+ ClassLoader cl = KSMLRunner.class.getClassLoader();
+
+ try (InputStream url = cl.getResourceAsStream("ksml/ksml-info.properties")) {
+ Properties ksmlInfo = new Properties();
+ ksmlInfo.load(url);
+ var titleBuilder = new StringBuilder()
+ .append(ksmlInfo.getProperty("name", "KSML"));
+ if (ksmlInfo.containsKey("version")) {
+ titleBuilder.append(" ").append(ksmlInfo.getProperty("version"));
+ }
+ if (ksmlInfo.containsKey("buildTime")) {
+ titleBuilder.append(" (")
+ .append(ksmlInfo.getProperty("buildTime"))
+ .append(")");
+ }
+ ksmlTitle = titleBuilder.toString();
+ }
+
+ } catch (IOException e) {
+ log.info("Could not load manifest file, using default values");
+ }
+ return ksmlTitle;
+ }
+
private static void checkForSchemaOutput(String[] args) {
// Check if the runner was started with "--schema". If so, then we output the JSON schema to validate the
// KSML definitions with on stdout and exit
diff --git a/ksml-runner/src/main/java/io/axual/ksml/runner/prometheus/PrometheusExport.java b/ksml-runner/src/main/java/io/axual/ksml/runner/prometheus/PrometheusExport.java
index 8d25968a..14560ddb 100644
--- a/ksml-runner/src/main/java/io/axual/ksml/runner/prometheus/PrometheusExport.java
+++ b/ksml-runner/src/main/java/io/axual/ksml/runner/prometheus/PrometheusExport.java
@@ -104,7 +104,8 @@ public void start() throws Exception {
public synchronized void stop() {
Optional.ofNullable(httpServer).ifPresent(HTTPServer::close);
httpServer = null;
- collectorList.forEach(registry::unregister);
+ Optional.ofNullable(registry).ifPresent(r -> collectorList.forEach(r::unregister));
+ registry = null;
collectorList.clear();
}
diff --git a/ksml-runner/src/main/resources/ksml/ksml-info.properties b/ksml-runner/src/main/resources/ksml/ksml-info.properties
new file mode 100644
index 00000000..15f0d192
--- /dev/null
+++ b/ksml-runner/src/main/resources/ksml/ksml-info.properties
@@ -0,0 +1,3 @@
+name=${project.name}
+version=${project.version}
+buildTime=${maven.build.timestamp}
diff --git a/ksml-runner/src/test/resources/ksml/ksml-info.properties b/ksml-runner/src/test/resources/ksml/ksml-info.properties
new file mode 100644
index 00000000..f25c3569
--- /dev/null
+++ b/ksml-runner/src/test/resources/ksml/ksml-info.properties
@@ -0,0 +1,3 @@
+name=ksml-for-testing
+version=testing
+buildTime=2024-01-01T01:00:00Z
diff --git a/pom.xml b/pom.xml
index a1ac41e3..0508bc0b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -104,6 +104,7 @@
3.4.1
3.2.0
2.4.0
+ 3.3.1
3.6.3
3.2.5
@@ -535,6 +536,12 @@
+
+ org.apache.maven.plugins
+ maven-resources-plugin
+ ${maven.resources.plugin.version}
+
+
org.jacoco
jacoco-maven-plugin