File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88 * This is the main build file.
99 */
1010
11+ import java.util.Properties
12+ import java.io.FileInputStream
13+
14+ val versionProperties = Properties ()
15+ file(" src/main/resources/version.properties" ).takeIf { it.exists() }?.let {
16+ versionProperties.load(FileInputStream (it))
17+ }
18+
1119plugins {
1220 id(" java" )
1321 id(" application" )
1422}
1523
1624group = " org.example"
17- version = " 1 .0-SNAPSHOT "
25+ version = versionProperties.getProperty( " version " , " 0 .0-VERSION-ERROR " )
1826
1927repositories {
2028 mavenCentral()
@@ -34,4 +42,18 @@ tasks.test {
3442application {
3543 mainClass.set(" com.CDPrintable.Main" )
3644 applicationDefaultJvmArgs = listOf (" -Djava.library.path=build/libs" )
45+ }
46+
47+ java {
48+ toolchain {
49+ languageVersion.set(JavaLanguageVersion .of(22 ))
50+ }
51+ }
52+
53+ tasks.named<Jar >(" jar" ) {
54+ manifest {
55+ attributes(
56+ " Main-Class" to " com.CDPrintable.Main"
57+ )
58+ }
3759}
Original file line number Diff line number Diff line change 1010
1111package com .CDPrintable ;
1212
13+ import java .io .InputStream ;
14+ import java .util .Properties ;
15+
1316public class Constants {
1417 // MAJOR MINOR PATCH
15- public static final String VERSION = "1.6.4" ;
18+ public static final String VERSION ;
19+ static {
20+ Properties prop = new Properties ();
21+ String tempVersion = "0.0.0" ; // Default version
22+ try (InputStream input = Constants .class .getClassLoader ().getResourceAsStream ("version.properties" )) {
23+ if (input != null ) {
24+ prop .load (input );
25+ tempVersion = prop .getProperty ("version" );
26+ } else {
27+ System .err .println ("version.properties not found in resources." );
28+ }
29+ } catch (Exception e ) {
30+ System .err .println ("Failed to load version.properties: " + e .getMessage ());
31+ }
32+ VERSION = tempVersion ;
33+ }
1634
1735 public static final boolean USER_AGENT_EMAIL_CHANGED = false ;
1836
Original file line number Diff line number Diff line change 1+ # Application version.
2+
3+ # MAJOR MINOR PATCH
4+ version =1.7.5
You can’t perform that action at this time.
0 commit comments