Search in sources :

Example 1 with Announcer

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);
    }
}
Also used : Announcer(org.jreleaser.model.announcer.spi.Announcer) TreeMap(java.util.TreeMap) Map(java.util.Map)

Example 2 with 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;
}
Also used : Announcer(org.jreleaser.model.announcer.spi.Announcer) JReleaserModel(org.jreleaser.model.JReleaserModel) AnnouncerBuilder(org.jreleaser.model.announcer.spi.AnnouncerBuilder) TreeMap(java.util.TreeMap) AnnouncerBuilderFactory(org.jreleaser.model.announcer.spi.AnnouncerBuilderFactory)

Aggregations

TreeMap (java.util.TreeMap)2 Announcer (org.jreleaser.model.announcer.spi.Announcer)2 Map (java.util.Map)1 JReleaserModel (org.jreleaser.model.JReleaserModel)1 AnnouncerBuilder (org.jreleaser.model.announcer.spi.AnnouncerBuilder)1 AnnouncerBuilderFactory (org.jreleaser.model.announcer.spi.AnnouncerBuilderFactory)1