cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Gentry <mgen...@masslight.net>
Subject Re: Version API
Date Wed, 29 Jul 2015 10:56:31 GMT
Maybe we should add a Cayenne.getVersion() method?



> On Jul 27, 2015, at 10:41 AM, Mike Kienenberger <mkienenb@gmail.com> wrote:
> 
> Our jar MANIFEST file also contains:
> 
> Bundle-Version: 4.0.0.M2
> 
> But shouldn't we also be supplying this information as
> 
> Implementation-Version: 4.0.0.M2
> 
> so it's in a standardized place?
> 
> I'd guess that's a simple maven build change -- I know how to do it
> under ant, but not under maven.
> 
> 
> Once we do that, then we can use the standard java libraries to
> provide the information:
> 
>        Object object = new CayenneRuntimeException();
>        Package objPackage = object.getClass().getPackage();
>        System.out.println("Implementation Version: " +
> objPackage.getImplementationVersion());
> 
> produces
> 
> Implementation Version: 4.0.0.M2
> 
> when I add an Implementation-Version: line to the MANIFEST in
> cayenne-server-4.0.M2.jar
> 
> =====
>   Manifest-Version: 1.0
> + Implementation-Version: 4.0.0.M2
>   Export-Package: org.apache.cayenne;uses:="org.apache.cayenne.reflect,o
> =====
> 
>> On Mon, Jul 27, 2015 at 9:57 AM, Andrus Adamchik <andrus@objectstyle.org> wrote:
>> 
>>> On Jul 27, 2015, at 4:21 PM, Joe Baldwin <jfbaldwin@earthlink.net> 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
>> 
>> 

Mime
View raw message