Skip to content

Commit 3957246

Browse files
committed
Version.properties now is accessible in jar
1 parent 3a033c3 commit 3957246

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

build.gradle

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ jlinkZip {
6969
group = 'distribution'
7070
}
7171

72-
sourceSets.main {
73-
resources {
74-
srcDir 'src/main/resources'
75-
}
76-
}
72+
//sourceSets.main {
73+
// resources {
74+
// srcDir 'src/main/resources'
75+
// }
76+
//}
7777

7878
allprojects {
7979
apply plugin: 'java'
@@ -85,7 +85,8 @@ allprojects {
8585

8686
task createProperties(dependsOn: processResources) {
8787
doLast {
88-
new File("$buildDir/resources/version.properties").withWriter { w ->
88+
new File("${sourceSets.main.resources.srcDirs[0]}/version.properties").
89+
withWriter { w ->
8990
Properties p = new Properties()
9091
p['version'] = project.version.toString()
9192
p.store w, null

src/main/java/com/candle/fileexplorer/viewmodel/AboutViewModel.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.candle.fileexplorer.viewmodel;
22

3-
import java.io.FileInputStream;
43
import java.io.FileNotFoundException;
54
import java.io.IOException;
5+
import java.io.InputStream;
66
import java.util.Properties;
77

88
public class AboutViewModel {
@@ -12,13 +12,12 @@ public class AboutViewModel {
1212
* Gets the version of the application.
1313
*/
1414
public String getFilesVersion() {
15-
Properties properties = null;
16-
FileInputStream stream = null;
15+
Properties properties;
16+
InputStream stream;
1717
String version = null;
1818
try {
19-
String location = System.getProperty("user.dir") + "/build" +
20-
"/resources/version.properties";
21-
stream = new FileInputStream(location);
19+
20+
stream = this.getClass().getResourceAsStream("/version.properties");
2221
properties = new Properties();
2322
properties.load(stream);
2423

-450 Bytes
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#Sat Jul 09 12:51:39 PDT 2022
2+
version=0.1

0 commit comments

Comments
 (0)