Search in sources :

Example 1 with Packager

use of org.jreleaser.model.Packager 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)

Example 2 with Packager

use of org.jreleaser.model.Packager in project jreleaser by jreleaser.

the class Artifacts method resolveDownloadUrl.

public static String resolveDownloadUrl(JReleaserContext context, String packagerName, Distribution distribution, Artifact artifact) {
    List<String> keys = Collections.singletonList("skip" + capitalize(packagerName));
    if (isSkip(artifact, keys))
        return "";
    String downloadUrl = artifact.getExtraProperty(packagerName + DOWNLOAD_URL_SUFFIX);
    if (isBlank(downloadUrl)) {
        downloadUrl = artifact.getExtraProperty(DOWNLOAD_URL_KEY);
    }
    Packager packager = distribution.findPackager(packagerName);
    if (isBlank(downloadUrl)) {
        downloadUrl = packager.getDownloadUrl();
    }
    if (isBlank(downloadUrl)) {
        downloadUrl = distribution.getExtraProperty(packagerName + DOWNLOAD_URL_SUFFIX);
    }
    if (isBlank(downloadUrl)) {
        downloadUrl = distribution.getExtraProperty(DOWNLOAD_URL_KEY);
    }
    GitService service = context.getModel().getRelease().getGitService();
    if (isBlank(downloadUrl)) {
        if (!service.isSkipRelease() && service.isArtifacts() && service.resolveUploadAssetsEnabled(context.getModel().getProject())) {
            downloadUrl = service.getDownloadUrl();
        }
    }
    if (isBlank(downloadUrl)) {
        downloadUrl = resolveDownloadUrlFromUploader(context, artifact, artifact);
    }
    if (isBlank(downloadUrl)) {
        downloadUrl = resolveDownloadUrlFromUploader(context, packager, artifact);
    }
    if (isBlank(downloadUrl)) {
        downloadUrl = resolveDownloadUrlFromUploader(context, distribution, artifact);
    }
    if (isBlank(downloadUrl)) {
        context.getLogger().warn(RB.$("ERROR_artifacts_download_url_missing", artifact.getEffectivePath(context, distribution).getFileName().toString(), service.getServiceName()));
        // assume artifact is available from Git
        downloadUrl = service.getDownloadUrl();
    }
    Map<String, Object> props = context.fullProps();
    props.putAll(packager.getResolvedExtraProperties());
    props.putAll(distribution.props());
    artifactProps(artifact, distribution, props);
    return resolveTemplate(downloadUrl, props);
}
Also used : Packager(org.jreleaser.model.Packager) GitService(org.jreleaser.model.GitService)

Example 3 with Packager

use of org.jreleaser.model.Packager in project jreleaser by jreleaser.

the class DistributionProcessor method packageDistribution.

public void packageDistribution() throws PackagerProcessingException {
    Distribution distribution = context.getModel().findDistribution(distributionName);
    Packager packager = distribution.getPackager(packagerName);
    if (!packager.isEnabled()) {
        context.getLogger().debug(RB.$("distributions.skip.distribution"), distributionName);
        return;
    }
    if (packager.isFailed()) {
        context.getLogger().warn(RB.$("distributions.previous.failure"));
        return;
    }
    PackagerProcessor<Packager> packagerProcessor = PackagerProcessors.findProcessor(context, packager);
    if (!packagerProcessor.supportsDistribution(distribution)) {
        context.getLogger().info(RB.$("distributions.not.supported.distribution"), distributionName, distribution.getType());
        return;
    }
    context.getLogger().info(RB.$("distributions.apply.action.distribution"), RB.$("distributions.action.packaging"), distributionName);
    try {
        packagerProcessor.packageDistribution(distribution, initProps());
    } catch (PackagerProcessingException tpe) {
        if (packager.isContinueOnError()) {
            packager.fail();
            context.getLogger().warn(RB.$("distributions.failure"), tpe.getMessage());
            context.getLogger().trace(tpe);
        } else {
            throw tpe;
        }
    }
}
Also used : Distribution(org.jreleaser.model.Distribution) Packager(org.jreleaser.model.Packager) PackagerProcessingException(org.jreleaser.model.packager.spi.PackagerProcessingException)

Example 4 with Packager

use of org.jreleaser.model.Packager in project jreleaser by jreleaser.

