org.scijava.util
Class VersionUtils

java.lang.Object
  extended by org.scijava.util.VersionUtils

public class VersionUtils
extends Object

Useful methods for retrieving versions from JARs and POMs associated with Class objects.

Author:
Curtis Rueden, Mark Hiner

Constructor Summary
VersionUtils()
           
 
Method Summary
static String getBuildNumber(Class<?> c)
          Looks up the build number (typically an SCM revision) of the specified class.
static String getVersion(Class<?> c)
          Looks up the version of the specified class using any means available, appending the build number to any SNAPSHOT version.
static String getVersion(Class<?> c, String groupId, String artifactId)
          Looks up the version of the specified class using any means available, appending the build number to any SNAPSHOT version.
static String getVersionFromManifest(Class<?> c)
          Looks up the version of the specified class using a JAR manifest if available, appending the build number to any SNAPSHOT version.
static String getVersionFromPOM(Class<?> c, String groupId, String artifactId)
          Looks up the version of the specified class using the specified POM, or base POM directory if groupId and artifactId are null.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VersionUtils

public VersionUtils()
Method Detail

getVersion

public static String getVersion(Class<?> c)
Looks up the version of the specified class using any means available, appending the build number to any SNAPSHOT version. Will only search POMs in the base directory.

Parameters:
c - - Look up this class's version
Returns:
Version of specified Class or null if not found.

getVersion

public static String getVersion(Class<?> c,
                                String groupId,
                                String artifactId)
Looks up the version of the specified class using any means available, appending the build number to any SNAPSHOT version. The groupId and artifactId parameters allow specification of the POM lookup path.

Parameters:
c - - Look up this class's version
groupId - - Maven group ID containing class
artifactId - - Maven artifact ID containing class
Returns:
Version of specified Class or null if not found.

getVersionFromManifest

public static String getVersionFromManifest(Class<?> c)
Looks up the version of the specified class using a JAR manifest if available, appending the build number to any SNAPSHOT version.

Parameters:
c - - Look up this class's version
Returns:
Version of specified Class or null if not found.

getVersionFromPOM

public static String getVersionFromPOM(Class<?> c,
                                       String groupId,
                                       String artifactId)
Looks up the version of the specified class using the specified POM, or base POM directory if groupId and artifactId are null.

Parameters:
c - - Look up this class's version
groupId - - Maven group ID containing class
artifactId - - Maven artifact ID containing class
Returns:
Version of specified Class or null if not found.

getBuildNumber

public static String getBuildNumber(Class<?> c)
Looks up the build number (typically an SCM revision) of the specified class. This information is retrieved from the JAR manifest's Implementation-Build entry, or null if no such value exists.

Parameters:
c - - Look up this class's build number
Returns:
Build number of specified Class or null if not found.


Copyright © 2009–2014 SciJava. All rights reserved.