use of org.jreleaser.model.assembler.spi.AssemblerProcessingException in project jreleaser by jreleaser.
the class Assemblers method assemble.
private static void assemble(JReleaserContext context, Assembler assembler) {
try {
context.getLogger().increaseIndent();
context.getLogger().setPrefix(assembler.getType());
DistributionAssembler processor = createDistributionAssembler(context, assembler);
processor.assemble();
context.getLogger().restorePrefix();
context.getLogger().decreaseIndent();
} catch (AssemblerProcessingException e) {
throw new JReleaserException(e.getMessage(), e);
}
}
use of org.jreleaser.model.assembler.spi.AssemblerProcessingException in project jreleaser by jreleaser.
the class AbstractJavaAssemblerProcessor method copyFiles.
protected Set<Path> copyFiles(JReleaserContext context, Path destination) throws AssemblerProcessingException {
Set<Path> paths = new LinkedHashSet<>();
// resolve all first
for (Glob glob : assembler.getFiles()) {
glob.getResolvedArtifacts(context).stream().map(artifact -> artifact.getResolvedPath(context, assembler)).forEach(paths::add);
}
// copy all next
try {
Files.createDirectories(destination);
for (Path path : paths) {
context.getLogger().debug(RB.$("assembler.copying"), path.getFileName());
Files.copy(path, destination.resolve(path.getFileName()), REPLACE_EXISTING);
}
} catch (IOException e) {
throw new AssemblerProcessingException(RB.$("ERROR_assembler_copying_files"), e);
}
return paths;
}
use of org.jreleaser.model.assembler.spi.AssemblerProcessingException in project jreleaser by jreleaser.
the class AbstractJavaAssemblerProcessor 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);
context.getLogger().debug(RB.$("packager.resolve.templates"), assembler.getType(), assembler.getName());
Map<String, Reader> templates = resolveAndMergeTemplates(context.getLogger(), assembler.getType(), assembler.getType(), context.getModel().getProject().isSnapshot(), context.getBasedir().resolve(getAssembler().getTemplateDirectory()));
for (Map.Entry<String, Reader> entry : templates.entrySet()) {
context.getLogger().debug(RB.$("packager.evaluate.template"), entry.getKey(), assembler.getName(), assembler.getType());
String content = applyTemplate(entry.getValue(), newProps, entry.getKey());
context.getLogger().debug(RB.$("packager.write.template"), entry.getKey(), assembler.getName(), assembler.getType());
writeFile(context.getModel().getProject(), content, newProps, entry.getKey());
}
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 AssemblerUtils method copyJars.
public static Set<Path> copyJars(JReleaserContext context, JavaAssembler assembler, Path jarsDirectory, String platform) throws AssemblerProcessingException {
Set<Path> paths = new LinkedHashSet<>();
// resolve all first
if (isBlank(platform)) {
paths.add(assembler.getMainJar().getEffectivePath(context, assembler));
}
for (Glob glob : assembler.getJars()) {
if ((isBlank(platform) && isBlank(glob.getPlatform())) || (isNotBlank(platform) && PlatformUtils.isCompatible(platform, glob.getPlatform()))) {
glob.getResolvedArtifacts(context).stream().map(artifact -> artifact.getResolvedPath(context, assembler)).forEach(paths::add);
}
}
// copy all next
try {
Files.createDirectories(jarsDirectory);
for (Path path : paths) {
context.getLogger().debug(RB.$("assembler.copying"), path.getFileName());
Files.copy(path, jarsDirectory.resolve(path.getFileName()), REPLACE_EXISTING);
}
} catch (IOException e) {
throw new AssemblerProcessingException(RB.$("ERROR_assembler_copying_jars"), e);
}
return paths;
}
use of org.jreleaser.model.assembler.spi.AssemblerProcessingException in project jreleaser by jreleaser.
the class JlinkAssemblerProcessor method calculateJarPath.
private void calculateJarPath(Path jarsDirectory, String platform, Command cmd, boolean join) throws AssemblerProcessingException {
try {
if (join) {
StringBuilder pathBuilder = new StringBuilder();
String s = listFilesAndProcess(jarsDirectory.resolve("universal"), files -> files.map(jarsDirectory::relativize).map(Object::toString).collect(joining(File.pathSeparator)));
pathBuilder.append(s);
String platformSpecific = listFilesAndProcess(jarsDirectory.resolve(platform), files -> files.map(jarsDirectory::relativize).map(Object::toString).collect(joining(File.pathSeparator)));
if (isNotBlank(platformSpecific)) {
pathBuilder.append(File.pathSeparator).append(platformSpecific);
}
cmd.arg(pathBuilder.toString());
} else {
listFilesAndConsume(jarsDirectory.resolve("universal"), files -> files.map(jarsDirectory::relativize).map(Object::toString).forEach(cmd::arg));
listFilesAndConsume(jarsDirectory.resolve(platform), files -> files.map(jarsDirectory::relativize).map(Object::toString).forEach(cmd::arg));
}
} catch (IOException e) {
throw new AssemblerProcessingException(RB.$("ERROR_assembler_jdeps_error", e.getMessage()));
}
}
Aggregations