the class DistributionProcessor method publishDistribution.

public void publishDistribution() throws PackagerProcessingException {
    Distribution distribution = context.getModel().findDistribution(distributionName);
    Packager packager = distribution.getPackager(packagerName);
    if (!packager.isEnabled()) {
        context.getLogger().debug(RB.$("distributions.skip.distribution"), distributionName);
        return;
    }
    if (packager.isFailed()) {
        context.getLogger().warn(RB.$("distributions.previous.failure"));
        return;
    }
    PackagerProcessor<Packager> packagerProcessor = PackagerProcessors.findProcessor(context, packager);
    if (!packagerProcessor.supportsDistribution(distribution)) {
        context.getLogger().info(RB.$("distributions.not.supported.distribution"), distributionName, distribution.getType());
        return;
    }
    context.getLogger().info(RB.$("distributions.apply.action.distribution"), RB.$("distributions.action.publishing"), distributionName);
    try {
        packagerProcessor.publishDistribution(distribution, initProps());
    } catch (PackagerProcessingException tpe) {
        if (packager.isContinueOnError()) {
            packager.fail();
            context.getLogger().warn(RB.$("distributions.failure"), tpe.getMessage());
            context.getLogger().trace(tpe);
        } else {
            throw tpe;
        }
    }
}
Also used : Distribution(org.jreleaser.model.Distribution) Packager(org.jreleaser.model.Packager) PackagerProcessingException(org.jreleaser.model.packager.spi.PackagerProcessingException)

Example 5 with Packager

use of org.jreleaser.model.Packager in project jreleaser by jreleaser.

the class DistributionProcessor method prepareDistribution.

public void prepareDistribution() throws PackagerProcessingException {
    Distribution distribution = context.getModel().findDistribution(distributionName);
    Packager packager = distribution.getPackager(packagerName);
    if (!packager.isEnabled()) {
        context.getLogger().debug(RB.$("distributions.skip.distribution"), distributionName);
        return;
    }
    PackagerProcessor<Packager> packagerProcessor = PackagerProcessors.findProcessor(context, packager);
    if (!packagerProcessor.supportsDistribution(distribution)) {
        context.getLogger().info(RB.$("distributions.not.supported.distribution"), distributionName, distribution.getType());
        return;
    }
    context.getLogger().info(RB.$("distributions.apply.action.distribution"), RB.$("distributions.action.preparing"), distributionName);
    try {
        packagerProcessor.prepareDistribution(distribution, initProps());
    } catch (PackagerProcessingException tpe) {
        if (packager.isContinueOnError()) {
            packager.fail();
            context.getLogger().warn(RB.$("distributions.failure"), tpe.getMessage());
            context.getLogger().trace(tpe);
        } else {
            throw tpe;
        }
    }
}
Also used : Distribution(org.jreleaser.model.Distribution) Packager(org.jreleaser.model.Packager) PackagerProcessingException(org.jreleaser.model.packager.spi.PackagerProcessingException)

Aggregations

Packager (org.jreleaser.model.Packager)5 Distribution (org.jreleaser.model.Distribution)4 PackagerProcessingException (org.jreleaser.model.packager.spi.PackagerProcessingException)3 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Collectors (java.util.stream.Collectors)1 Collectors.groupingBy (java.util.stream.Collectors.groupingBy)1 RB (org.jreleaser.bundle.RB)1 Active (org.jreleaser.model.Active)1 Artifact (org.jreleaser.model.Artifact)1 GitService (org.jreleaser.model.GitService)1 KEY_SKIP_RELEASE_SIGNATURES (org.jreleaser.model.GitService.KEY_SKIP_RELEASE_SIGNATURES)1 JReleaserContext (org.jreleaser.model.JReleaserContext)1 Project (org.jreleaser.model.Project)1 BrewValidator.postValidateBrew (org.jreleaser.model.validation.BrewValidator.postValidateBrew)1 BrewValidator.validateBrew (org.jreleaser.model.validation.BrewValidator.validateBrew)1 ChocolateyValidator.postValidateChocolatey (org.jreleaser.model.validation.ChocolateyValidator.postValidateChocolatey)1 ChocolateyValidator.validateChocolatey (org.jreleaser.model.validation.ChocolateyValidator.validateChocolatey)1