diff --git a/build.gradle.kts b/build.gradle.kts index d5366eb..5f57608 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,13 +8,21 @@ * This is the main build file. */ +import java.util.Properties +import java.io.FileInputStream + +val versionProperties = Properties() +file("src/main/resources/version.properties").takeIf { it.exists() }?.let { + versionProperties.load(FileInputStream(it)) +} + plugins { id("java") id("application") } group = "org.example" -version = "1.0-SNAPSHOT" +version = versionProperties.getProperty("version", "0.0-VERSION-ERROR") repositories { mavenCentral() @@ -34,4 +42,18 @@ tasks.test { application { mainClass.set("com.CDPrintable.Main") applicationDefaultJvmArgs = listOf("-Djava.library.path=build/libs") +} + +java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(22)) + } +} + +tasks.named("jar") { + manifest { + attributes( + "Main-Class" to "com.CDPrintable.Main" + ) + } } \ No newline at end of file diff --git a/src/main/java/com/CDPrintable/Constants.java b/src/main/java/com/CDPrintable/Constants.java index 49c923a..3ba3534 100644 --- a/src/main/java/com/CDPrintable/Constants.java +++ b/src/main/java/com/CDPrintable/Constants.java @@ -10,9 +10,27 @@ package com.CDPrintable; +import java.io.InputStream; +import java.util.Properties; + public class Constants { // MAJOR MINOR PATCH - public static final String VERSION = "1.6.4"; + public static final String VERSION; + static { + Properties prop = new Properties(); + String tempVersion = "0.0.0"; // Default version + try (InputStream input = Constants.class.getClassLoader().getResourceAsStream("version.properties")) { + if (input != null) { + prop.load(input); + tempVersion = prop.getProperty("version"); + } else { + System.err.println("version.properties not found in resources."); + } + } catch (Exception e) { + System.err.println("Failed to load version.properties: " + e.getMessage()); + } + VERSION = tempVersion; + } public static final boolean USER_AGENT_EMAIL_CHANGED = false; diff --git a/src/main/resources/version.properties b/src/main/resources/version.properties new file mode 100644 index 0000000..da0fc6f --- /dev/null +++ b/src/main/resources/version.properties @@ -0,0 +1,4 @@ +# Application version. + +# MAJOR MINOR PATCH +version=1.7.5 \ No newline at end of file