use of org.jreleaser.model.Assemble in project jreleaser by jreleaser.
the class AssemblersValidator method validateAssemblers.
public static void validateAssemblers(JReleaserContext context, JReleaserContext.Mode mode, Errors errors) {
if (mode == JReleaserContext.Mode.CHANGELOG) {
return;
}
context.getLogger().debug("assemble");
Assemble assemble = context.getModel().getAssemble();
validateArchive(context, mode, errors);
validateJlink(context, mode, errors);
validateJpackage(context, mode, errors);
validateNativeImage(context, mode, errors);
// validate unique distribution names between exported assemblers
Map<String, List<String>> byDistributionName = new LinkedHashMap<>();
for (Archive archive : assemble.getActiveArchives()) {
List<String> types = byDistributionName.computeIfAbsent(archive.getName(), k -> new ArrayList<>());
types.add(archive.getType());
}
for (Jlink jlink : assemble.getActiveJlinks()) {
List<String> types = byDistributionName.computeIfAbsent(jlink.getName(), k -> new ArrayList<>());
if (jlink.isExported())
types.add(jlink.getType());
}
for (Jpackage jpackage : assemble.getActiveJpackages()) {
List<String> types = byDistributionName.computeIfAbsent(jpackage.getName(), k -> new ArrayList<>());
if (jpackage.isExported())
types.add(jpackage.getType());
}
for (NativeImage nativeImage : assemble.getActiveNativeImages()) {
List<String> types = byDistributionName.computeIfAbsent(nativeImage.getName(), k -> new ArrayList<>());
if (nativeImage.isExported())
types.add(nativeImage.getType());
}
byDistributionName.forEach((name, types) -> {
if (types.size() > 1) {
errors.configuration(RB.$("validation_multiple_assemblers", "distribution." + name, types));
assemble.setEnabled(false);
}
});
if (!assemble.isEnabledSet()) {
assemble.setEnabled(!assemble.getActiveArchives().isEmpty() || !assemble.getActiveJlinks().isEmpty() || !assemble.getActiveJpackages().isEmpty() || !assemble.getActiveNativeImages().isEmpty());
}
}
use of org.jreleaser.model.Assemble 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