private static String getVersion ( final Class < ? > clazz ) { CodeSource source = clazz . getProtectionDomain ( ) . getCodeSource ( ) ; URL location = source . getLocation ( ) ; try { Path path = Paths . get ( location . toURI ( ) ) ; return Files . isRegularFile ( path ) ? getVersionFromJar ( path ) : getVersionFromPom ( path ) ; } catch ( URISyntaxException ex ) { Logger . error ( ex , "Unknown location: \"{}\"" , location ) ; return null ; } }
Gets the version for a class .