Search in sources :

Example 6 with RB

use of org.jreleaser.bundle.RB 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)

Example 7 with RB

use of org.jreleaser.bundle.RB in project jreleaser by jreleaser.

the class ClientUtils method builder.

public static Feign.Builder builder(JReleaserLogger logger, int connectTimeout, int readTimeout) {
    requireNonNull(logger, "'logger' must not be null");
    Feign.Builder builder = Feign.builder();
    if (Boolean.getBoolean("jreleaser.disableSslValidation")) {
        logger.warn(RB.$("warn_ssl_disabled"));
        builder = builder.client(new Client.Default(nonValidatingSSLSocketFactory(), new NonValidatingHostnameVerifier()));
    }
    return builder.encoder(new FormEncoder(new JacksonEncoder())).decoder(new JacksonDecoder()).requestInterceptor(template -> template.header("User-Agent", "JReleaser/" + JReleaserVersion.getPlainVersion())).errorDecoder((methodKey, response) -> new RestAPIException(response.request(), response.status(), response.reason(), response.headers())).options(new Request.Options(connectTimeout, TimeUnit.SECONDS, readTimeout, TimeUnit.SECONDS, true));
}
Also used : JReleaserModelPrinter(org.jreleaser.model.JReleaserModelPrinter) HttpURLConnection(java.net.HttpURLConnection) X509Certificate(java.security.cert.X509Certificate) SSLContext(javax.net.ssl.SSLContext) URL(java.net.URL) TrustManager(javax.net.ssl.TrustManager) Client(feign.Client) MediaType(org.apache.tika.mime.MediaType) StringUtils.isNotBlank(org.jreleaser.util.StringUtils.isNotBlank) JReleaserLogger(org.jreleaser.util.JReleaserLogger) UploadException(org.jreleaser.model.uploader.spi.UploadException) SSLSession(javax.net.ssl.SSLSession) Map(java.util.Map) Objects.requireNonNull(java.util.Objects.requireNonNull) JacksonDecoder(feign.jackson.JacksonDecoder) HostnameVerifier(javax.net.ssl.HostnameVerifier) Path(java.nio.file.Path) OutputStream(java.io.OutputStream) Constants(org.jreleaser.util.Constants) Files(java.nio.file.Files) UTF_8(java.nio.charset.StandardCharsets.UTF_8) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) FormEncoder(feign.form.FormEncoder) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) IOException(java.io.IOException) Reader(java.io.Reader) Feign(feign.Feign) InputStreamReader(java.io.InputStreamReader) SSLSocketFactory(javax.net.ssl.SSLSocketFactory) TimeUnit(java.util.concurrent.TimeUnit) IOUtils(org.apache.commons.io.IOUtils) AnnounceException(org.jreleaser.model.announcer.spi.AnnounceException) JReleaserVersion(org.jreleaser.model.JReleaserVersion) JacksonEncoder(feign.jackson.JacksonEncoder) X509TrustManager(javax.net.ssl.X509TrustManager) FormData(feign.form.FormData) Tika(org.apache.tika.Tika) Request(feign.Request) RB(org.jreleaser.bundle.RB) Feign(feign.Feign) Request(feign.Request) JacksonEncoder(feign.jackson.JacksonEncoder) FormEncoder(feign.form.FormEncoder) JacksonDecoder(feign.jackson.JacksonDecoder)

Example 8 with RB

use of org.jreleaser.bundle.RB in project jreleaser by jreleaser.

the class SdkmanAnnouncer method announce.

