[cli][build] Relax the git id plugin (#6094)

* [cli][build] Relax the git id plugin

* Guard against null on missing build properties
This commit is contained in:
Jim Schubert
2020-04-30 08:49:07 -04:00
committed by GitHub
parent 3e2c933dec
commit cc623ba429
2 changed files with 20 additions and 7 deletions

View File

@@ -2,6 +2,7 @@ package org.openapitools.codegen.cmd;
import java.io.IOException;
import java.io.InputStream;
import java.time.DateTimeException;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
@@ -23,15 +24,19 @@ public class BuildInfo {
static {
try (InputStream is = BuildInfo.class.getResourceAsStream("/version.properties")) {
Properties versionProps = new Properties();
versionProps.load(is);
properties.putAll(versionProps);
if (is != null) {
Properties versionProps = new Properties();
versionProps.load(is);
properties.putAll(versionProps);
}
} catch (IOException ignored) {
}
try (InputStream is = BuildInfo.class.getResourceAsStream("/openapi-generator-git.properties")) {
Properties gitProps = new Properties();
gitProps.load(is);
properties.putAll(gitProps);
if (is != null) {
Properties gitProps = new Properties();
gitProps.load(is);
properties.putAll(gitProps);
}
} catch (IOException ignored) {
}
}
@@ -82,7 +87,13 @@ public class BuildInfo {
StringBuilder sb = new StringBuilder(CLI_NAME);
sb.append(" ").append(this.getVersion()).append(System.lineSeparator());
sb.append(" commit : ").append(this.getSha()).append(System.lineSeparator());
sb.append(" built : ").append(this.getBuildTime().format(DateTimeFormatter.ISO_OFFSET_DATE_TIME)).append(System.lineSeparator());
sb.append(" built : ");
try {
sb.append(this.getBuildTime().format(DateTimeFormatter.ISO_OFFSET_DATE_TIME));
} catch (DateTimeException e) {
sb.append(UNKNOWN);
}
sb.append(System.lineSeparator());
sb.append(" source : ").append(GIT_REPO).append(System.lineSeparator());
sb.append(" docs : ").append(SITE).append(System.lineSeparator());
return sb.toString();

View File

@@ -65,6 +65,8 @@
</includeOnlyProperties>
<commitIdGenerationMode>full</commitIdGenerationMode>
<dotGitDirectory>${project.parent.basedir}${file.separator}.git</dotGitDirectory>
<failOnNoGitDirectory>false</failOnNoGitDirectory>
<failOnUnableToExtractRepoInfo>false</failOnUnableToExtractRepoInfo>
</configuration>
</plugin>
<plugin>