Search in sources :

Example 11 with AssemblerProcessingException

use of org.jreleaser.model.assembler.spi.AssemblerProcessingException in project jreleaser by jreleaser.

the class AbstractAssemblerProcessor method writeFile.

protected void writeFile(String content, Path outputFile) throws AssemblerProcessingException {
    try {
        createDirectoriesWithFullAccess(outputFile.getParent());
        Files.write(outputFile, content.getBytes(), CREATE, WRITE, TRUNCATE_EXISTING);
        grantFullAccess(outputFile);
    } catch (IOException e) {
        throw new AssemblerProcessingException(RB.$("ERROR_unexpected_error_writing_file", outputFile.toAbsolutePath()), e);
    }
}
Also used : AssemblerProcessingException(org.jreleaser.model.assembler.spi.AssemblerProcessingException) IOException(java.io.IOException)

Example 12 with AssemblerProcessingException

use of org.jreleaser.model.assembler.spi.AssemblerProcessingException in project jreleaser by jreleaser.

the class AbstractAssemblerProcessor method assemble.

@Override
public void assemble(Map<String, Object> props) throws AssemblerProcessingException {
    try {
        context.getLogger().debug(RB.$("packager.create.properties"), assembler.getType(), assembler.getName());
        Map<String, Object> newProps = fillProps(props);
        Path assembleDirectory = (Path) props.get(Constants.KEY_DISTRIBUTION_ASSEMBLE_DIRECTORY);
        Files.createDirectories(assembleDirectory);
        doAssemble(newProps);
    } catch (IllegalArgumentException | IOException e) {
        throw new AssemblerProcessingException(e);
    }
}
Also used : Path(java.nio.file.Path) AssemblerProcessingException(org.jreleaser.model.assembler.spi.AssemblerProcessingException) IOException(java.io.IOException)

Example 13 with AssemblerProcessingException

use of org.jreleaser.model.assembler.spi.AssemblerProcessingException in project jreleaser by jreleaser.

the class AbstractAssemblerProcessor method copyFileSets.

protected void copyFileSets(JReleaserContext context, Path destination) throws AssemblerProcessingException {
    try {
        for (FileSet fileSet : assembler.getFileSets()) {
            Path src = context.getBasedir().resolve(fileSet.getResolvedInput(context));
            Path dest = destination;
            String output = fileSet.getResolvedOutput(context);
            if (isNotBlank(output)) {
                dest = destination.resolve(output);
            }
            Set<Path> paths = fileSet.getResolvedPaths(context);
            FileUtils.copyFiles(context.getLogger(), src, dest, paths);
        }
    } catch (IOException e) {
        throw new AssemblerProcessingException(RB.$("ERROR_assembler_copying_files"), e);
    }
}
Also used : Path(java.nio.file.Path) FileSet(org.jreleaser.model.FileSet) AssemblerProcessingException(org.jreleaser.model.assembler.spi.AssemblerProcessingException) IOException(java.io.IOException)

Example 14 with AssemblerProcessingException

use of org.jreleaser.model.assembler.spi.AssemblerProcessingException in project jreleaser by jreleaser.

the class ArchiveAssemblerProcessor method archive.

private void archive(Path workDirectory, Path assembleDirectory, String archiveName, Archive.Format format) throws AssemblerProcessingException {
    String finalArchiveName = archiveName + "." + format.extension();
    context.getLogger().info("- {}", finalArchiveName);
    try {
        Path archiveFile = assembleDirectory.resolve(finalArchiveName);
        switch(format) {
            case ZIP:
                FileUtils.zip(workDirectory, archiveFile);
                break;
            case TAR:
                FileUtils.tar(workDirectory, archiveFile);
                break;
            case TGZ:
            case TAR_GZ:
                FileUtils.tgz(workDirectory, archiveFile);
                break;
            case TXZ:
            case TAR_XZ:
                FileUtils.xz(workDirectory, archiveFile);
                break;
            case TBZ2:
            case TAR_BZ2:
                FileUtils.bz2(workDirectory, archiveFile);
        }
    } catch (IOException e) {
        throw new AssemblerProcessingException(RB.$("ERROR_unexpected_error"), e);
    }
}
Also used : Path(java.nio.file.Path) AssemblerProcessingException(org.jreleaser.model.assembler.spi.AssemblerProcessingException) IOException(java.io.IOException)

Example 15 with AssemblerProcessingException

use of org.jreleaser.model.assembler.spi.AssemblerProcessingException 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)

Aggregations

AssemblerProcessingException (org.jreleaser.model.assembler.spi.AssemblerProcessingException)23 IOException (java.io.IOException)18 Path (java.nio.file.Path)18 Command (org.jreleaser.util.command.Command)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 Properties (java.util.Properties)3 Artifact (org.jreleaser.model.Artifact)3 Reader (java.io.Reader)2 Files (java.nio.file.Files)2 REPLACE_EXISTING (java.nio.file.StandardCopyOption.REPLACE_EXISTING)2 LinkedHashSet (java.util.LinkedHashSet)2 Map (java.util.Map)2 Set (java.util.Set)2 RB (org.jreleaser.bundle.RB)2 Archive (org.jreleaser.model.Archive)2 Glob (org.jreleaser.model.Glob)2 JReleaserContext (org.jreleaser.model.JReleaserContext)2 JavaAssembler (org.jreleaser.model.JavaAssembler)2 Jpackage (org.jreleaser.model.Jpackage)2 SemVer (org.jreleaser.util.SemVer)2