2
0
Fork 0
mirror of https://github.com/ethauvin/bld.git synced 2025-04-25 08:17:11 -07:00

Initialize BldVersion directly using the classloader resources.

This commit is contained in:
Geert Bevin 2023-05-11 09:32:50 -04:00
parent 2fa65fc302
commit ddf31fd1a5
2 changed files with 15 additions and 6 deletions

View file

@ -4,8 +4,9 @@
*/
package rife.bld;
import rife.resources.ResourceFinderClasspath;
import rife.resources.exceptions.ResourceFinderErrorException;
import rife.tools.FileUtils;
import java.io.IOException;
/**
* Singleton class that provides access to the current bld version as a string.
@ -17,10 +18,18 @@ public class BldVersion {
private String version_;
BldVersion() {
ResourceFinderClasspath resource_finder = ResourceFinderClasspath.instance();
var resource = getClass().getClassLoader().getResource("BLD_VERSION");
try {
version_ = resource_finder.getContent("BLD_VERSION");
} catch (ResourceFinderErrorException e) {
if (resource == null) {
version_ = null;
} else {
var connection = resource.openConnection();
connection.setUseCaches(false);
try (var input_stream = connection.getInputStream()) {
version_ = FileUtils.readString(input_stream);
}
}
} catch (IOException e) {
version_ = null;
}

View file

@ -429,7 +429,7 @@ public class Wrapper {
}
}
// find the wrapper classloader in the hierarchy and add the RIFE2 jar to it
// find the wrapper classloader in the hierarchy and add the bld jar to it
classloader_ = new WrapperClassLoader();
classloader_.add(distribution_file.toURI().toURL());