- java.lang.Object
-
- ch.qos.logback.core.util.VersionUtil
-
public class VersionUtil extends Object
Utility class for handling and validating version information of various artifacts.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 Modifier Constructor Description protectedVersionUtil(Context context)Instance methods allow for polymorphism, static methods do not.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected static voidaddFoundVersionStatus(Context context, String name, String version)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.voidcompareExpectedAndFoundVersion(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.protected StringgetExpectedVersionOfDependencyByProperties(Class<?> dependerClass, String propertiesFileName, String dependencyNameAsKey)static StringgetVersionOfArtifact(Class<?> aClass)Deprecated.protected static StringnameToPropertiesFilename(String name)static StringnonNull(String input)
-
-
-
Constructor Detail
-
VersionUtil
protected VersionUtil(Context context)
Instance methods allow for polymorphism, static methods do not.- Parameters:
context-- Since:
- 1.5.30
-
-
Method Detail
-
getVersionOfArtifact
public static String getVersionOfArtifact(Class<?> aClass)
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
-
getExpectedVersionOfDependencyByProperties
protected String getExpectedVersionOfDependencyByProperties(Class<?> dependerClass, String propertiesFileName, String dependencyNameAsKey)
-
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
-
addFoundVersionStatus
protected static void addFoundVersionStatus(Context context, String name, String version)
-
nameToPropertiesFilename
protected static String nameToPropertiesFilename(String name)
-
compareExpectedAndFoundVersion
public void compareExpectedAndFoundVersion(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.
-
-