Search in sources :

Example 1 with Assembler

use of org.jreleaser.model.Assembler in project jreleaser by jreleaser.

the class Assemblers method assemble.

public static void assemble(JReleaserContext context) {
    Assemble assemble = context.getModel().getAssemble();
    if (!assemble.isEnabled()) {
        context.getLogger().info(RB.$("assemblers.not.enabled"));
        return;
    }
    if (!context.getIncludedAssemblers().isEmpty()) {
        for (String assemblerType : context.getIncludedAssemblers()) {
            // check if the assemblerType is valid
            if (!Assemble.supportedAssemblers().contains(assemblerType)) {
                context.getLogger().warn(RB.$("ERROR_unsupported_assembler", assemblerType));
                continue;
            }
            Map<String, Assembler> assemblers = assemble.findAssemblersByType(assemblerType);
            if (assemblers.isEmpty()) {
                context.getLogger().debug(RB.$("assemblers.no.match"), assemblerType);
                return;
            }
            if (!context.getIncludedDistributions().isEmpty()) {
                for (String distributionName : context.getIncludedDistributions()) {
                    if (!assemblers.containsKey(distributionName)) {
                        context.getLogger().error(RB.$("assemblers.distribution.not.configured"), assemblerType, distributionName);
                        continue;
                    }
                    assemble.findAllAssemblers().stream().filter(a -> distributionName.equals(a.getName())).peek(assembler -> context.getLogger().info(RB.$("assemblers.assemble.distribution.with"), distributionName, assembler.getName())).forEach(assembler -> assemble(context, assembler));
                }
            } else {
                context.getLogger().info(RB.$("assemblers.assemble.all.distributions.with"), assemblerType);
                assemblers.values().forEach(assembler -> assemble(context, assembler));
            }
        }
    } else if (!context.getIncludedDistributions().isEmpty()) {
        for (String distributionName : context.getIncludedDistributions()) {
            context.getLogger().info(RB.$("assemblers.assemble.distribution.with.all"), distributionName);
            assemble.findAllAssemblers().stream().filter(a -> distributionName.equals(a.getName())).forEach(assembler -> assemble(context, assembler));
        }
    } else {
        context.getLogger().info(RB.$("assemblers.assemble.all.distributions"));
        for (Assembler assembler : assemble.findAllAssemblers()) {
            String assemblerType = assembler.getType();
            String distributionName = assembler.getName();
            if (context.getExcludedAssemblers().contains(assemblerType) || context.getExcludedDistributions().contains(distributionName)) {
                context.getLogger().info(RB.$("assemblers.assembler.excluded"), assemblerType, distributionName);
                continue;
            }
            assemble(context, assembler);
        }
    }
}
Also used : Map(java.util.Map) JReleaserContext(org.jreleaser.model.JReleaserContext) JReleaserException(org.jreleaser.util.JReleaserException) Assembler(org.jreleaser.model.Assembler) RB(org.jreleaser.bundle.RB) AssemblerProcessingException(org.jreleaser.model.assembler.spi.AssemblerProcessingException) Assemble(org.jreleaser.model.Assemble) Assemble(org.jreleaser.model.Assemble) Assembler(org.jreleaser.model.Assembler)

Aggregations

Map (java.util.Map)1 RB (org.jreleaser.bundle.RB)1 Assemble (org.jreleaser.model.Assemble)1 Assembler (org.jreleaser.model.Assembler)1 JReleaserContext (org.jreleaser.model.JReleaserContext)1 AssemblerProcessingException (org.jreleaser.model.assembler.spi.AssemblerProcessingException)1 JReleaserException (org.jreleaser.util.JReleaserException)1