File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import org.apache.tools.ant.filters.ReplaceTokens
12import tool.generator.GenerateLibs
23
34plugins {
@@ -35,18 +36,10 @@ jar {
3536 }
3637}
3738
38- tasks. register(' makePropertyResource' ) {
39- def directory = file " ${ buildDir} /resources/main/imgui/"
40- directory. mkdirs()
41- def propertyFile = file " ${ directory} /imgui-java.properties"
42- def props = new Properties ()
43- if (propertyFile. exists()) {
44- propertyFile. withReader { props. load(it) }
45- }
46- props. setProperty(" version" , project. version)
47- propertyFile. withWriter { props. store(it, " imgui-java" ) }
48- }
49-
5039processResources {
51- dependsOn makePropertyResource
40+ filesMatching(' **/imgui-java.properties' ) {
41+ filter(ReplaceTokens , tokens : [
42+ ' version' : project. version
43+ ])
44+ }
5245}
Original file line number Diff line number Diff line change 2323import java .nio .file .Path ;
2424import java .nio .file .Paths ;
2525import java .nio .file .StandardCopyOption ;
26+ import java .util .Optional ;
2627import java .util .Properties ;
2728
2829public class ImGui {
@@ -122,10 +123,7 @@ private static String tryLoadFromClasspath(final String fullLibName) {
122123 return null ;
123124 }
124125
125- String version = getVersionString ();
126- if (version == null ) {
127- version = "unknown" ;
128- }
126+ final String version = getVersionString ().orElse ("undefined" );
129127 final Path tmpDir = Paths .get (System .getProperty ("java.io.tmpdir" )).resolve (LIB_TMP_DIR_PREFIX ).resolve (version );
130128 if (!Files .exists (tmpDir )) {
131129 Files .createDirectories (tmpDir );
@@ -146,17 +144,17 @@ private static String tryLoadFromClasspath(final String fullLibName) {
146144 }
147145 }
148146
149- private static String getVersionString () {
147+ private static Optional < String > getVersionString () {
150148 final Properties properties = new Properties ();
151149 try (InputStream is = ImGui .class .getResourceAsStream ("/imgui/imgui-java.properties" )) {
152150 if (is != null ) {
153151 properties .load (is );
154- return properties .get ("version" ).toString ();
152+ return Optional . of ( properties .get ("imgui.java. version" ).toString () );
155153 }
156154 } catch (IOException e ) {
157155 throw new UncheckedIOException (e );
158156 }
159- return null ;
157+ return Optional . empty () ;
160158 }
161159
162160 /**
Original file line number Diff line number Diff line change 1+ imgui.java.version =@version@
You can’t perform that action at this time.
0 commit comments