mirror of
https://github.com/jlengrand/jreleaser.git
synced 2026-03-10 08:31:24 +00:00
[chore] Avoid printing null when parsing the project version
This commit is contained in:
@@ -127,7 +127,7 @@ public class Environment implements Domain {
|
||||
|
||||
private void loadVariables(JReleaserContext context, Path file) {
|
||||
propertiesFile = file;
|
||||
context.getLogger().info("Loading properties from {}", file.toAbsolutePath());
|
||||
context.getLogger().info("Loading variables from {}", file.toAbsolutePath());
|
||||
if (Files.exists(file)) {
|
||||
try {
|
||||
if (file.getFileName().toString().endsWith(".properties")) {
|
||||
@@ -136,10 +136,10 @@ public class Environment implements Domain {
|
||||
vars.putAll(JReleaserConfigLoader.loadProperties(file));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
context.getLogger().debug("Could not load properties from {}", file.toAbsolutePath(), e);
|
||||
context.getLogger().debug("Could not load variables from {}", file.toAbsolutePath(), e);
|
||||
}
|
||||
} else {
|
||||
context.getLogger().warn("Properties source {} does not exist", file.toAbsolutePath());
|
||||
context.getLogger().warn("Variables source {} does not exist", file.toAbsolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -315,10 +315,13 @@ public class Project implements Domain, ExtraProperties {
|
||||
}
|
||||
|
||||
public void parseVersion() {
|
||||
String v = getResolvedVersion();
|
||||
if (isBlank(v)) return;
|
||||
|
||||
switch (getVersionPattern()) {
|
||||
case SEMVER: {
|
||||
try {
|
||||
Version parsedVersion = Version.of(getVersion());
|
||||
Version parsedVersion = Version.of(v);
|
||||
StringBuilder vn = new StringBuilder().append(parsedVersion.getMajor());
|
||||
addExtraProperty(Constants.KEY_VERSION_MAJOR, parsedVersion.getMajor());
|
||||
if (parsedVersion.hasMinor()) {
|
||||
@@ -337,13 +340,13 @@ public class Project implements Domain, ExtraProperties {
|
||||
addExtraProperty(Constants.KEY_VERSION_BUILD, parsedVersion.getBuild());
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new JReleaserException("Version '" + getVersion() + "' does not follow the semver spec", e);
|
||||
throw new JReleaserException("Version '" + v + "' does not follow the semver spec", e);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case JAVA_MODULE: {
|
||||
case JAVA_MODULE: {
|
||||
try {
|
||||
JavaModuleVersion parsedVersion = JavaModuleVersion.of(getVersion());
|
||||
JavaModuleVersion parsedVersion = JavaModuleVersion.of(v);
|
||||
addExtraProperty(Constants.KEY_VERSION_NUMBER, parsedVersion.getVersion());
|
||||
if (parsedVersion.hasPrerelease()) {
|
||||
addExtraProperty(Constants.KEY_VERSION_PRERELEASE, parsedVersion.getPrerelease());
|
||||
@@ -352,7 +355,7 @@ public class Project implements Domain, ExtraProperties {
|
||||
addExtraProperty(Constants.KEY_VERSION_BUILD, parsedVersion.getBuild());
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new JReleaserException("Version '" + getVersion() + "' does not follow the Java module spec", e);
|
||||
throw new JReleaserException("Version '" + v + "' does not follow the Java module spec", e);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user