Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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>("jar") {
manifest {
attributes(
"Main-Class" to "com.CDPrintable.Main"
)
}
}
20 changes: 19 additions & 1 deletion src/main/java/com/CDPrintable/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/version.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Application version.

# MAJOR MINOR PATCH
version=1.7.5