I'm creating a Java sdk which I ultimately want a file called version
to contain a string of the current version of the sdk.
I want to read this file and pass it along in underlying API calls I make within the sdk.
Currently this file is located in src/main/resources/version
and simply contains 0.1.0
.
I have this method which reads the file and returns the version.
private static String getVersion() {
URL versionFile = ConfigurationUtils.class.getResource("version");
Path path = Paths.get(String.valueOf(versionFile));
String version = null;
try {
version = Files.readAllLines(path).get(0);
} catch (IOException e) {
// The project should never build without if this happens so therefore just print a stacktrace
e.printStackTrace();
}
return version;
}
In another project where I'm trying to use this sdk, i'm getting a java.nio.file.NoSuchFileException: null
on this line
I can see that the file actually does exist in my dependencies though
Any idea what i'm missing here?
** Update **
When trying the suggestion from the possible duplicate, my sdk won't even compile b/c it's getting a null pointer exception on this line when running my tests.