use of org.jreleaser.util.Constants.MAGIC_SET in project jreleaser by jreleaser.
the class SdkmanAnnouncer method announce.
@Override
public void announce() throws AnnounceException {
Map<String, Distribution> distributions = context.getModel().getActiveDistributions().stream().filter(d -> d.getSdkman().isEnabled()).filter(d -> !JReleaserCommand.supportsPublish(context.getCommand()) || d.getSdkman().isPublished()).collect(Collectors.toMap(distribution -> {
Sdkman sdkman = distribution.getSdkman();
return isNotBlank(sdkman.getCandidate()) ? sdkman.getCandidate().trim() : context.getModel().getProject().getName();
}, distribution -> distribution));
Boolean set = (Boolean) context.getModel().getAnnounce().getSdkman().getExtraProperties().remove(MAGIC_SET);
if (distributions.isEmpty()) {
if (set == null || !set) {
announceProject();
} else {
context.getLogger().debug(RB.$("announcers.announcer.disabled"));
}
return;
}
boolean failures = false;
for (Map.Entry<String, Distribution> e : distributions.entrySet()) {
String candidate = e.getKey();
Distribution distribution = e.getValue();
Sdkman sdkman = distribution.getSdkman();
Map<String, Object> props = context.fullProps();
props.putAll(distribution.props());
String releaseNotesUrl = resolveTemplate(sdkman.getReleaseNotesUrl(), props);
String command = sdkman.getCommand().name().toLowerCase();
context.getLogger().info(RB.$("sdkman.release.announce"), command, candidate);
try {
AnnounceSdkmanCommand.builder(context.getLogger()).connectTimeout(sdkman.getConnectTimeout()).readTimeout(sdkman.getReadTimeout()).consumerKey(context.isDryrun() ? "**UNDEFINED**" : sdkman.getResolvedConsumerKey()).consumerToken(context.isDryrun() ? "**UNDEFINED**" : sdkman.getResolvedConsumerToken()).candidate(candidate).version(context.getModel().getProject().getVersion()).releaseNotesUrl(releaseNotesUrl).dryrun(context.isDryrun()).build().execute();
} catch (SdkmanException x) {
context.getLogger().warn(x.getMessage().trim());
failures = true;
}
}
if (failures) {
throw new AnnounceException(RB.$("ERROR_sdkman_announce"));
}
}
Aggregations