@Override
public void announce() throws AnnounceException {
    Map<String, Distribution> distributions = context.getModel().getActiveDistributions().stream().filter(d -> d.getSdkman().isEnabled()).filter(d -> !JReleaserCommand.supportsPublish(context.getCommand()) || d.getSdkman().isPublished()).collect(Collectors.toMap(distribution -> {
        Sdkman sdkman = distribution.getSdkman();
        return isNotBlank(sdkman.getCandidate()) ? sdkman.getCandidate().trim() : context.getModel().getProject().getName();
    }, distribution -> distribution));
    Boolean set = (Boolean) context.getModel().getAnnounce().getSdkman().getExtraProperties().remove(MAGIC_SET);
    if (distributions.isEmpty()) {
        if (set == null || !set) {
            announceProject();
        } else {
            context.getLogger().debug(RB.$("announcers.announcer.disabled"));
        }
        return;
    }
    boolean failures = false;
    for (Map.Entry<String, Distribution> e : distributions.entrySet()) {
        String candidate = e.getKey();
        Distribution distribution = e.getValue();
        Sdkman sdkman = distribution.getSdkman();
        Map<String, Object> props = context.fullProps();
        props.putAll(distribution.props());
        String releaseNotesUrl = resolveTemplate(sdkman.getReleaseNotesUrl(), props);
        String command = sdkman.getCommand().name().toLowerCase();
        context.getLogger().info(RB.$("sdkman.release.announce"), command, candidate);
        try {
            AnnounceSdkmanCommand.builder(context.getLogger()).connectTimeout(sdkman.getConnectTimeout()).readTimeout(sdkman.getReadTimeout()).consumerKey(context.isDryrun() ? "**UNDEFINED**" : sdkman.getResolvedConsumerKey()).consumerToken(context.isDryrun() ? "**UNDEFINED**" : sdkman.getResolvedConsumerToken()).candidate(candidate).version(context.getModel().getProject().getVersion()).releaseNotesUrl(releaseNotesUrl).dryrun(context.isDryrun()).build().execute();
        } catch (SdkmanException x) {
            context.getLogger().warn(x.getMessage().trim());
            failures = true;
        }
    }
    if (failures) {
        throw new AnnounceException(RB.$("ERROR_sdkman_announce"));
    }
}
Also used : StringUtils.isTrue(org.jreleaser.util.StringUtils.isTrue) Sdkman(org.jreleaser.model.Sdkman) Collectors(java.util.stream.Collectors) StringUtils.isNotBlank(org.jreleaser.util.StringUtils.isNotBlank) LinkedHashMap(java.util.LinkedHashMap) AnnounceException(org.jreleaser.model.announcer.spi.AnnounceException) Announcer(org.jreleaser.model.announcer.spi.Announcer) JReleaserCommand(org.jreleaser.model.JReleaserCommand) Map(java.util.Map) MAGIC_SET(org.jreleaser.util.Constants.MAGIC_SET) JReleaserContext(org.jreleaser.model.JReleaserContext) SdkmanHelper.collectArtifacts(org.jreleaser.model.util.SdkmanHelper.collectArtifacts) Distribution(org.jreleaser.model.Distribution) RB(org.jreleaser.bundle.RB) Templates.resolveTemplate(org.jreleaser.util.Templates.resolveTemplate) AnnounceException(org.jreleaser.model.announcer.spi.AnnounceException) Sdkman(org.jreleaser.model.Sdkman) Distribution(org.jreleaser.model.Distribution) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 9 with RB

use of org.jreleaser.bundle.RB in project jreleaser by jreleaser.

the class AbstractPackagerProcessor method verifyAndAddArtifacts.

