Search in sources :

Example 1 with Brew

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

the class BrewValidator method validateBrew.

public static void validateBrew(JReleaserContext context, Distribution distribution, Brew packager, Errors errors) {
    JReleaserModel model = context.getModel();
    Brew parentPackager = model.getPackagers().getBrew();
    if (!packager.isActiveSet() && parentPackager.isActiveSet()) {
        packager.setActive(parentPackager.getActive());
    }
    if (!packager.resolveEnabled(context.getModel().getProject(), distribution)) {
        packager.disable();
        packager.getCask().disable();
        return;
    }
    GitService service = model.getRelease().getGitService();
    if (!service.isReleaseSupported()) {
        packager.disable();
        packager.getCask().disable();
        return;
    }
    context.getLogger().debug("distribution.{}.brew", distribution.getName());
    Brew.Cask cask = preValidateCask(distribution, packager, parentPackager);
    if (!packager.isMultiPlatformSet() && parentPackager.isMultiPlatformSet()) {
        packager.setMultiPlatform(parentPackager.isMultiPlatform());
    }
    if (packager.isMultiPlatform() && (distribution.getType() == Distribution.DistributionType.SINGLE_JAR || distribution.getType() == Distribution.DistributionType.JAVA_BINARY || distribution.getType() == Distribution.DistributionType.NATIVE_PACKAGE)) {
        packager.setMultiPlatform(false);
    }
    if (packager.isMultiPlatform()) {
        packager.getCask().disable();
    }
    validateCask(context, distribution, packager, cask, errors);
    List<Artifact> candidateArtifacts = packager.resolveCandidateArtifacts(context, distribution);
    if (candidateArtifacts.size() == 0) {
        packager.setActive(Active.NEVER);
        packager.disable();
        return;
    }
    validateCommitAuthor(packager, parentPackager);
    Brew.HomebrewTap tap = packager.getTap();
    tap.resolveEnabled(model.getProject());
    validateTap(context, distribution, tap, parentPackager.getTap(), "brew.tap");
    validateTemplate(context, distribution, packager, parentPackager, errors);
    mergeExtraProperties(packager, parentPackager);
    validateContinueOnError(packager, parentPackager);
    if (isBlank(packager.getDownloadUrl())) {
        packager.setDownloadUrl(parentPackager.getDownloadUrl());
    }
    List<Brew.Dependency> dependencies = new ArrayList<>(parentPackager.getDependenciesAsList());
    dependencies.addAll(packager.getDependenciesAsList());
    packager.setDependenciesAsList(dependencies);
    if (isBlank(packager.getFormulaName())) {
        packager.setFormulaName(distribution.getName());
    }
    if (!cask.isEnabled()) {
        validateArtifactPlatforms(context, distribution, packager, candidateArtifacts, errors);
    }
}
Also used : JReleaserModel(org.jreleaser.model.JReleaserModel) GitService(org.jreleaser.model.GitService) ArrayList(java.util.ArrayList) Brew(org.jreleaser.model.Brew) Artifact(org.jreleaser.model.Artifact)

Aggregations

ArrayList (java.util.ArrayList)1 Artifact (org.jreleaser.model.Artifact)1 Brew (org.jreleaser.model.Brew)1 GitService (org.jreleaser.model.GitService)1 JReleaserModel (org.jreleaser.model.JReleaserModel)1