> On Jul 27, 2015, at 4:21 PM, Joe Baldwin <[email protected]> wrote:
>
> 1. My goal is to display the version of cayenne server jar I have added to
> the project with Cayenne 4.0.
As it happens, Project.CURRENT_PROJECT_VERSION (or its 4.0 alternative) is not
the same as the version of cayenne server jar. It denotes the version of the
XML mapping format, which does not align with the .jar version.
If you need the version of the jar, here is another approach. While you are not
using Maven, Cayenne is assembled with Maven, so each Cayenne jar has some
extra metadata that you get for free. Namely there's a "pom.properties" file
that you can read and get the version:
Properties props = new Properties();
String path = "META-INF/maven/org.apache.cayenne/cayenne-server/pom.properties";
try(InputStream in :
ObjectContext.class.getClassLoader().getResourceAsStream(path)) {
props.load(in);
}
String version = props.getProperty("version");
Andrus