I have a library foo.jar
that contains an svnversion.properties
file (just looks like svnversion=12345M
or whatever) and the following static method in a class SVNVersion
:
public static SVNVersion fromString(String s) { ... }
public static SVNVersion fromResources(Class<?> cl) {
ResourceBundle svnversionResource = ResourceBundle.getBundle(
"svnversion", Locale.getDefault(), cl.getClassLoader());
if (svnversionResource.containsKey("svnversion"))
{
String svnv = svnversionResource.getString("svnversion");
return fromString(svnv);
}
else
{
return null;
}
}
I also have a library bar.jar
that contains an svnversion.properties
file as well (let's say it contains svnversion=789
).
However, when I run the following within a class SomeClassInBarJar
that's in bar.jar
:
SVNVersion vfoo = SVNVersion.fromResources(SVNVersion.class);
SVNVersion vbar = SVNVersion.fromResources(SomeClassInBarJar.class);
and I print the result, I see 789
twice. Clearly I am not doing this right. How do I get the right svnversion.properties
file in the root of the jar file containing a given class? (assuming it's there)
edit: I just tried
InputStream is = cl.getResourceAsStream("/svnversion.properties");
and it has the same problem. I seem to be able only to get access to the main jar file's /svnversion.properties
and not the library's /svnversion.properties
.