mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-09 13:46:10 +00:00
[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:
@@ -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();
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user