public class VersionUtil
extends java.lang.Object
Version
s.
Also contains other misc methods that have no other place to live in.
Note that this class can be used in two roles: first, as a static utility class for loading purposes, and second, as a singleton loader of per-module version information.
Note that method for accessing version information changed between versions 2.1 and 2.2; earlier code used file named "VERSION.txt"; but this has serious performance issues on some platforms (Android), so a replacement system was implemented to use class generation and dynamic class loading.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
PACKAGE_VERSION_CLASS_NAME |
static java.lang.String |
VERSION_FILE
Deprecated.
Since 2.2, use of version file is deprecated, and generated
class should be used instead.
|
Modifier | Constructor and Description |
---|---|
protected |
VersionUtil() |
Modifier and Type | Method and Description |
---|---|
static Version |
mavenVersionFor(java.lang.ClassLoader classLoader,
java.lang.String groupId,
java.lang.String artifactId)
Will attempt to load the maven version for the given groupId and
artifactId.
|
static Version |
packageVersionFor(java.lang.Class<?> cls)
Loads version information by introspecting a class named
"PackageVersion" in the same package as the given class.
|
static Version |
parseVersion(java.lang.String versionStr)
Deprecated.
|
static Version |
parseVersion(java.lang.String versionStr,
java.lang.String groupId,
java.lang.String artifactId) |
protected static int |
parseVersionPart(java.lang.String partStr) |
static void |
throwInternal() |
Version |
version() |
static Version |
versionFor(java.lang.Class<?> cls)
Helper method that will try to load version information for specified
class.
|
@Deprecated public static final java.lang.String VERSION_FILE
public static final java.lang.String PACKAGE_VERSION_CLASS_NAME
public Version version()
public static Version versionFor(java.lang.Class<?> cls)
Version.unknownVersion()
is returned.public static Version packageVersionFor(java.lang.Class<?> cls)
public static Version mavenVersionFor(java.lang.ClassLoader classLoader, java.lang.String groupId, java.lang.String artifactId)
classLoader
- the ClassLoader to load the pom.properties file fromgroupId
- the groupId of the libraryartifactId
- the artifactId of the library@Deprecated public static Version parseVersion(java.lang.String versionStr)
public static Version parseVersion(java.lang.String versionStr, java.lang.String groupId, java.lang.String artifactId)
protected static int parseVersionPart(java.lang.String partStr)
public static final void throwInternal()
Copyright © 2013. All Rights Reserved.