Class VersionUtil
It is used by logback-classic, logback-access-common, logback-access-jetty11, logback-access-tomcat, etc. to alert users about version discrepancies between depender and dependency artifacts.
- Since:
- 1.5.25
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckForVersionEquality(Context context, Class<?> dependerClass, Class<?> dependencyClass, String dependerName, String dependencyName) static voidcheckForVersionEquality(Context context, Class<?> dependerClass, String dependencyVersion, String dependerName, String dependencyName) static voidcheckForVersionEquality(Context context, String dependerVersion, String dependencyVersion, String dependerName, String dependencyName) Compares the versions of a depender and a dependency to determine if they are equal.static voidcompareExpectedAndFoundVersion(Context context, String actualDependencyVersion, Class<?> dependerClass, String dependerVersion, String dependerName, String dependencyName) Compares the expected version of a dependency with the actual version found and updates the status context.static StringgetArtifactVersionBySelfDeclaredProperties(Class<?> aClass, String moduleName) Deprecated.(this code cannot be shared and is useless here)static StringgetVersionOfArtifact(Class<?> aClass) Deprecated.static String
-
Constructor Details
-
VersionUtil
public VersionUtil()
-
-
Method Details
-
getVersionOfArtifact
Deprecated.Retrieves the version of an artifact, such as logback-core.jar, logback-access-common.jar etc.The aClass parameter is assumed to be part of the artifact.
The method first attempts to get the version from the module information. If the module version is not available, it falls back to retrieving the implementation version from the package.
- Parameters:
aClass- the class from which to retrieve the version information- Returns:
- the version of the artifact where aClass is found, or null if the version cannot be determined
-
nonNull
-
getArtifactVersionBySelfDeclaredProperties
Deprecated.(this code cannot be shared and is useless here)Retrieves the version of a module using a properties file associated with the module.Unfortunately, this code cannot be called by other modules. It needs to be duplicated.
The method looks for a properties file with a name derived from the
moduleNameparameter, in the same location, e.g. package, as theaClassparameter. It attempts to load the properties file and fetch the version information using a specific key.The properties file is expected to be in the same package as the class provided, and named
moduleName-version.properties. The properties file should contain a single key-value pair, where the key ismoduleName-version, and the value is the module version.- Parameters:
aClass- the class used to locate the resource file, the properties file is expected to be in the same packagemoduleName- the name of the module, which is used to construct the properties file name and the key- Returns:
- the version of the module as a string, or null if the version cannot be determined
- Since:
- 1.5.26
-
checkForVersionEquality
-
checkForVersionEquality
-
checkForVersionEquality
public static void checkForVersionEquality(Context context, String dependerVersion, String dependencyVersion, String dependerName, String dependencyName) Compares the versions of a depender and a dependency to determine if they are equal. Updates the context's status manager with version information and logs a warning if the versions differ.- Since:
- 1.5.26
-
compareExpectedAndFoundVersion
public static void compareExpectedAndFoundVersion(Context context, String actualDependencyVersion, Class<?> dependerClass, String dependerVersion, String dependerName, String dependencyName) Compares the expected version of a dependency with the actual version found and updates the status context. If the versions do not match, a warning is added to the context's status manager.Note: This method is used be logback-access-jetty11/12 and logback-access-tomcat.
-