Class VersionUtil
- Since:
- 2.0.0
- Author:
- Pascal Essiembre
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetDetailedVersion(Class<?> cls) Gets the detailed version from the project or library the provided class belongs to.static StringgetDetailedVersion(Class<?> cls, String fallback) Gets the detailed version from the project or library the provided class belongs to.static StringgetVersion(Class<?> cls) Gets the version from the project or library the provided class belongs to.static StringgetVersion(Class<?> cls, String fallback) Gets the version from the project or library the provided class belongs to.
-
Method Details
-
getVersion
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
addDefaultImplementationEntriesset totrue(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
nullif not found
-
getVersion
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
addDefaultImplementationEntriesset totrue(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 versionfallback- text to return when no version could be found- Returns:
- the version number or the fallback value if not found
-
getDetailedVersion
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
addDefaultImplementationEntriesset totrue(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
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
addDefaultImplementationEntriesset totrue(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 versionfallback- text to return when no version could be found- Returns:
- the version number or the fallback value if not found
-