use of org.jreleaser.model.Archive in project jreleaser by jreleaser.
the class ArchiveResolver method resolveArchiveOutputs.
private static void resolveArchiveOutputs(JReleaserContext context, Archive archive, Errors errors) {
if (archive.isAttachPlatform() && !context.isPlatformSelected(PlatformUtils.getCurrentFull()))
return;
Path baseOutputDirectory = context.getAssembleDirectory().resolve(archive.getName()).resolve(archive.getType());
String archiveName = archive.getResolvedArchiveName(context);
for (Archive.Format format : archive.getFormats()) {
Path path = baseOutputDirectory.resolve(archiveName + "." + format.extension()).toAbsolutePath();
if (!Files.exists(path)) {
errors.assembly(RB.$("validation_missing_assembly", archive.getType(), archive.getName(), archive.getName()));
} else {
Artifact artifact = Artifact.of(path, archive.isAttachPlatform() ? PlatformUtils.getCurrentFull() : "");
artifact.setExtraProperties(archive.getExtraProperties());
artifact.activate();
archive.addOutput(artifact);
}
}
}
use of org.jreleaser.model.Archive in project jreleaser by jreleaser.
the class ArchiveAssemblerProcessor method doAssemble.
@Override
protected void doAssemble(Map<String, Object> props) throws AssemblerProcessingException {
Path assembleDirectory = (Path) props.get(Constants.KEY_DISTRIBUTION_ASSEMBLE_DIRECTORY);
String archiveName = assembler.getResolvedArchiveName(context);
Path workDirectory = assembleDirectory.resolve("work");
Path archiveDirectory = workDirectory.resolve(archiveName);
try {
FileUtils.deleteFiles(workDirectory);
Files.createDirectories(archiveDirectory);
} catch (IOException e) {
throw new AssemblerProcessingException(RB.$("ERROR_assembler_delete_archive", archiveName), e);
}
// copy fileSets
context.getLogger().debug(RB.$("assembler.copy.files"), context.relativizeToBasedir(archiveDirectory));
copyFileSets(context, archiveDirectory);
// run archive x format
for (Archive.Format format : assembler.getFormats()) {
archive(workDirectory, assembleDirectory, archiveName, format);
}
}
use of org.jreleaser.model.Archive 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());
}
}
Aggregations