From 6e0e99694e884c48b861333c436451a2b8259f66 Mon Sep 17 00:00:00 2001 From: Athou Date: Tue, 9 Jan 2024 14:53:13 +0100 Subject: [PATCH] use properties file of git-commit-id-maven-plugin so we don't need to filter resources --- commafeed-server/pom.xml | 9 ++------- .../com/commafeed/CommaFeedConfiguration.java | 19 +++++++++++++++---- .../src/main/resources/application.properties | 2 -- 3 files changed, 17 insertions(+), 13 deletions(-) delete mode 100644 commafeed-server/src/main/resources/application.properties diff --git a/commafeed-server/pom.xml b/commafeed-server/pom.xml index acdffdc2..dcaf5492 100644 --- a/commafeed-server/pom.xml +++ b/commafeed-server/pom.xml @@ -31,12 +31,6 @@ commafeed - - - src/main/resources - true - - @@ -69,7 +63,8 @@ - false + true + ${project.build.outputDirectory}/git.properties false false diff --git a/commafeed-server/src/main/java/com/commafeed/CommaFeedConfiguration.java b/commafeed-server/src/main/java/com/commafeed/CommaFeedConfiguration.java index f1ddab63..dbd660cb 100644 --- a/commafeed-server/src/main/java/com/commafeed/CommaFeedConfiguration.java +++ b/commafeed-server/src/main/java/com/commafeed/CommaFeedConfiguration.java @@ -1,8 +1,10 @@ package com.commafeed; +import java.io.IOException; +import java.io.InputStream; import java.time.Instant; import java.time.temporal.ChronoUnit; -import java.util.ResourceBundle; +import java.util.Properties; import com.commafeed.backend.cache.RedisPoolFactory; import com.commafeed.frontend.session.SessionHandlerFactory; @@ -20,9 +22,11 @@ import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Positive; import lombok.Getter; import lombok.Setter; +import lombok.extern.slf4j.Slf4j; @Getter @Setter +@Slf4j public class CommaFeedConfiguration extends Configuration implements WebsocketBundleConfiguration { public enum CacheType { @@ -53,10 +57,17 @@ public class CommaFeedConfiguration extends Configuration implements WebsocketBu private final String gitCommit; public CommaFeedConfiguration() { - ResourceBundle bundle = ResourceBundle.getBundle("application"); + Properties properties = new Properties(); + try (InputStream stream = getClass().getResourceAsStream("/git.properties")) { + if (stream != null) { + properties.load(stream); + } + } catch (IOException e) { + throw new RuntimeException(e); + } - this.version = bundle.getString("version"); - this.gitCommit = bundle.getString("git.commit"); + this.version = properties.getProperty("git.build.version", "unknown"); + this.gitCommit = properties.getProperty("git.commit.id.abbrev", "unknown"); } @Override diff --git a/commafeed-server/src/main/resources/application.properties b/commafeed-server/src/main/resources/application.properties deleted file mode 100644 index 263d9922..00000000 --- a/commafeed-server/src/main/resources/application.properties +++ /dev/null @@ -1,2 +0,0 @@ -version=${project.version} -git.commit=${git.commit.id.abbrev} \ No newline at end of file