use of org.jreleaser.util.Errors in project jreleaser by jreleaser.
the class Validator method checkProperty.
static String checkProperty(JReleaserContext context, String key, String property, String value, Errors errors, boolean dryrun) {
if (isNotBlank(value))
return value;
Environment environment = context.getModel().getEnvironment();
String dsl = context.getConfigurer().toString();
String configFilePath = environment.getPropertiesFile().toAbsolutePath().normalize().toString();
return Env.check(key, environment.getVariable(key), property, dsl, configFilePath, dryrun ? new Errors() : errors);
}
use of org.jreleaser.util.Errors in project jreleaser by jreleaser.
the class ListDiscoMojo 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 SlackValidator method validateSlack.
public static void validateSlack(JReleaserContext context, Slack slack, Errors errors) {
if (!slack.resolveEnabled(context.getModel().getProject()))
return;
context.getLogger().debug("announce.slack");
Errors ignored = new Errors();
slack.setToken(checkProperty(context, SLACK_TOKEN, "slack.token", slack.getToken(), ignored, context.isDryrun()));
slack.setWebhook(checkProperty(context, SLACK_WEBHOOK, "slack.webhook", slack.getWebhook(), ignored, context.isDryrun()));
String token = slack.getResolvedToken();
String webhook = slack.getResolvedWebhook();
if (!context.isDryrun() && isBlank(token) && isBlank(webhook)) {
errors.configuration(RB.$("validation_slack_token"));
return;
}
if (isBlank(slack.getChannel())) {
slack.setChannel("#announce");
}
if (isBlank(slack.getMessage()) && isBlank(slack.getMessageTemplate())) {
if (Files.exists(context.getBasedir().resolve(DEFAULT_SLACK_TPL))) {
slack.setMessageTemplate(DEFAULT_SLACK_TPL);
} else {
slack.setMessage(RB.$("default.release.message"));
}
}
if (isNotBlank(slack.getMessageTemplate()) && !Files.exists(context.getBasedir().resolve(slack.getMessageTemplate().trim()))) {
errors.configuration(RB.$("validation_directory_not_exist", "slack.messageTemplate ", slack.getMessageTemplate()));
}
validateTimeout(slack);
}
use of org.jreleaser.util.Errors in project jreleaser by jreleaser.
the class Validator method checkProperty.
static <T extends Enum<T>> String checkProperty(JReleaserContext context, String key, String property, T value, T defaultValue) {
if (null != value)
return value.name();
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() ? result : (null != defaultValue ? defaultValue.name() : null);
}
use of org.jreleaser.util.Errors in project jreleaser by jreleaser.
the class Validator method checkProperty.
static String checkProperty(JReleaserContext context, String key, String property, String value, String defaultValue) {
if (isNotBlank(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() ? result : defaultValue;
}
Aggregations