Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional info in CLI's --version output #2942

Merged
merged 1 commit into from
Jun 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import liquibase.configuration.core.DefaultsFileValueProvider;
import liquibase.exception.CommandLineParsingException;
import liquibase.exception.CommandValidationException;
import liquibase.exception.UnexpectedLiquibaseException;
import liquibase.hub.HubConfiguration;
import liquibase.license.LicenseService;
import liquibase.license.LicenseServiceFactory;
Expand All @@ -30,7 +29,6 @@
import picocli.CommandLine;

import java.io.*;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
Expand Down Expand Up @@ -1168,7 +1166,12 @@ public String[] getVersion() throws Exception {
filePath = workingDirectory.relativize(info.file.toPath()).toString();
}

libraryDescription.append("- "). append(filePath).append(": ").append(info.name).append(" ").append(info.version).append("\n");
libraryDescription.append("- ")
.append(filePath).append(":")
.append(" ").append(info.name)
.append(" ").append(info.version == null ? "UNKNOWN" : info.version)
.append(info.vendor == null ? "" : " By " + info.vendor)
.append("\n");
}
}

Expand All @@ -1192,15 +1195,13 @@ private LibraryInfo getLibraryInfo(File pathEntryFile) throws IOException {
libraryInfo.file = pathEntryFile;

final Manifest manifest = jarFile.getManifest();
libraryInfo.name = getValue(manifest, "Bundle-Name", "Implementation-Title");
libraryInfo.version = getValue(manifest, "Bundle-Version", "Implementation-Version");
libraryInfo.name = getValue(manifest, "Bundle-Name", "Implementation-Title", "Specification-Title");
libraryInfo.version = getValue(manifest, "Bundle-Version", "Implementation-Version", "Specification-Version");
libraryInfo.vendor = getValue(manifest, "Bundle-Vendor", "Implementation-Vendor", "Specification-Vendor");

if (libraryInfo.name == null) {
libraryInfo.name = pathEntryFile.getName().replace(".jar", "");
}
if (libraryInfo.version == null) {
libraryInfo.version = "UNKNOWN";
}
return libraryInfo;
}
}
Expand All @@ -1217,6 +1218,7 @@ private String getValue(Manifest manifest, String... keys) {


private static class LibraryInfo implements Comparable<LibraryInfo> {
private String vendor;
private String name;
private File file;
private String version;
Expand Down