Search in sources :

Example 1 with Spec

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

the class SpecValidator method validateSpec.

public static void validateSpec(JReleaserContext context, Distribution distribution, Spec packager, Errors errors) {
    JReleaserModel model = context.getModel();
    Spec parentPackager = model.getPackagers().getSpec();
    if (!packager.isActiveSet() && parentPackager.isActiveSet()) {
        packager.setActive(parentPackager.getActive());
    }
    if (!packager.resolveEnabled(context.getModel().getProject(), distribution)) {
        packager.disable();
        return;
    }
    GitService service = model.getRelease().getGitService();
    if (!service.isReleaseSupported()) {
        packager.disable();
        return;
    }
    context.getLogger().debug("distribution.{}.spec", distribution.getName());
    List<Artifact> candidateArtifacts = packager.resolveCandidateArtifacts(context, distribution);
    if (candidateArtifacts.size() == 0) {
        packager.setActive(Active.NEVER);
        packager.disable();
        return;
    } else if (candidateArtifacts.size() > 1) {
        errors.configuration(RB.$("validation_packager_multiple_artifacts", "distribution." + distribution.getName() + ".spec"));
        packager.disable();
        return;
    }
    if (isBlank(packager.getRelease())) {
        packager.setRelease(parentPackager.getRelease());
    }
    if (isBlank(packager.getRelease())) {
        packager.setRelease("1");
    }
    try {
        Integer.parseInt(packager.getRelease());
        packager.setRelease(packager.getRelease() + "%{?dist}");
    } catch (NumberFormatException ignored) {
    // ok?
    }
    if (packager.getRequires().isEmpty()) {
        packager.setRequires(parentPackager.getRequires());
    }
    if (packager.getRequires().isEmpty()) {
        packager.setRequires(Collections.singletonList("java"));
    }
    validateCommitAuthor(packager, parentPackager);
    Spec.SpecRepository repository = packager.getRepository();
    repository.resolveEnabled(model.getProject());
    validateTap(context, distribution, repository, parentPackager.getRepository(), "spec.repository");
    validateTemplate(context, distribution, packager, parentPackager, errors);
    mergeExtraProperties(packager, parentPackager);
    validateContinueOnError(packager, parentPackager);
    if (isBlank(packager.getDownloadUrl())) {
        packager.setDownloadUrl(parentPackager.getDownloadUrl());
    }
    validateArtifactPlatforms(context, distribution, packager, candidateArtifacts, errors);
    if (isBlank(packager.getPackageName())) {
        packager.setPackageName(parentPackager.getPackageName());
        if (isBlank(packager.getPackageName())) {
            packager.setPackageName(distribution.getName());
        }
    }
}
Also used : JReleaserModel(org.jreleaser.model.JReleaserModel) GitService(org.jreleaser.model.GitService) Spec(org.jreleaser.model.Spec) Artifact(org.jreleaser.model.Artifact)

Aggregations

Artifact (org.jreleaser.model.Artifact)1 GitService (org.jreleaser.model.GitService)1 JReleaserModel (org.jreleaser.model.JReleaserModel)1 Spec (org.jreleaser.model.Spec)1