Search in sources :

Example 1 with JavaAssembler

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;
}
Also used : Path(java.nio.file.Path) LinkedHashSet(java.util.LinkedHashSet) JavaAssembler(org.jreleaser.model.JavaAssembler) Properties(java.util.Properties) Files(java.nio.file.Files) Set(java.util.Set) StringUtils.isBlank(org.jreleaser.util.StringUtils.isBlank) IOException(java.io.IOException) PlatformUtils(org.jreleaser.util.PlatformUtils) File(java.io.File) StringUtils.isNotBlank(org.jreleaser.util.StringUtils.isNotBlank) Glob(org.jreleaser.model.Glob) Paths(java.nio.file.Paths) JReleaserContext(org.jreleaser.model.JReleaserContext) RB(org.jreleaser.bundle.RB) Path(java.nio.file.Path) REPLACE_EXISTING(java.nio.file.StandardCopyOption.REPLACE_EXISTING) AssemblerProcessingException(org.jreleaser.model.assembler.spi.AssemblerProcessingException) LinkedHashSet(java.util.LinkedHashSet) AssemblerProcessingException(org.jreleaser.model.assembler.spi.AssemblerProcessingException) Glob(org.jreleaser.model.Glob) IOException(java.io.IOException)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 Files (java.nio.file.Files)1 Path (java.nio.file.Path)1 Paths (java.nio.file.Paths)1 REPLACE_EXISTING (java.nio.file.StandardCopyOption.REPLACE_EXISTING)1 LinkedHashSet (java.util.LinkedHashSet)1 Properties (java.util.Properties)1 Set (java.util.Set)1 RB (org.jreleaser.bundle.RB)1 Glob (org.jreleaser.model.Glob)1 JReleaserContext (org.jreleaser.model.JReleaserContext)1 JavaAssembler (org.jreleaser.model.JavaAssembler)1 AssemblerProcessingException (org.jreleaser.model.assembler.spi.AssemblerProcessingException)1 PlatformUtils (org.jreleaser.util.PlatformUtils)1 StringUtils.isBlank (org.jreleaser.util.StringUtils.isBlank)1 StringUtils.isNotBlank (org.jreleaser.util.StringUtils.isNotBlank)1