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);
}
}
}
Aggregations