Search in sources :

Example 1 with Archive

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);
        }
    }
}
Also used : Path(java.nio.file.Path) Archive(org.jreleaser.model.Archive) Artifact(org.jreleaser.model.Artifact)

Example 2 with Archive

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);
    }
}
Also used : Path(java.nio.file.Path) Archive(org.jreleaser.model.Archive) AssemblerProcessingException(org.jreleaser.model.assembler.spi.AssemblerProcessingException) IOException(java.io.IOException)

Example 3 with Archive

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());
    }
}
Also used : JpackageValidator.validateJpackage(org.jreleaser.model.validation.JpackageValidator.validateJpackage) Jpackage(org.jreleaser.model.Jpackage) JpackageValidator.postValidateJpackage(org.jreleaser.model.validation.JpackageValidator.postValidateJpackage) Jlink(org.jreleaser.model.Jlink) JlinkValidator.validateJlink(org.jreleaser.model.validation.JlinkValidator.validateJlink) Archive(org.jreleaser.model.Archive) ArchiveValidator.validateArchive(org.jreleaser.model.validation.ArchiveValidator.validateArchive) NativeImageValidator.validateNativeImage(org.jreleaser.model.validation.NativeImageValidator.validateNativeImage) NativeImage(org.jreleaser.model.NativeImage) Assemble(org.jreleaser.model.Assemble) ArrayList(java.util.ArrayList) List(java.util.List) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

Archive (org.jreleaser.model.Archive)3 Path (java.nio.file.Path)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Artifact (org.jreleaser.model.Artifact)1 Assemble (org.jreleaser.model.Assemble)1 Jlink (org.jreleaser.model.Jlink)1 Jpackage (org.jreleaser.model.Jpackage)1 NativeImage (org.jreleaser.model.NativeImage)1 AssemblerProcessingException (org.jreleaser.model.assembler.spi.AssemblerProcessingException)1 ArchiveValidator.validateArchive (org.jreleaser.model.validation.ArchiveValidator.validateArchive)1 JlinkValidator.validateJlink (org.jreleaser.model.validation.JlinkValidator.validateJlink)1 JpackageValidator.postValidateJpackage (org.jreleaser.model.validation.JpackageValidator.postValidateJpackage)1 JpackageValidator.validateJpackage (org.jreleaser.model.validation.JpackageValidator.validateJpackage)1 NativeImageValidator.validateNativeImage (org.jreleaser.model.validation.NativeImageValidator.validateNativeImage)1