use of org.jreleaser.model.Upload in project jreleaser by jreleaser.
the class Uploaders method upload.
public static void upload(JReleaserContext context) {
Upload upload = context.getModel().getUpload();
if (!upload.isEnabled()) {
context.getLogger().info(RB.$("uploaders.not.enabled"));
return;
}
if (!context.getIncludedUploaderTypes().isEmpty()) {
for (String uploaderType : context.getIncludedUploaderTypes()) {
// check if the uploaderType is valid
if (!Upload.supportedUploaders().contains(uploaderType)) {
context.getLogger().warn(RB.$("ERROR_unsupported_uploader", uploaderType));
continue;
}
Map<String, Uploader> uploaders = upload.findUploadersByType(uploaderType);
if (uploaders.isEmpty()) {
context.getLogger().debug(RB.$("uploaders.no.match"), uploaderType);
return;
}
if (!context.getIncludedUploaderNames().isEmpty()) {
for (String uploaderName : context.getIncludedUploaderNames()) {
if (!uploaders.containsKey(uploaderName)) {
context.getLogger().warn(RB.$("uploaders.uploader.not.configured"), uploaderType, uploaderName);
continue;
}
Uploader uploader = uploaders.get(uploaderName);
if (!uploader.isEnabled()) {
context.getLogger().info(RB.$("uploaders.uploader.disabled"), uploaderType, uploaderName);
continue;
}
context.getLogger().info(RB.$("uploaders.upload.with"), uploaderType, uploaderName);
upload(context, uploader);
}
} else {
context.getLogger().info(RB.$("uploaders.upload.all.artifacts.with"), uploaderType);
uploaders.values().forEach(uploader -> upload(context, uploader));
}
}
} else if (!context.getIncludedUploaderNames().isEmpty()) {
for (String uploaderName : context.getIncludedUploaderNames()) {
List<Uploader> filteredUploaders = upload.findAllActiveUploaders().stream().filter(a -> uploaderName.equals(a.getName())).collect(toList());
if (!filteredUploaders.isEmpty()) {
context.getLogger().info(RB.$("uploaders.upload.all.artifacts.to"), uploaderName);
filteredUploaders.forEach(uploader -> upload(context, uploader));
} else {
context.getLogger().warn(RB.$("uploaders.uploader.not.configured2"), uploaderName);
}
}
} else {
context.getLogger().info(RB.$("uploaders.upload.all.artifacts"));
for (Uploader uploader : upload.findAllActiveUploaders()) {
String uploaderType = uploader.getType();
String uploaderName = uploader.getName();
if (context.getExcludedUploaderTypes().contains(uploaderType) || context.getExcludedUploaderNames().contains(uploaderName)) {
context.getLogger().info(RB.$("uploaders.uploader.excluded"), uploaderType, uploaderName);
continue;
}
upload(context, uploader);
}
}
}
use of org.jreleaser.model.Upload in project jreleaser by jreleaser.
the class UploadersValidator method validateUploaders.
public static void validateUploaders(JReleaserContext context, JReleaserContext.Mode mode, Errors errors) {
context.getLogger().debug("upload");
Upload upload = context.getModel().getUpload();
validateArtifactory(context, mode, errors);
validateHttp(context, mode, errors);
validateS3(context, mode, errors);
if (mode.validateConfig() && !upload.isEnabledSet()) {
upload.setEnabled(!upload.getActiveArtifactories().isEmpty() || !upload.getActiveHttps().isEmpty() || !upload.getActiveS3s().isEmpty());
}
}
use of org.jreleaser.model.Upload in project jreleaser by jreleaser.
the class Artifacts method resolveDownloadUrlFromUploader.
private static String resolveDownloadUrlFromUploader(JReleaserContext context, ExtraProperties props, Artifact artifact) {
Upload upload = context.getModel().getUpload();
String coords = props.getExtraProperty(DOWNLOAD_URL_FROM_KEY);
if (isBlank(coords)) {
// search for "<uploaderType><uploaderName>Path"
for (Uploader up : upload.findAllActiveUploaders()) {
List<String> keys = up.resolveSkipKeys();
String key = up.getType() + capitalize(up.getName()) + "Path";
if (artifact.getExtraProperties().containsKey(key) && !isSkip(props, keys)) {
return up.getResolvedDownloadUrl(context, artifact);
}
}
return null;
}
String[] parts = coords.split(":");
if (parts.length != 2)
return null;
Optional<? extends Uploader> uploader = upload.getActiveUploader(parts[0], parts[1]);
if (uploader.isPresent()) {
List<String> keys = uploader.get().resolveSkipKeys();
if (!isSkip(props, keys)) {
return uploader.get().getResolvedDownloadUrl(context, artifact);
}
} else {
// search for "<uploaderType><uploaderName>Path"
for (Uploader up : upload.findAllActiveUploaders()) {
List<String> keys = up.resolveSkipKeys();
String key = up.getType() + capitalize(up.getName()) + "Path";
if (artifact.getExtraProperties().containsKey(key) && !isSkip(props, keys)) {
return up.getResolvedDownloadUrl(context, artifact);
}
}
}
return null;
}
Aggregations