use of org.jreleaser.model.JReleaserContext in project jreleaser by jreleaser.
the class Release method createContext.
@Override
protected JReleaserContext createContext() {
JReleaserContext context = super.createContext();
if (null != composite) {
context.setIncludedDistributions(collectEntries(composite.includedDistributions()));
context.setIncludedUploaderTypes(collectEntries(composite.includedUploaderTypes(), true));
context.setIncludedUploaderNames(collectEntries(composite.includedUploaderNames()));
context.setExcludedDistributions(collectEntries(composite.excludedDistributions()));
context.setExcludedUploaderTypes(collectEntries(composite.excludedUploaderTypes(), true));
context.setExcludedUploaderNames(collectEntries(composite.excludedUploaderNames()));
}
return context;
}
use of org.jreleaser.model.JReleaserContext in project jreleaser by jreleaser.
the class Release method execute.
protected void execute() {
if (composite == null || !composite.autoConfig()) {
super.execute();
return;
}
basedir();
initLogger();
JReleaserContext context = ModelAutoConfigurer.builder().logger(logger).basedir(actualBasedir).outputDirectory(getOutputDirectory()).dryrun(dryrun()).gitRootSearch(gitRootSearch).projectName(composite.autoConfig.projectName).projectVersion(composite.autoConfig.projectVersion).projectVersionPattern(composite.autoConfig.projectVersionPattern).projectSnapshotPattern(composite.autoConfig.projectSnapshotPattern).projectSnapshotLabel(composite.autoConfig.projectSnapshotLabel).projectSnapshotFullChangelog(composite.autoConfig.projectSnapshotFullChangelog).tagName(composite.autoConfig.tagName).previousTagName(composite.autoConfig.previousTagName).releaseName(composite.autoConfig.releaseName).milestoneName(composite.autoConfig.milestoneName).branch(composite.autoConfig.branch).prerelease(composite.autoConfig.prerelease).prereleasePattern(composite.autoConfig.prereleasePattern).draft(composite.autoConfig.draft).overwrite(composite.autoConfig.overwrite).update(composite.autoConfig.update).updateSections(collectUpdateSections()).skipTag(composite.autoConfig.skipTag).skipRelease(composite.autoConfig.skipRelease).changelog(composite.autoConfig.changelog).changelogFormatted(composite.autoConfig.changelogFormatted).username(composite.autoConfig.username).commitAuthorName(composite.autoConfig.commitAuthorName).commitAuthorEmail(composite.autoConfig.commitAuthorEmail).signing(composite.autoConfig.signing).armored(composite.autoConfig.armored).files(collectEntries(composite.autoConfig.files)).globs(collectEntries(composite.autoConfig.globs)).selectedPlatforms(collectSelectedPlatforms()).autoConfigure();
doExecute(context);
}
use of org.jreleaser.model.JReleaserContext 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.JReleaserContext in project jreleaser by jreleaser.
the class GofishValidator method validateGofish.
public static void validateGofish(JReleaserContext context, Distribution distribution, Gofish packager, Errors errors) {
JReleaserModel model = context.getModel();
Gofish parentPackager = model.getPackagers().getGofish();
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.{}.gofish", distribution.getName());
List<Artifact> candidateArtifacts = packager.resolveCandidateArtifacts(context, distribution);
if (candidateArtifacts.size() == 0) {
packager.setActive(Active.NEVER);
packager.disable();
return;
} else if (candidateArtifacts.stream().filter(artifact -> isBlank(artifact.getPlatform())).count() > 1) {
errors.configuration(RB.$("validation_packager_multiple_artifacts", "distribution." + distribution.getName() + ".gofish"));
packager.disable();
return;
}
validateCommitAuthor(packager, parentPackager);
Gofish.GofishRepository repository = packager.getRepository();
repository.resolveEnabled(model.getProject());
validateTap(context, distribution, repository, parentPackager.getRepository(), "gofish.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);
}
use of org.jreleaser.model.JReleaserContext in project jreleaser by jreleaser.
the class JlinkValidator method validateJlink.
private static void validateJlink(JReleaserContext context, JReleaserContext.Mode mode, Jlink jlink, Errors errors) {
context.getLogger().debug("jlink.{}", jlink.getName());
if (!jlink.isActiveSet()) {
jlink.setActive(Active.NEVER);
}
if (!jlink.resolveEnabled(context.getModel().getProject()))
return;
if (isBlank(jlink.getName())) {
errors.configuration(RB.$("validation_must_not_be_blank", "jlink.name"));
return;
}
context.getLogger().debug("jlink.{}.java", jlink.getName());
if (!validateJava(context, jlink, errors)) {
return;
}
Platform platform = jlink.getPlatform().merge(context.getModel().getPlatform());
jlink.setPlatform(platform);
if (isBlank(jlink.getImageName())) {
jlink.setImageName(jlink.getJava().getGroupId() + "." + jlink.getJava().getArtifactId() + "-" + context.getModel().getProject().getResolvedVersion());
}
if (isBlank(jlink.getExecutable())) {
jlink.setExecutable(jlink.getName());
}
int i = 0;
for (Artifact targetJdk : jlink.getTargetJdks()) {
validateJdk(context, mode, jlink, targetJdk, i++, errors);
}
// validate jdks.platform is unique
Map<String, List<Artifact>> byPlatform = jlink.getTargetJdks().stream().collect(groupingBy(jdk -> isBlank(jdk.getPlatform()) ? "<nil>" : jdk.getPlatform()));
if (byPlatform.containsKey("<nil>")) {
errors.configuration(RB.$("validation_jlink_jdk_platform", jlink.getName()));
}
// check platforms
byPlatform.forEach((p, jdks) -> {
if (jdks.size() > 1) {
errors.configuration(RB.$("validation_jlink_jdk_multiple_platforms", jlink.getName(), p));
}
});
if (isBlank(jlink.getJdk().getPath())) {
String currentPlatform = PlatformUtils.getCurrentFull();
String javaHome = System.getProperty("java.home");
if (jlink.getTargetJdks().isEmpty()) {
if (isBlank(javaHome)) {
// Can only happen when running as native-image, fail for now
// TODO: native-image
errors.configuration(RB.$("validation_java_home_missing"));
return;
}
// Use current
jlink.getJdk().setPath(javaHome);
jlink.getJdk().setPlatform(currentPlatform);
jlink.addTargetJdk(jlink.getJdk());
} else {
// find a compatible JDK in targets
Optional<Artifact> jdk = jlink.getTargetJdks().stream().filter(j -> PlatformUtils.isCompatible(currentPlatform, j.getPlatform())).findFirst();
if (jdk.isPresent()) {
jlink.setJdk(jdk.get());
} else {
if (isBlank(javaHome)) {
// Can only happen when running as native-image, fail for now
// TODO: native-image
errors.configuration(RB.$("validation_java_home_missing"));
return;
}
// Can't tell if the current JDK will work but might as well use it
jlink.getJdk().setPath(javaHome);
jlink.getJdk().setPlatform(currentPlatform);
}
}
}
if (jlink.getArgs().isEmpty()) {
jlink.getArgs().add("--no-header-files");
jlink.getArgs().add("--no-man-pages");
jlink.getArgs().add("--compress=2");
jlink.getArgs().add("--strip-debug");
}
if (null == jlink.getMainJar()) {
errors.configuration(RB.$("validation_is_null", "jlink." + jlink.getName() + ".mainJar"));
return;
}
if (isBlank(jlink.getMainJar().getPath())) {
errors.configuration(RB.$("validation_must_not_be_null", "jlink." + jlink.getName() + ".mainJar.path"));
}
validateGlobs(context, jlink.getJars(), "jlink." + jlink.getName() + ".jars", errors);
if (mode == JReleaserContext.Mode.ASSEMBLE) {
validateTemplate(context, jlink, errors);
}
if (!jlink.getFileSets().isEmpty()) {
i = 0;
for (FileSet fileSet : jlink.getFileSets()) {
validateFileSet(context, mode, jlink, fileSet, i++, errors);
}
}
}
Aggregations