use of org.jreleaser.model.JavaAssembler 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;
}
Aggregations