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;
}
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);
}
}
}
Aggregations