Skip to content

Commit

Permalink
[cli][build] Relax the git id plugin (#6094)
Browse files Browse the repository at this point in the history
* [cli][build] Relax the git id plugin

* Guard against null on missing build properties
  • Loading branch information
jimschubert authored Apr 30, 2020
1 parent 3e2c933 commit cc623ba
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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;
Expand All @@ -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) {
}
}
Expand Down Expand Up @@ -82,7 +87,13 @@ public String versionDisplayText() {
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();
Expand Down
2 changes: 2 additions & 0 deletions modules/openapi-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit cc623ba

Please sign in to comment.