[core] skip properties should have a defined value. Fixes #292

This commit is contained in:
Andres Almiray
2021-07-16 19:34:49 +02:00
parent 81a08ede4a
commit 5f56576dcc
6 changed files with 31 additions and 9 deletions

View File

@@ -27,6 +27,7 @@ import java.util.stream.Collectors;
import static org.jreleaser.util.StringUtils.capitalize;
import static org.jreleaser.util.StringUtils.getClassNameForLowerCaseHyphenSeparatedName;
import static org.jreleaser.util.StringUtils.isBlank;
import static org.jreleaser.util.StringUtils.isTrue;
/**
* @author Andres Almiray
@@ -202,6 +203,11 @@ public class Upload implements Domain, EnabledAware {
}
private boolean isSkip(Map<String, Object> props, List<String> keys) {
return props.keySet().stream().anyMatch(keys::contains);
for (String key : keys) {
if (props.containsKey(key) && isTrue(props.get(key))) {
return true;
}
}
return false;
}
}

View File

@@ -39,6 +39,7 @@ import static org.jreleaser.model.validation.ExtraPropertiesValidator.mergeExtra
import static org.jreleaser.model.validation.TemplateValidator.validateTemplate;
import static org.jreleaser.util.StringUtils.isBlank;
import static org.jreleaser.util.StringUtils.isNotBlank;
import static org.jreleaser.util.StringUtils.isTrue;
/**
* @author Andres Almiray
@@ -114,9 +115,9 @@ public abstract class BrewValidator extends Validator {
int pkgFound = 0;
String pkgName = "";
for (Artifact artifact : distribution.getArtifacts()) {
if (artifact.getPath().endsWith(".dmg") && !artifact.getExtraProperties().containsKey("skipBrew"))
if (artifact.getPath().endsWith(".dmg") && !isTrue(artifact.getExtraProperties().get("skipBrew")))
dmgFound++;
if (artifact.getPath().endsWith(".pkg") && !artifact.getExtraProperties().containsKey("skipBrew")) {
if (artifact.getPath().endsWith(".pkg") && !isTrue(artifact.getExtraProperties().get("skipBrew"))) {
pkgFound++;
pkgName = artifact.getEffectivePath(context).getFileName().toString();
}

View File

@@ -34,6 +34,7 @@ import static org.jreleaser.templates.TemplateUtils.trimTplExtension;
import static org.jreleaser.util.MustacheUtils.applyTemplate;
import static org.jreleaser.util.MustacheUtils.passThrough;
import static org.jreleaser.util.StringUtils.isNotBlank;
import static org.jreleaser.util.StringUtils.isTrue;
/**
* @author Andres Almiray
@@ -72,8 +73,8 @@ public class BrewToolProcessor extends AbstractRepositoryToolProcessor<Brew> {
if ((distribution.getType() == Distribution.DistributionType.JAVA_BINARY ||
distribution.getType() == Distribution.DistributionType.SINGLE_JAR) &&
!tool.getExtraProperties().containsKey("javaSkip") &&
!tool.getExtraProperties().containsKey("skipJava")) {
!isTrue(tool.getExtraProperties().get("javaSkip")) &&
!isTrue(tool.getExtraProperties().get("skipJava"))) {
tool.addDependency("openjdk@" + props.get(Constants.KEY_DISTRIBUTION_JAVA_VERSION));
} else if (distribution.getType() == Distribution.DistributionType.NATIVE_PACKAGE) {
props.put(Constants.KEY_BREW_CASK_NAME, tool.getCask().getResolvedCaskName(props));

View File

@@ -639,4 +639,10 @@ public class StringUtils {
public static Pattern toSafePattern(String str) {
return Pattern.compile(toSafeRegexPattern(str));
}
public static boolean isTrue(Object o) {
if (o == null) return false;
if (o instanceof Boolean) return (Boolean) o;
return "true".equalsIgnoreCase(String.valueOf(o).trim());
}
}

View File

@@ -30,6 +30,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import static org.jreleaser.util.StringUtils.isTrue;
/**
* @author Andres Almiray
* @since 0.4.0
@@ -88,6 +90,11 @@ public abstract class AbstractArtifactUploader<U extends Uploader> implements Ar
}
private boolean isSkip(Map<String, Object> props, List<String> keys) {
return props.keySet().stream().anyMatch(keys::contains);
for (String key : keys) {
if (props.containsKey(key) && isTrue(props.get(key))) {
return true;
}
}
return false;
}
}

View File

@@ -30,6 +30,7 @@ import java.util.Map;
import static org.jreleaser.util.MustacheUtils.applyTemplate;
import static org.jreleaser.util.StringUtils.isBlank;
import static org.jreleaser.util.StringUtils.isNotBlank;
import static org.jreleaser.util.StringUtils.isTrue;
/**
* @author Andres Almiray
@@ -68,7 +69,7 @@ public class SdkmanAnnouncer implements Announcer {
continue;
}
if (artifact.getExtraProperties().containsKey("skipSdkman")) {
if (isTrue(artifact.getExtraProperties().get("skipSdkman"))) {
context.getLogger().debug("Artifact {} is explicitly skipped.",
artifact.getEffectivePath(context, distribution).getFileName());
continue;
@@ -130,8 +131,8 @@ public class SdkmanAnnouncer implements Announcer {
return (distribution.getType() == Distribution.DistributionType.JAVA_BINARY ||
distribution.getType() == Distribution.DistributionType.JLINK ||
distribution.getType() == Distribution.DistributionType.NATIVE_IMAGE) &&
!distribution.getExtraProperties().containsKey("sdkmanSkip") &&
!distribution.getExtraProperties().containsKey("skipSdkman");
!isTrue(distribution.getExtraProperties().get("sdkmanSkip")) &&
!isTrue(distribution.getExtraProperties().get("skipSdkman"));
}
private String mapPlatform(String platform) {