VersionExtractor Class — spring-boot Architecture
Architecture documentation for the VersionExtractor class in VersionExtractor.java from the spring-boot codebase.
Entity Profile
Relationship Graph
Source Code
build-plugin/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/util/VersionExtractor.java lines 36–70
public final class VersionExtractor {
private VersionExtractor() {
}
/**
* Return the version information for the provided {@link Class}.
* @param cls the Class to retrieve the version for
* @return the version, or {@code null} if a version can not be extracted
*/
public static @Nullable String forClass(Class<?> cls) {
String implementationVersion = cls.getPackage().getImplementationVersion();
if (implementationVersion != null) {
return implementationVersion;
}
URL codeSourceLocation = cls.getProtectionDomain().getCodeSource().getLocation();
try {
URLConnection connection = codeSourceLocation.openConnection();
if (connection instanceof JarURLConnection jarURLConnection) {
return getImplementationVersion(jarURLConnection.getJarFile());
}
try (JarFile jarFile = new JarFile(new File(codeSourceLocation.toURI()))) {
return getImplementationVersion(jarFile);
}
}
catch (Exception ex) {
return null;
}
}
private static String getImplementationVersion(JarFile jarFile) throws IOException {
return jarFile.getManifest().getMainAttributes().getValue(Attributes.Name.IMPLEMENTATION_VERSION);
}
}
Domain
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free