protected boolean verifyAndAddArtifacts(Map<String, Object> props, Distribution distribution, List<Artifact> artifacts) throws PackagerProcessingException {
    List<Artifact> activeArtifacts = artifacts.stream().filter(Artifact::isActive).collect(Collectors.toList());
    if (activeArtifacts.size() == 0) {
        // we can't proceed
        context.getLogger().warn(RB.$("packager.no.matching.artifacts"), distribution.getName(), capitalize(packager.getType()));
        return false;
    }
    int count = 0;
    for (Artifact artifact : activeArtifacts) {
        String artifactUrl = Artifacts.resolveDownloadUrl(context, packager.getType(), distribution, artifact);
        if (isBlank(artifactUrl))
            continue;
        count++;
        String platform = artifact.getPlatform();
        String artifactPlatform = isNotBlank(platform) ? capitalize(platform) : "";
        String platformReplaced = distribution.getPlatform().applyReplacements(platform);
        String artifactPlatformReplaced = isNotBlank(platformReplaced) ? capitalize(platformReplaced) : "";
        // add extra properties without clobbering existing keys
        Map<String, Object> artifactProps = artifact.getResolvedExtraProperties(ARTIFACT + artifactPlatform);
        artifactProps.keySet().stream().filter(k -> !props.containsKey(k)).forEach(k -> props.put(k, artifactProps.get(k)));
        Path artifactPath = artifact.getEffectivePath(context, distribution);
        long artifactSize = 0;
        try {
            artifactSize = Files.size(artifactPath);
        } catch (IOException ignored) {
            // this would be strange
            context.getLogger().trace(ignored);
        }
        String artifactFile = artifact.getEffectivePath().getFileName().toString();
        String artifactFileName = getFilename(artifactFile, FileType.getSupportedExtensions());
        String artifactFileExtension = artifactFile.substring(artifactFileName.length());
        String artifactFileFormat = artifactFileExtension.substring(1);
        String artifactName = "";
        String artifactVersion = "";
        String projectVersion = context.getModel().getProject().getEffectiveVersion();
        if (isNotBlank(projectVersion) && artifactFileName.contains(projectVersion)) {
            artifactName = artifactFileName.substring(0, artifactFileName.indexOf(projectVersion));
            if (artifactName.endsWith("-")) {
                artifactName = artifactName.substring(0, artifactName.length() - 1);
            }
            artifactVersion = projectVersion;
        }
        projectVersion = context.getModel().getProject().getVersion();
        if (isBlank(artifactName) && isNotBlank(projectVersion) && artifactFileName.contains(projectVersion)) {
            artifactName = artifactFileName.substring(0, artifactFileName.indexOf(projectVersion));
            if (artifactName.endsWith("-")) {
                artifactName = artifactName.substring(0, artifactName.length() - 1);
            }
            artifactVersion = projectVersion;
        }
        String artifactOs = "";
        String artifactArch = "";
        if (isNotBlank(platform)) {
            if (platform.contains("-")) {
                String[] parts = platform.split("-");
                artifactOs = parts[0];
                artifactArch = parts[1];
            }
        }
        safePut(props, ARTIFACT + artifactPlatform + NAME, artifactName);
        safePut(props, ARTIFACT + artifactPlatform + VERSION, artifactVersion);
        safePut(props, ARTIFACT + artifactPlatform + OS, artifactOs);
        safePut(props, ARTIFACT + artifactPlatform + ARCH, artifactArch);
        safePut(props, ARTIFACT + artifactPlatform + FILE, artifactFile);
        safePut(props, ARTIFACT + artifactPlatform + SIZE, artifactSize);
        safePut(props, ARTIFACT + artifactPlatform + FILE_NAME, artifactFileName);
        safePut(props, ARTIFACT + artifactPlatform + FILE_EXTENSION, artifactFileExtension);
        safePut(props, ARTIFACT + artifactPlatform + FILE_FORMAT, artifactFileFormat);
        safePut(props, ARTIFACT + artifactPlatformReplaced + NAME, artifactName);
        safePut(props, ARTIFACT + artifactPlatformReplaced + VERSION, artifactVersion);
        safePut(props, ARTIFACT + artifactPlatformReplaced + OS, artifactOs);
        safePut(props, ARTIFACT + artifactPlatformReplaced + ARCH, artifactArch);
        safePut(props, ARTIFACT + artifactPlatformReplaced + FILE, artifactFile);
        safePut(props, ARTIFACT + artifactPlatformReplaced + SIZE, artifactSize);
        safePut(props, ARTIFACT + artifactPlatformReplaced + FILE_NAME, artifactFileName);
        safePut(props, ARTIFACT + artifactPlatformReplaced + FILE_EXTENSION, artifactFileExtension);
        safePut(props, ARTIFACT + artifactPlatformReplaced + FILE_FORMAT, artifactFileFormat);
        for (Algorithm algorithm : context.getModel().getChecksum().getAlgorithms()) {
            safePut(props, ARTIFACT + artifactPlatform + CHECKSUM + capitalize(algorithm.formatted()), artifact.getHash(algorithm));
            safePut(props, ARTIFACT + artifactPlatformReplaced + CHECKSUM + capitalize(algorithm.formatted()), artifact.getHash(algorithm));
        }
        safePut(props, ARTIFACT + artifactPlatform + URL, artifactUrl);
        safePut(props, ARTIFACT + artifactPlatformReplaced + URL, artifactUrl);
        props.putAll(context.getModel().getUpload().resolveDownloadUrls(context, distribution, artifact, ARTIFACT + artifactPlatform));
        props.putAll(context.getModel().getUpload().resolveDownloadUrls(context, distribution, artifact, ARTIFACT + artifactPlatformReplaced));
        if (count == 1) {
            props.putAll(context.getModel().getUpload().resolveDownloadUrls(context, distribution, artifact, DISTRIBUTION));
            safePut(props, KEY_DISTRIBUTION_ARTIFACT, artifact);
            safePut(props, KEY_DISTRIBUTION_URL, artifactUrl);
            safePut(props, KEY_DISTRIBUTION_SIZE, artifactSize);
            safePut(props, KEY_DISTRIBUTION_SHA_256, artifact.getHash(Algorithm.SHA_256));
            for (Algorithm algorithm : context.getModel().getChecksum().getAlgorithms()) {
                safePut(props, DISTRIBUTION + CHECKSUM + capitalize(algorithm.formatted()), artifact.getHash(algorithm));
            }
            safePut(props, KEY_DISTRIBUTION_ARTIFACT_PLATFORM, platform);
            safePut(props, KEY_DISTRIBUTION_ARTIFACT_PLATFORM_REPLACED, platformReplaced);
            safePut(props, KEY_DISTRIBUTION_ARTIFACT_NAME, artifactName);
            safePut(props, KEY_DISTRIBUTION_ARTIFACT_VERSION, artifactVersion);
            safePut(props, KEY_DISTRIBUTION_ARTIFACT_OS, artifactOs);
            safePut(props, KEY_DISTRIBUTION_ARTIFACT_ARCH, artifactArch);
            safePut(props, KEY_DISTRIBUTION_ARTIFACT_SIZE, artifactSize);
            safePut(props, KEY_DISTRIBUTION_ARTIFACT_FILE, artifactFile);
            safePut(props, KEY_DISTRIBUTION_ARTIFACT_FILE_NAME, artifactFileName);
            safePut(props, KEY_DISTRIBUTION_ARTIFACT_FILE_EXTENSION, artifactFileExtension);
            safePut(props, KEY_DISTRIBUTION_ARTIFACT_FILE_FORMAT, artifactFileFormat);
            safePut(props, KEY_ARTIFACT_PLATFORM, platform);
            safePut(props, KEY_ARTIFACT_PLATFORM_REPLACED, platformReplaced);
            safePut(props, KEY_ARTIFACT_NAME, artifactName);
            safePut(props, KEY_ARTIFACT_VERSION, artifactVersion);
            safePut(props, KEY_ARTIFACT_OS, artifactOs);
            safePut(props, KEY_ARTIFACT_ARCH, artifactArch);
            safePut(props, KEY_ARTIFACT_SIZE, artifactSize);
            safePut(props, KEY_ARTIFACT_FILE, artifactFile);
            safePut(props, KEY_ARTIFACT_FILE_NAME, artifactFileName);
            safePut(props, KEY_ARTIFACT_FILE_EXTENSION, artifactFileExtension);
            safePut(props, KEY_ARTIFACT_FILE_FORMAT, artifactFileFormat);
            // add extra properties without clobbering existing keys
            Map<String, Object> aprops = artifact.getResolvedExtraProperties();
            Map<String, Object> bprops = new LinkedHashMap<>(aprops);
            applyTemplates(aprops, bprops);
            aprops.keySet().stream().filter(k -> !props.containsKey(k)).forEach(k -> props.put(k, aprops.get(k)));
        }
    }
    return count > 0;
}
Also used : KEY_DISTRIBUTION_ARTIFACT_FILE(org.jreleaser.util.Constants.KEY_DISTRIBUTION_ARTIFACT_FILE) KEY_ARTIFACT_OS(org.jreleaser.util.Constants.KEY_ARTIFACT_OS) KEY_REVERSE_REPO_HOST(org.jreleaser.util.Constants.KEY_REVERSE_REPO_HOST) Arrays(java.util.Arrays) CommandExecutor(org.jreleaser.util.command.CommandExecutor) KEY_DISTRIBUTION_URL(org.jreleaser.util.Constants.KEY_DISTRIBUTION_URL) KEY_ARTIFACT_FILE_EXTENSION(org.jreleaser.util.Constants.KEY_ARTIFACT_FILE_EXTENSION) KEY_DISTRIBUTION_ARTIFACT_FILE_EXTENSION(org.jreleaser.util.Constants.KEY_DISTRIBUTION_ARTIFACT_FILE_EXTENSION) KEY_DISTRIBUTION_ARTIFACT_SIZE(org.jreleaser.util.Constants.KEY_DISTRIBUTION_ARTIFACT_SIZE) KEY_DISTRIBUTION_ARTIFACT_FILE_NAME(org.jreleaser.util.Constants.KEY_DISTRIBUTION_ARTIFACT_FILE_NAME) StringUtils.isNotBlank(org.jreleaser.util.StringUtils.isNotBlank) Map(java.util.Map) Path(java.nio.file.Path) KEY_DISTRIBUTION_SIZE(org.jreleaser.util.Constants.KEY_DISTRIBUTION_SIZE) KEY_DISTRIBUTION_ARTIFACT_PLATFORM(org.jreleaser.util.Constants.KEY_DISTRIBUTION_ARTIFACT_PLATFORM) KEY_ARTIFACT_FILE(org.jreleaser.util.Constants.KEY_ARTIFACT_FILE) KEY_ARTIFACT_FILE_FORMAT(org.jreleaser.util.Constants.KEY_ARTIFACT_FILE_FORMAT) KEY_DISTRIBUTION_ARTIFACT(org.jreleaser.util.Constants.KEY_DISTRIBUTION_ARTIFACT) Packager(org.jreleaser.model.Packager) KEY_ARTIFACT_SIZE(org.jreleaser.util.Constants.KEY_ARTIFACT_SIZE) Collectors(java.util.stream.Collectors) KEY_ARTIFACT_VERSION(org.jreleaser.util.Constants.KEY_ARTIFACT_VERSION) List(java.util.List) KEY_DISTRIBUTION_ARTIFACT_VERSION(org.jreleaser.util.Constants.KEY_DISTRIBUTION_ARTIFACT_VERSION) CommandException(org.jreleaser.util.command.CommandException) KEY_DISTRIBUTION_PREPARE_DIRECTORY(org.jreleaser.util.Constants.KEY_DISTRIBUTION_PREPARE_DIRECTORY) KEY_ARTIFACT_NAME(org.jreleaser.util.Constants.KEY_ARTIFACT_NAME) Command(org.jreleaser.util.command.Command) KEY_DISTRIBUTION_ARTIFACT_NAME(org.jreleaser.util.Constants.KEY_DISTRIBUTION_ARTIFACT_NAME) RB(org.jreleaser.bundle.RB) Artifacts(org.jreleaser.model.util.Artifacts) FileUtils(org.jreleaser.util.FileUtils) Artifact(org.jreleaser.model.Artifact) ByteArrayOutputStream(java.io.ByteArrayOutputStream) PackagerProcessingException(org.jreleaser.model.packager.spi.PackagerProcessingException) KEY_ARTIFACT_FILE_NAME(org.jreleaser.util.Constants.KEY_ARTIFACT_FILE_NAME) StringUtils.isBlank(org.jreleaser.util.StringUtils.isBlank) MustacheUtils.applyTemplates(org.jreleaser.util.MustacheUtils.applyTemplates) LinkedHashMap(java.util.LinkedHashMap) StringUtils.getFilename(org.jreleaser.util.StringUtils.getFilename) KEY_ARTIFACT_PLATFORM(org.jreleaser.util.Constants.KEY_ARTIFACT_PLATFORM) KEY_DISTRIBUTION_ARTIFACT_PLATFORM_REPLACED(org.jreleaser.util.Constants.KEY_DISTRIBUTION_ARTIFACT_PLATFORM_REPLACED) JReleaserContext(org.jreleaser.model.JReleaserContext) StringUtils.capitalize(org.jreleaser.util.StringUtils.capitalize) KEY_DISTRIBUTION_ARTIFACT_FILE_FORMAT(org.jreleaser.util.Constants.KEY_DISTRIBUTION_ARTIFACT_FILE_FORMAT) KEY_DISTRIBUTION_PACKAGE_DIRECTORY(org.jreleaser.util.Constants.KEY_DISTRIBUTION_PACKAGE_DIRECTORY) KEY_DISTRIBUTION_ARTIFACT_OS(org.jreleaser.util.Constants.KEY_DISTRIBUTION_ARTIFACT_OS) Distribution(org.jreleaser.model.Distribution) OutputStream(java.io.OutputStream) FileType(org.jreleaser.util.FileType) KEY_ARTIFACT_PLATFORM_REPLACED(org.jreleaser.util.Constants.KEY_ARTIFACT_PLATFORM_REPLACED) KEY_DISTRIBUTION_ARTIFACT_ARCH(org.jreleaser.util.Constants.KEY_DISTRIBUTION_ARTIFACT_ARCH) Files(java.nio.file.Files) Algorithm(org.jreleaser.util.Algorithm) IOException(java.io.IOException) Consumer(java.util.function.Consumer) KEY_DISTRIBUTION_SHA_256(org.jreleaser.util.Constants.KEY_DISTRIBUTION_SHA_256) KEY_ARTIFACT_ARCH(org.jreleaser.util.Constants.KEY_ARTIFACT_ARCH) Collections(java.util.Collections) PackagerProcessor(org.jreleaser.model.packager.spi.PackagerProcessor) InputStream(java.io.InputStream) Path(java.nio.file.Path) IOException(java.io.IOException) Algorithm(org.jreleaser.util.Algorithm) Artifact(org.jreleaser.model.Artifact) LinkedHashMap(java.util.LinkedHashMap)

