** What steps will reproduce the problem?
This unit test will show that no version have been defined for the jar/package
public void testMetadataExtractorVersion() throws Exception {
Package loadMetadataExt = com.drew.imaging.jpeg.JpegMetadataReader.class.getPackage();
assertEquals("com.drew.imaging.jpeg", loadMetadataExt.getImplementationTitle());
assertEquals("drewnoakes.com", loadMetadataExt.getImplementationVendor());
assertEquals("2.6.4", loadMetadataExt.getImplementationVersion());
}
** What is the expected output? What do you see instead?
I'd like to be able to retrieve the implementation version at runtime using
native Java information.
We use it in our software to show current version of library loaded by the
application server so that our user know if for some reason another version
than the one expected has been loaded.
** Please provide any additional information below.
One nice approach I see in some software package is to provide
1. a simple "Version" class in the main package of the library, with a simple
static method getVersion().
2. a valid MANIFEST entry for the main package.
For example you could provide both
1. a class com.drew.metadata.Version.class : getString() { return "2.6.4"; }
2. a valid MANIFEST entry , either for the whole jar of per package, your
choice), here is for the whole jar :
Implementation-Title: metadata-extractor
Implementation-Version: 2.6.4
Implementation-Vendor: drewnoakes.com
You could then test with following unit test :
public void testMetadataExtractorVersion() throws Exception {
assertEquals("2.6.4", com.drew.metadata.Version.getString());
Package loadMetadataExt = com.drew.metadata.Versionclass.getPackage();
assertEquals("com.drew.metadata", loadMetadataExt.getImplementationTitle());
assertEquals("drewnoakes.com", loadMetadataExt.getImplementationVendor());
assertEquals("2.6.4", loadMetadataExt.getImplementationVersion());
}
Original issue reported on code.google.com by olivier....@gmail.com on 22 Apr 2013 at 4:05
Original issue reported on code.google.com by
olivier....@gmail.com
on 22 Apr 2013 at 4:05