Search in sources :

Example 1 with Artifactory

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

the class AbstractArtifactUploader method collectArtifacts.

protected List<Artifact> collectArtifacts() {
    List<Artifact> artifacts = new ArrayList<>();
    List<String> keys = getUploader().resolveSkipKeys();
    Checksum checksum = context.getModel().getChecksum();
    boolean uploadChecksums = getUploader().isChecksums() && !(getUploader() instanceof Artifactory);
    if (getUploader().isFiles()) {
        for (Artifact artifact : Artifacts.resolveFiles(context)) {
            if (!artifact.isActive())
                continue;
            Path path = artifact.getEffectivePath(context);
            if (isSkip(artifact, keys))
                continue;
            if (Files.exists(path) && 0 != path.toFile().length()) {
                artifacts.add(artifact);
                if (uploadChecksums && isIndividual(context, artifact) && !artifact.extraPropertyIsTrue(KEY_SKIP_CHECKSUM)) {
                    for (Algorithm algorithm : checksum.getAlgorithms()) {
                        artifacts.add(Artifact.of(context.getChecksumsDirectory().resolve(path.getFileName() + "." + algorithm.formatted())));
                    }
                }
            }
        }
    }
    if (getUploader().isArtifacts()) {
        for (Distribution distribution : context.getModel().getActiveDistributions()) {
            if (isSkip(distribution, keys))
                continue;
            for (Artifact artifact : distribution.getArtifacts()) {
                if (!artifact.isActive())
                    continue;
                Path path = artifact.getEffectivePath(context, distribution);
                if (isSkip(artifact, keys))
                    continue;
                if (Files.exists(path) && 0 != path.toFile().length()) {
                    String platform = artifact.getPlatform();
                    String platformReplaced = distribution.getPlatform().applyReplacements(platform);
                    if (isNotBlank(platformReplaced)) {
                        artifact.getExtraProperties().put("platformReplaced", platformReplaced);
                    }
                    artifacts.add(artifact);
                    if (uploadChecksums && isIndividual(context, distribution, artifact)) {
                        for (Algorithm algorithm : checksum.getAlgorithms()) {
                            artifacts.add(Artifact.of(context.getChecksumsDirectory().resolve(distribution.getName()).resolve(path.getFileName() + "." + algorithm.formatted())));
                        }
                    }
                }
            }
        }
    }
    if (uploadChecksums) {
        for (Algorithm algorithm : checksum.getAlgorithms()) {
            Path checksums = context.getChecksumsDirectory().resolve(checksum.getResolvedName(context, algorithm));
            if (Files.exists(checksums)) {
                artifacts.add(Artifact.of(checksums));
            }
        }
    }
    Signing signing = context.getModel().getSigning();
    if (getUploader().isSignatures() && signing.isEnabled()) {
        String extension = signing.getSignatureExtension();
        List<Artifact> signatures = new ArrayList<>();
        for (Artifact artifact : artifacts) {
            if (artifact.extraPropertyIsTrue(KEY_SKIP_SIGNING))
                continue;
            Path signaturePath = context.getSignaturesDirectory().resolve(artifact.getEffectivePath(context).getFileName() + extension);
            if (Files.exists(signaturePath) && 0 != signaturePath.toFile().length()) {
                signatures.add(Artifact.of(signaturePath, artifact.getExtraProperties()));
            }
        }
        if (!signatures.isEmpty() && signing.getMode() == Signing.Mode.COSIGN) {
            Path publicKeyFile = signing.getCosign().getResolvedPublicKeyFilePath(context);
            signatures.add(Artifact.of(publicKeyFile));
        }
        artifacts.addAll(signatures);
    }
    return artifacts;
}
Also used : Path(java.nio.file.Path) Signing(org.jreleaser.model.Signing) Checksum(org.jreleaser.model.Checksum) Distribution(org.jreleaser.model.Distribution) ArrayList(java.util.ArrayList) Artifactory(org.jreleaser.model.Artifactory) Algorithm(org.jreleaser.util.Algorithm) Artifact(org.jreleaser.model.Artifact)

Example 2 with Artifactory

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

the class ArtifactoryValidator method validateArtifactory.

public static void validateArtifactory(JReleaserContext context, JReleaserContext.Mode mode, Errors errors) {
    context.getLogger().debug("artifactory");
    Map<String, Artifactory> artifactory = context.getModel().getUpload().getArtifactory();
    for (Map.Entry<String, Artifactory> e : artifactory.entrySet()) {
        e.getValue().setName(e.getKey());
        if (!mode.validateConfig()) {
            validateArtifactory(context, mode, e.getValue(), new Errors());
        } else {
            validateArtifactory(context, mode, e.getValue(), errors);
        }
    }
}
Also used : Errors(org.jreleaser.util.Errors) Artifactory(org.jreleaser.model.Artifactory) Map(java.util.Map)

Aggregations

Artifactory (org.jreleaser.model.Artifactory)2 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Artifact (org.jreleaser.model.Artifact)1 Checksum (org.jreleaser.model.Checksum)1 Distribution (org.jreleaser.model.Distribution)1 Signing (org.jreleaser.model.Signing)1 Algorithm (org.jreleaser.util.Algorithm)1 Errors (org.jreleaser.util.Errors)1