Skip to content

Commit

Permalink
Merge pull request #2942 from liquibase/more-library-info-in-version
Browse files Browse the repository at this point in the history
Add additional info in CLI's --version output
  • Loading branch information
nvoxland committed Jun 17, 2022
2 parents fc5ccbd + 1323630 commit e43bf18
Showing 1 changed file with 10 additions and 8 deletions.
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

0 comments on commit e43bf18

Please sign in to comment.