diff --git a/build.gradle b/build.gradle index 0d3265744f02e0674505a7677063bded30f079f5..bbefbb2490539aaa6799153446a482e5dc028340 100644 --- a/build.gradle +++ b/build.gradle @@ -47,6 +47,13 @@ java { withJavadocJar() } +processResources { + inputs.property("project.version", project.version) + filesMatching("de/tla2b/build.properties") { + expand(version: project.version) + } +} + jacoco { toolVersion = "0.8.9" reportsDirectory = file("$buildDir/customJacocoReportDir") diff --git a/src/main/java/de/tla2b/global/TranslationGlobals.java b/src/main/java/de/tla2b/global/TranslationGlobals.java index 5ac04170e2778198400d864fc63e89e88654169a..9c5c6d88426d1145faacc77a4d81860f3809448e 100644 --- a/src/main/java/de/tla2b/global/TranslationGlobals.java +++ b/src/main/java/de/tla2b/global/TranslationGlobals.java @@ -6,7 +6,7 @@ import java.util.Arrays; import tla2sany.semantic.FrontEnd; public interface TranslationGlobals { - final String VERSION_NUMBER = "1.1.5-SNAPSHOT"; + final String VERSION_NUMBER = VersionHelper.VERSION; final int TLCValueKind = 100; diff --git a/src/main/java/de/tla2b/global/VersionHelper.java b/src/main/java/de/tla2b/global/VersionHelper.java new file mode 100644 index 0000000000000000000000000000000000000000..5ff99e42445d3ea9e45de531b4d7a037b216ce68 --- /dev/null +++ b/src/main/java/de/tla2b/global/VersionHelper.java @@ -0,0 +1,30 @@ +package de.tla2b.global; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.nio.charset.StandardCharsets; +import java.util.Properties; + +final class VersionHelper { + private VersionHelper() { + throw new AssertionError("Utility class"); + } + + static final String VERSION; + static { + final Properties buildProperties = new Properties(); + final InputStream is = VersionHelper.class.getResourceAsStream("/de/tla2b/build.properties"); + if (is == null) { + throw new AssertionError("Build properties not found, this should never happen!"); + } else { + try (final Reader r = new InputStreamReader(is, StandardCharsets.UTF_8)) { + buildProperties.load(r); + } catch (final IOException e) { + throw new AssertionError("IOException while loading build properties, this should never happen!", e); + } + } + VERSION = buildProperties.getProperty("version"); + } +} diff --git a/src/main/resources/de/tla2b/build.properties b/src/main/resources/de/tla2b/build.properties new file mode 100644 index 0000000000000000000000000000000000000000..178150d8adcd72de8d62a2fea7bb8611961d2a38 --- /dev/null +++ b/src/main/resources/de/tla2b/build.properties @@ -0,0 +1,3 @@ +# The values for these properties are generated during the build. +# See the configuration of the processResources task in build.gradle. +version=${version}