public static void touch() {
Class clazz = Version.class;
String classFileName = clazz.getSimpleName() + ".class";
String classFilePath = clazz.getCanonicalName().replace( '.", '/" )
+ ".class";
String pathToThisClass =
clazz.getResource( classFileName ).toString();
String pathToManifest = pathToThisClass.substring( 0, pathToThisClass.indexOf( classFilePath ) - 1 )
+ "/META-INF/MANIFEST.MF";
log.trace( "Manifest file {}", pathToManifest );
Manifest manifest = null;
String version;
try {
manifest = new Manifest( new URL( pathToManifest ).openStream() );
}
catch ( Exception e ) {
log.warn( "Unable to determine version of Hibernate Validator" );
}
if ( manifest == null ) {
version = "?";
}
else {
version = manifest.getMainAttributes().getValue( Attributes.Name.IMPLEMENTATION_VERSION );
}
log.info( "Hibernate Commons Annotations {}", version );
}
|