Example 10 with RB

use of org.jreleaser.bundle.RB in project jreleaser by jreleaser.

the class DistributionsValidator method validateArtifactPlatforms.

public static void validateArtifactPlatforms(JReleaserContext context, Distribution distribution, Packager packager, List<Artifact> candidateArtifacts, Errors errors) {
    // validate distribution type
    if (distribution.getType() == Distribution.DistributionType.BINARY || distribution.getType() == Distribution.DistributionType.JLINK || distribution.getType() == Distribution.DistributionType.NATIVE_IMAGE || distribution.getType() == Distribution.DistributionType.NATIVE_PACKAGE) {
        // ensure all artifacts define a platform
        AtomicBoolean universal = new AtomicBoolean();
        String noPlatform = "<nil>";
        Map<String, List<Artifact>> byPlatform = candidateArtifacts.stream().peek(artifact -> {
            if (distribution.getType() == Distribution.DistributionType.BINARY && artifact.extraPropertyIsTrue("universal")) {
                universal.compareAndSet(false, true);
            }
        }).collect(groupingBy(artifact -> isBlank(artifact.getPlatform()) ? noPlatform : artifact.getPlatform()));
        if (byPlatform.containsKey(noPlatform) && !universal.get()) {
            errors.configuration(RB.$("validation_distributions_platform_check", distribution.getName(), distribution.getType(), packager.getType()));
        }
        if (byPlatform.keySet().stream().noneMatch(packager::supportsPlatform) && !universal.get()) {
            context.getLogger().warn(RB.$("validation_distributions_disable", distribution.getName(), packager.getType()));
            packager.disable();
        }
    }
}
Also used : Artifact(org.jreleaser.model.Artifact) ChocolateyValidator.validateChocolatey(org.jreleaser.model.validation.ChocolateyValidator.validateChocolatey) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ScoopValidator.validateScoop(org.jreleaser.model.validation.ScoopValidator.validateScoop) StringUtils.isBlank(org.jreleaser.util.StringUtils.isBlank) StringUtils.isNotBlank(org.jreleaser.util.StringUtils.isNotBlank) ArrayList(java.util.ArrayList) Active(org.jreleaser.model.Active) JbangValidator.validateJbang(org.jreleaser.model.validation.JbangValidator.validateJbang) Errors(org.jreleaser.util.Errors) JbangValidator.postValidateJBang(org.jreleaser.model.validation.JbangValidator.postValidateJBang) Map(java.util.Map) JReleaserContext(org.jreleaser.model.JReleaserContext) BrewValidator.validateBrew(org.jreleaser.model.validation.BrewValidator.validateBrew) Distribution(org.jreleaser.model.Distribution) ChocolateyValidator.postValidateChocolatey(org.jreleaser.model.validation.ChocolateyValidator.postValidateChocolatey) FileType(org.jreleaser.util.FileType) BrewValidator.postValidateBrew(org.jreleaser.model.validation.BrewValidator.postValidateBrew) KEY_SKIP_RELEASE_SIGNATURES(org.jreleaser.model.GitService.KEY_SKIP_RELEASE_SIGNATURES) DockerValidator.validateDocker(org.jreleaser.model.validation.DockerValidator.validateDocker) Packager(org.jreleaser.model.Packager) PlatformUtils(org.jreleaser.util.PlatformUtils) Collectors(java.util.stream.Collectors) SdkmanValidator.postValidateSdkman(org.jreleaser.model.validation.SdkmanValidator.postValidateSdkman) Project(org.jreleaser.model.Project) List(java.util.List) GofishValidator.validateGofish(org.jreleaser.model.validation.GofishValidator.validateGofish) SdkmanValidator.validateSdkman(org.jreleaser.model.validation.SdkmanValidator.validateSdkman) MacportsValidator.validateMacports(org.jreleaser.model.validation.MacportsValidator.validateMacports) SpecValidator.validateSpec(org.jreleaser.model.validation.SpecValidator.validateSpec) RB(org.jreleaser.bundle.RB) SnapValidator.validateSnap(org.jreleaser.model.validation.SnapValidator.validateSnap) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

RB (org.jreleaser.bundle.RB)15 JReleaserContext (org.jreleaser.model.JReleaserContext)13 Map (java.util.Map)12 List (java.util.List)10 StringUtils.isNotBlank (org.jreleaser.util.StringUtils.isNotBlank)10 StringUtils.isBlank (org.jreleaser.util.StringUtils.isBlank)9 Artifact (org.jreleaser.model.Artifact)7 IOException (java.io.IOException)6 Collectors.groupingBy (java.util.stream.Collectors.groupingBy)6 Active (org.jreleaser.model.Active)6 Project (org.jreleaser.model.Project)6 Errors (org.jreleaser.util.Errors)6 PlatformUtils (org.jreleaser.util.PlatformUtils)6 Files (java.nio.file.Files)5 Path (java.nio.file.Path)5 Collectors (java.util.stream.Collectors)5 Distribution (org.jreleaser.model.Distribution)5 ArrayList (java.util.ArrayList)4 TemplateValidator.validateTemplate (org.jreleaser.model.validation.TemplateValidator.validateTemplate)4 LinkedHashSet (java.util.LinkedHashSet)3