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