use of org.jreleaser.util.Errors in project jreleaser by jreleaser.
the class Validator method checkProperty.
static boolean checkProperty(JReleaserContext context, String key, String property, Boolean value, boolean defaultValue) {
if (null != value)
return value;
Environment environment = context.getModel().getEnvironment();
String dsl = context.getConfigurer().toString();
String configFilePath = environment.getPropertiesFile().toAbsolutePath().normalize().toString();
Errors errors = new Errors();
String result = Env.check(key, environment.getVariable(key), property, dsl, configFilePath, errors);
return !errors.hasErrors() ? Boolean.parseBoolean(result) : defaultValue;
}
use of org.jreleaser.util.Errors in project jreleaser by jreleaser.
the class AbstractJdksMojo method validate.
protected void validate() throws MojoFailureException {
if (jdks == null || jdks.isEmpty())
return;
Errors errors = new Errors();
jdks.forEach(jdk -> jdk.validate(errors));
if (errors.hasErrors()) {
StringWriter s = new StringWriter();
PrintWriter w = new PrintWriter(s, true);
errors.logErrors(w);
throw new MojoFailureException(s.toString());
}
}
use of org.jreleaser.util.Errors in project jreleaser by jreleaser.
the class SetupDiscoMojo method validate.
private void validate() throws MojoFailureException {
if (connectTimeout <= 0 || connectTimeout > 300) {
connectTimeout = 20;
}
if (readTimeout <= 0 || readTimeout > 300) {
readTimeout = 60;
}
Errors errors = new Errors();
pkgs.forEach(pkg -> pkg.validate(errors));
if (errors.hasErrors()) {
StringWriter s = new StringWriter();
PrintWriter w = new PrintWriter(s, true);
errors.logErrors(w);
throw new MojoFailureException(s.toString());
}
}
use of org.jreleaser.util.Errors in project jreleaser by jreleaser.
the class DistributionsValidator method validateArtifactPlatforms.
public static void validateArtifactPlatforms(JReleaserContext context, Distribution distribution, Packager packager, List<Artifact> candidateArtifacts, Errors errors) {
// validate distribution type
if (distribution.getType() == Distribution.DistributionType.BINARY || distribution.getType() == Distribution.DistributionType.JLINK || distribution.getType() == Distribution.DistributionType.NATIVE_IMAGE || distribution.getType() == Distribution.DistributionType.NATIVE_PACKAGE) {
// ensure all artifacts define a platform
AtomicBoolean universal = new AtomicBoolean();
String noPlatform = "<nil>";
Map<String, List<Artifact>> byPlatform = candidateArtifacts.stream().peek(artifact -> {
if (distribution.getType() == Distribution.DistributionType.BINARY && artifact.extraPropertyIsTrue("universal")) {
universal.compareAndSet(false, true);
}
}).collect(groupingBy(artifact -> isBlank(artifact.getPlatform()) ? noPlatform : artifact.getPlatform()));
if (byPlatform.containsKey(noPlatform) && !universal.get()) {
errors.configuration(RB.$("validation_distributions_platform_check", distribution.getName(), distribution.getType(), packager.getType()));
}
if (byPlatform.keySet().stream().noneMatch(packager::supportsPlatform) && !universal.get()) {
context.getLogger().warn(RB.$("validation_distributions_disable", distribution.getName(), packager.getType()));
packager.disable();
}
}
}
use of org.jreleaser.util.Errors in project jreleaser by jreleaser.
the class GofishValidator method validateGofish.
public static void validateGofish(JReleaserContext context, Distribution distribution, Gofish packager, Errors errors) {
JReleaserModel model = context.getModel();
Gofish parentPackager = model.getPackagers().getGofish();
if (!packager.isActiveSet() && parentPackager.isActiveSet()) {
packager.setActive(parentPackager.getActive());
}
if (!packager.resolveEnabled(context.getModel().getProject(), distribution)) {
packager.disable();
return;
}
GitService service = model.getRelease().getGitService();
if (!service.isReleaseSupported()) {
packager.disable();
return;
}
context.getLogger().debug("distribution.{}.gofish", distribution.getName());
List<Artifact> candidateArtifacts = packager.resolveCandidateArtifacts(context, distribution);
if (candidateArtifacts.size() == 0) {
packager.setActive(Active.NEVER);
packager.disable();
return;
} else if (candidateArtifacts.stream().filter(artifact -> isBlank(artifact.getPlatform())).count() > 1) {
errors.configuration(RB.$("validation_packager_multiple_artifacts", "distribution." + distribution.getName() + ".gofish"));
packager.disable();
return;
}
validateCommitAuthor(packager, parentPackager);
Gofish.GofishRepository repository = packager.getRepository();
repository.resolveEnabled(model.getProject());
validateTap(context, distribution, repository, parentPackager.getRepository(), "gofish.repository");
validateTemplate(context, distribution, packager, parentPackager, errors);
mergeExtraProperties(packager, parentPackager);
validateContinueOnError(packager, parentPackager);
if (isBlank(packager.getDownloadUrl())) {
packager.setDownloadUrl(parentPackager.getDownloadUrl());
}
validateArtifactPlatforms(context, distribution, packager, candidateArtifacts, errors);
}
Aggregations