use of org.jreleaser.model.announcer.spi.Announcer in project jreleaser by jreleaser.
the class Announcers method announce.
public static void announce(JReleaserContext context) throws AnnounceException {
context.getLogger().info(RB.$("announcers.header"));
if (!context.getModel().getAnnounce().isEnabled()) {
context.getLogger().info(RB.$("announcers.not.enabled"));
return;
}
Map<String, Announcer> announcers = Announcers.findAnnouncers(context);
if (announcers.isEmpty()) {
context.getLogger().info(RB.$("announcers.not.configured"));
return;
}
if (!context.getIncludedAnnouncers().isEmpty()) {
for (String announcerName : context.getIncludedAnnouncers()) {
// check if the announcer name is valid
if (!Announce.supportedAnnouncers().contains(announcerName)) {
context.getLogger().warn(RB.$("ERROR_unsupported_announcer", announcerName));
continue;
}
Announcer announcer = announcers.get(announcerName);
if (null == announcer) {
context.getLogger().warn(RB.$("announcers.announcer.not.found"), announcerName);
continue;
}
if (!announcer.isEnabled()) {
context.getLogger().warn(RB.$("announcers.announcer.not.enabled"), announcerName);
continue;
}
announce(context, announcer);
}
return;
}
for (Map.Entry<String, Announcer> entry : announcers.entrySet()) {
Announcer announcer = entry.getValue();
if (context.getExcludedAnnouncers().contains(announcer.getName())) {
context.getLogger().info(RB.$("announcers.announcer.excluded"), announcer.getName());
continue;
}
announce(context, announcer);
}
}
use of org.jreleaser.model.announcer.spi.Announcer in project jreleaser by jreleaser.
the class Announcers method findAnnouncers.
private static Map<String, Announcer> findAnnouncers(JReleaserContext context) {
JReleaserModel model = context.getModel();
Map<String, AnnouncerBuilder> builders = StreamSupport.stream(ServiceLoader.load(AnnouncerBuilderFactory.class, Announcers.class.getClassLoader()).spliterator(), false).collect(Collectors.toMap(AnnouncerBuilderFactory::getName, AnnouncerBuilderFactory::getBuilder));
Map<String, Announcer> announcers = new TreeMap<>();
builders.forEach((name, builder) -> {
if (null != model.getAnnounce().findAnnouncer(name) && !context.getExcludedAnnouncers().contains(name)) {
announcers.put(name, builder.configureWith(context).build());
}
});
return announcers;
}
Aggregations