Class VersionUtil

java.lang.Object
com.norconex.commons.lang.VersionUtil

@Deprecated(forRemoval=true, since="3.0.0") public final class VersionUtil extends Object
Deprecated, for removal: This API element is subject to removal in a future version.
Use PackageManifest instead.
Version-related convenience methods.
Since:
2.0.0
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    getDetailedVersion(@NonNull Class<?> cls, String fallback)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Gets the detailed version from the project or library the provided class belongs to.
    static String
    Deprecated, for removal: This API element is subject to removal in a future version.
    Gets the detailed version from the project or library the provided class belongs to.
    static String
    getVersion(@NonNull Class<?> cls, String fallback)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Gets the version from the project or library the provided class belongs to.
    static String
    getVersion(Class<?> cls)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Gets the version from the project or library the provided class belongs to.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getVersion

      public static String getVersion(Class<?> cls)
      Deprecated, for removal: This API element is subject to removal in a future version.

      Gets the version from the project or library the provided class belongs to. This method attempts to read that version information from the class package implementation details, normally found in jar manifest files.

      The manifest is often created when the code is packaged for distribution. For instance, if you use Maven, you can ask it to automaticall store implementation details with the manifest file when creating a jar file by setting addDefaultImplementationEntries set to true (see https://maven.apache.org/shared/maven-archiver/).

      If developing (not yet packaged), an attempt is made to locate a pom.xml and load the version from it.

      Parameters:
      cls - the class used to extract version
      Returns:
      the version number or null if not found
    • getVersion

      public static String getVersion(@NonNull @NonNull Class<?> cls, String fallback)
      Deprecated, for removal: This API element is subject to removal in a future version.

      Gets the version from the project or library the provided class belongs to. This method attempts to read that version information from the class package implementation details, normally found in jar manifest files.

      The manifest is often created when the code is packaged for distribution. For instance, if you use Maven, you can ask it to automaticall store implementation details with the manifest file when creating a jar file by setting addDefaultImplementationEntries set to true (see https://maven.apache.org/shared/maven-archiver/).

      If developing (not yet packaged), an attempt is made to locate a pom.xml and load the version from it.

      Parameters:
      cls - the class used to extract version
      fallback - text to return when no version could be found
      Returns:
      the version number or the fallback value if not found
    • getDetailedVersion

      public static String getDetailedVersion(Class<?> cls)
      Deprecated, for removal: This API element is subject to removal in a future version.

      Gets the detailed version from the project or library the provided class belongs to. This method attempts to read that version information from the class package implementation details, normally found in jar manifest files.

      The manifest is often created when the code is packaged for distribution. For instance, if you use Maven, you can ask it to automaticall store implementation details with the manifest file when creating a jar file by setting addDefaultImplementationEntries set to true (see https://maven.apache.org/shared/maven-archiver/).

      If developing (not yet packaged), an attempt is made to locate a pom.xml and load the version from it.

      Parameters:
      cls - the class used to extract version
      Returns:
      the version number or the fallback value if not found
    • getDetailedVersion

      public static String getDetailedVersion(@NonNull @NonNull Class<?> cls, String fallback)
      Deprecated, for removal: This API element is subject to removal in a future version.

      Gets the detailed version from the project or library the provided class belongs to. This method attempts to read that version information from the class package implementation details, normally found in jar manifest files.

      The manifest is often created when the code is packaged for distribution. For instance, if you use Maven, you can ask it to automatically store implementation details with the manifest file when creating a jar file by setting addDefaultImplementationEntries set to true (see https://maven.apache.org/shared/maven-archiver/).

      If developing (not yet packaged), an attempt is made to locate a pom.xml and load the version from it.

      Parameters:
      cls - the class used to extract version
      fallback - text to return when no version could be found
      Returns:
      the version number or the fallback value if not found