use of org.jreleaser.model.Packager in project jreleaser by jreleaser.
the class DistributionsValidator method validateArtifactPlatforms.
public static void validateArtifactPlatforms(JReleaserContext context, Distribution distribution, Packager packager, List<Artifact> candidateArtifacts, Errors errors) {
// validate distribution type
if (distribution.getType() == Distribution.DistributionType.BINARY || distribution.getType() == Distribution.DistributionType.JLINK || distribution.getType() == Distribution.DistributionType.NATIVE_IMAGE || distribution.getType() == Distribution.DistributionType.NATIVE_PACKAGE) {
// ensure all artifacts define a platform
AtomicBoolean universal = new AtomicBoolean();
String noPlatform = "<nil>";
Map<String, List<Artifact>> byPlatform = candidateArtifacts.stream().peek(artifact -> {
if (distribution.getType() == Distribution.DistributionType.BINARY && artifact.extraPropertyIsTrue("universal")) {
universal.compareAndSet(false, true);
}
}).collect(groupingBy(artifact -> isBlank(artifact.getPlatform()) ? noPlatform : artifact.getPlatform()));
if (byPlatform.containsKey(noPlatform) && !universal.get()) {
errors.configuration(RB.$("validation_distributions_platform_check", distribution.getName(), distribution.getType(), packager.getType()));
}
if (byPlatform.keySet().stream().noneMatch(packager::supportsPlatform) && !universal.get()) {
context.getLogger().warn(RB.$("validation_distributions_disable", distribution.getName(), packager.getType()));
packager.disable();
}
}
}
use of org.jreleaser.model.Packager in project jreleaser by jreleaser.
the class Artifacts method resolveDownloadUrl.
public static String resolveDownloadUrl(JReleaserContext context, String packagerName, Distribution distribution, Artifact artifact) {
List<String> keys = Collections.singletonList("skip" + capitalize(packagerName));
if (isSkip(artifact, keys))
return "";
String downloadUrl = artifact.getExtraProperty(packagerName + DOWNLOAD_URL_SUFFIX);
if (isBlank(downloadUrl)) {
downloadUrl = artifact.getExtraProperty(DOWNLOAD_URL_KEY);
}
Packager packager = distribution.findPackager(packagerName);
if (isBlank(downloadUrl)) {
downloadUrl = packager.getDownloadUrl();
}
if (isBlank(downloadUrl)) {
downloadUrl = distribution.getExtraProperty(packagerName + DOWNLOAD_URL_SUFFIX);
}
if (isBlank(downloadUrl)) {
downloadUrl = distribution.getExtraProperty(DOWNLOAD_URL_KEY);
}
GitService service = context.getModel().getRelease().getGitService();
if (isBlank(downloadUrl)) {
if (!service.isSkipRelease() && service.isArtifacts() && service.resolveUploadAssetsEnabled(context.getModel().getProject())) {
downloadUrl = service.getDownloadUrl();
}
}
if (isBlank(downloadUrl)) {
downloadUrl = resolveDownloadUrlFromUploader(context, artifact, artifact);
}
if (isBlank(downloadUrl)) {
downloadUrl = resolveDownloadUrlFromUploader(context, packager, artifact);
}
if (isBlank(downloadUrl)) {
downloadUrl = resolveDownloadUrlFromUploader(context, distribution, artifact);
}
if (isBlank(downloadUrl)) {
context.getLogger().warn(RB.$("ERROR_artifacts_download_url_missing", artifact.getEffectivePath(context, distribution).getFileName().toString(), service.getServiceName()));
// assume artifact is available from Git
downloadUrl = service.getDownloadUrl();
}
Map<String, Object> props = context.fullProps();
props.putAll(packager.getResolvedExtraProperties());
props.putAll(distribution.props());
artifactProps(artifact, distribution, props);
return resolveTemplate(downloadUrl, props);
}
use of org.jreleaser.model.Packager in project jreleaser by jreleaser.
the class DistributionProcessor method packageDistribution.
public void packageDistribution() throws PackagerProcessingException {
Distribution distribution = context.getModel().findDistribution(distributionName);
Packager packager = distribution.getPackager(packagerName);
if (!packager.isEnabled()) {
context.getLogger().debug(RB.$("distributions.skip.distribution"), distributionName);
return;
}
if (packager.isFailed()) {
context.getLogger().warn(RB.$("distributions.previous.failure"));
return;
}
PackagerProcessor<Packager> packagerProcessor = PackagerProcessors.findProcessor(context, packager);
if (!packagerProcessor.supportsDistribution(distribution)) {
context.getLogger().info(RB.$("distributions.not.supported.distribution"), distributionName, distribution.getType());
return;
}
context.getLogger().info(RB.$("distributions.apply.action.distribution"), RB.$("distributions.action.packaging"), distributionName);
try {
packagerProcessor.packageDistribution(distribution, initProps());
} catch (PackagerProcessingException tpe) {
if (packager.isContinueOnError()) {
packager.fail();
context.getLogger().warn(RB.$("distributions.failure"), tpe.getMessage());
context.getLogger().trace(tpe);
} else {
throw tpe;
}
}
}
use of org.jreleaser.model.Packager in project jreleaser by jreleaser.
the class DistributionProcessor method publishDistribution.
public void publishDistribution() throws PackagerProcessingException {
Distribution distribution = context.getModel().findDistribution(distributionName);
Packager packager = distribution.getPackager(packagerName);
if (!packager.isEnabled()) {
context.getLogger().debug(RB.$("distributions.skip.distribution"), distributionName);
return;
}
if (packager.isFailed()) {
context.getLogger().warn(RB.$("distributions.previous.failure"));
return;
}
PackagerProcessor<Packager> packagerProcessor = PackagerProcessors.findProcessor(context, packager);
if (!packagerProcessor.supportsDistribution(distribution)) {
context.getLogger().info(RB.$("distributions.not.supported.distribution"), distributionName, distribution.getType());
return;
}
context.getLogger().info(RB.$("distributions.apply.action.distribution"), RB.$("distributions.action.publishing"), distributionName);
try {
packagerProcessor.publishDistribution(distribution, initProps());
} catch (PackagerProcessingException tpe) {
if (packager.isContinueOnError()) {
packager.fail();
context.getLogger().warn(RB.$("distributions.failure"), tpe.getMessage());
context.getLogger().trace(tpe);
} else {
throw tpe;
}
}
}
use of org.jreleaser.model.Packager in project jreleaser by jreleaser.
the class DistributionProcessor method prepareDistribution.
public void prepareDistribution() throws PackagerProcessingException {
Distribution distribution = context.getModel().findDistribution(distributionName);
Packager packager = distribution.getPackager(packagerName);
if (!packager.isEnabled()) {
context.getLogger().debug(RB.$("distributions.skip.distribution"), distributionName);
return;
}
PackagerProcessor<Packager> packagerProcessor = PackagerProcessors.findProcessor(context, packager);
if (!packagerProcessor.supportsDistribution(distribution)) {
context.getLogger().info(RB.$("distributions.not.supported.distribution"), distributionName, distribution.getType());
return;
}
context.getLogger().info(RB.$("distributions.apply.action.distribution"), RB.$("distributions.action.preparing"), distributionName);
try {
packagerProcessor.prepareDistribution(distribution, initProps());
} catch (PackagerProcessingException tpe) {
if (packager.isContinueOnError()) {
packager.fail();
context.getLogger().warn(RB.$("distributions.failure"), tpe.getMessage());
context.getLogger().trace(tpe);
} else {
throw tpe;
}
}
}
Aggregations