mirror of
https://github.com/jlengrand/jreleaser.git
synced 2026-03-10 08:31:24 +00:00
[announce] fix sdkman announcer when run on dryrun mode. Fixes #329
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Copyright 2020-2021 The JReleaser authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jreleaser.model;
|
||||
|
||||
/**
|
||||
* @author Andres Almiray
|
||||
* @since 0.6.0
|
||||
*/
|
||||
public enum JReleaserCommand {
|
||||
ASSEMBLE,
|
||||
CHANGELOG,
|
||||
CHECKSUM,
|
||||
SIGN,
|
||||
UPLOAD,
|
||||
RELEASE,
|
||||
PREPARE,
|
||||
PACKAGE,
|
||||
PUBLISH,
|
||||
ANNOUNCE,
|
||||
FULL_RELEASE;
|
||||
|
||||
public static boolean supportsAssemble(JReleaserCommand command) {
|
||||
return ASSEMBLE == command;
|
||||
}
|
||||
|
||||
public static boolean supportsChangelog(JReleaserCommand command) {
|
||||
return CHANGELOG == command ||
|
||||
RELEASE == command ||
|
||||
ANNOUNCE == command ||
|
||||
FULL_RELEASE == command;
|
||||
}
|
||||
|
||||
public static boolean supportsChecksum(JReleaserCommand command) {
|
||||
return CHECKSUM == command ||
|
||||
SIGN == command ||
|
||||
UPLOAD == command ||
|
||||
RELEASE == command ||
|
||||
PREPARE == command ||
|
||||
PACKAGE == command ||
|
||||
PUBLISH == command ||
|
||||
FULL_RELEASE == command;
|
||||
}
|
||||
|
||||
public static boolean supportsSign(JReleaserCommand command) {
|
||||
return SIGN == command ||
|
||||
UPLOAD == command ||
|
||||
RELEASE == command ||
|
||||
FULL_RELEASE == command;
|
||||
}
|
||||
|
||||
public static boolean supportsUpload(JReleaserCommand command) {
|
||||
return UPLOAD == command ||
|
||||
RELEASE == command ||
|
||||
FULL_RELEASE == command;
|
||||
}
|
||||
|
||||
public static boolean supportsRelease(JReleaserCommand command) {
|
||||
return RELEASE == command ||
|
||||
FULL_RELEASE == command;
|
||||
}
|
||||
|
||||
public static boolean supportsPrepare(JReleaserCommand command) {
|
||||
return PREPARE == command ||
|
||||
PACKAGE == command ||
|
||||
PUBLISH == command ||
|
||||
FULL_RELEASE == command;
|
||||
}
|
||||
|
||||
public static boolean supportsPackage(JReleaserCommand command) {
|
||||
return PACKAGE == command ||
|
||||
PUBLISH == command ||
|
||||
FULL_RELEASE == command;
|
||||
}
|
||||
|
||||
public static boolean supportsPublish(JReleaserCommand command) {
|
||||
return PUBLISH == command ||
|
||||
FULL_RELEASE == command;
|
||||
}
|
||||
|
||||
public static boolean supportsAnnounce(JReleaserCommand command) {
|
||||
return ANNOUNCE == command ||
|
||||
FULL_RELEASE == command;
|
||||
}
|
||||
}
|
||||
@@ -90,6 +90,7 @@ public class JReleaserContext {
|
||||
private String assemblerName;
|
||||
private String changelog;
|
||||
private Releaser releaser;
|
||||
private JReleaserCommand command;
|
||||
|
||||
public JReleaserContext(JReleaserLogger logger,
|
||||
Configurer configurer,
|
||||
@@ -370,6 +371,14 @@ public class JReleaserContext {
|
||||
this.assemblerName = assemblerName;
|
||||
}
|
||||
|
||||
public JReleaserCommand getCommand() {
|
||||
return command;
|
||||
}
|
||||
|
||||
public void setCommand(JReleaserCommand command) {
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public Map<String, Object> props() {
|
||||
Map<String, Object> props = new LinkedHashMap<>(model.props());
|
||||
props.put(Constants.KEY_OUTPUT_DIRECTORY, getOutputDirectory());
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.jreleaser.tools;
|
||||
|
||||
import org.jreleaser.model.Artifact;
|
||||
import org.jreleaser.model.Distribution;
|
||||
import org.jreleaser.model.GitService;
|
||||
import org.jreleaser.model.JReleaserContext;
|
||||
import org.jreleaser.model.Sdkman;
|
||||
import org.jreleaser.model.tool.spi.ToolProcessingException;
|
||||
@@ -130,8 +129,6 @@ public class SdkmanToolProcessor extends AbstractToolProcessor<Sdkman> {
|
||||
|
||||
@Override
|
||||
protected void fillToolProperties(Map<String, Object> props, Distribution distribution) throws ToolProcessingException {
|
||||
GitService gitService = context.getModel().getRelease().getGitService();
|
||||
|
||||
props.put(Constants.KEY_SDKMAN_CANDIDATE, tool.getCandidate());
|
||||
props.put(Constants.KEY_SDKMAN_RELEASE_NOTES_URL, applyTemplate(tool.getReleaseNotesUrl(), props));
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
package org.jreleaser.workflow;
|
||||
|
||||
import org.jreleaser.model.JReleaserCommand;
|
||||
import org.jreleaser.model.JReleaserContext;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
@@ -28,24 +29,28 @@ import static java.util.Collections.singletonList;
|
||||
*/
|
||||
public class Workflows {
|
||||
public static Workflow assemble(JReleaserContext context) {
|
||||
context.setCommand(JReleaserCommand.ASSEMBLE);
|
||||
return new WorkflowImpl(context, singletonList(
|
||||
new AssembleWorkflowItem()
|
||||
));
|
||||
}
|
||||
|
||||
public static Workflow changelog(JReleaserContext context) {
|
||||
context.setCommand(JReleaserCommand.CHANGELOG);
|
||||
return new WorkflowImpl(context, singletonList(
|
||||
new ChangelogWorkflowItem()
|
||||
));
|
||||
}
|
||||
|
||||
public static Workflow checksum(JReleaserContext context) {
|
||||
context.setCommand(JReleaserCommand.CHECKSUM);
|
||||
return new WorkflowImpl(context, singletonList(
|
||||
new ChecksumWorkflowItem()
|
||||
));
|
||||
}
|
||||
|
||||
public static Workflow sign(JReleaserContext context) {
|
||||
context.setCommand(JReleaserCommand.SIGN);
|
||||
return new WorkflowImpl(context, asList(
|
||||
new ChecksumWorkflowItem(),
|
||||
new SignWorkflowItem()
|
||||
@@ -53,6 +58,7 @@ public class Workflows {
|
||||
}
|
||||
|
||||
public static Workflow upload(JReleaserContext context) {
|
||||
context.setCommand(JReleaserCommand.UPLOAD);
|
||||
return new WorkflowImpl(context, asList(
|
||||
new ChecksumWorkflowItem(),
|
||||
new SignWorkflowItem(),
|
||||
@@ -61,6 +67,7 @@ public class Workflows {
|
||||
}
|
||||
|
||||
public static Workflow release(JReleaserContext context) {
|
||||
context.setCommand(JReleaserCommand.RELEASE);
|
||||
return new WorkflowImpl(context, asList(
|
||||
new ChangelogWorkflowItem(),
|
||||
new ChecksumWorkflowItem(),
|
||||
@@ -71,6 +78,7 @@ public class Workflows {
|
||||
}
|
||||
|
||||
public static Workflow prepare(JReleaserContext context) {
|
||||
context.setCommand(JReleaserCommand.PREPARE);
|
||||
return new WorkflowImpl(context, asList(
|
||||
new ChecksumWorkflowItem(),
|
||||
new PrepareWorkflowItem()
|
||||
@@ -78,6 +86,7 @@ public class Workflows {
|
||||
}
|
||||
|
||||
public static Workflow packageRelease(JReleaserContext context) {
|
||||
context.setCommand(JReleaserCommand.PACKAGE);
|
||||
return new WorkflowImpl(context, asList(
|
||||
new ChecksumWorkflowItem(),
|
||||
new PrepareWorkflowItem(),
|
||||
@@ -86,6 +95,7 @@ public class Workflows {
|
||||
}
|
||||
|
||||
public static Workflow publish(JReleaserContext context) {
|
||||
context.setCommand(JReleaserCommand.PUBLISH);
|
||||
return new WorkflowImpl(context, asList(
|
||||
new ChecksumWorkflowItem(),
|
||||
new PrepareWorkflowItem(),
|
||||
@@ -95,6 +105,7 @@ public class Workflows {
|
||||
}
|
||||
|
||||
public static Workflow announce(JReleaserContext context) {
|
||||
context.setCommand(JReleaserCommand.ANNOUNCE);
|
||||
return new WorkflowImpl(context, asList(
|
||||
new ChangelogWorkflowItem(),
|
||||
new AnnounceWorkflowItem()
|
||||
@@ -102,6 +113,7 @@ public class Workflows {
|
||||
}
|
||||
|
||||
public static Workflow fullRelease(JReleaserContext context) {
|
||||
context.setCommand(JReleaserCommand.FULL_RELEASE);
|
||||
return new WorkflowImpl(context, asList(
|
||||
new ChangelogWorkflowItem(),
|
||||
new ChecksumWorkflowItem(),
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.jreleaser.sdk.sdkman;
|
||||
|
||||
import org.jreleaser.model.Artifact;
|
||||
import org.jreleaser.model.Distribution;
|
||||
import org.jreleaser.model.JReleaserCommand;
|
||||
import org.jreleaser.model.JReleaserContext;
|
||||
import org.jreleaser.model.Sdkman;
|
||||
import org.jreleaser.model.announcer.spi.AnnounceException;
|
||||
@@ -59,15 +60,19 @@ public class SdkmanAnnouncer implements Announcer {
|
||||
public void announce() throws AnnounceException {
|
||||
Map<String, Distribution> distributions = context.getModel().getActiveDistributions().stream()
|
||||
.filter(d -> d.getSdkman().isEnabled())
|
||||
.filter(d -> d.getSdkman().isPublished())
|
||||
.filter(d -> !JReleaserCommand.supportsPublish(context.getCommand()) || d.getSdkman().isPublished())
|
||||
.collect(Collectors.toMap(distribution -> {
|
||||
Sdkman sdkman = distribution.getSdkman();
|
||||
return isNotBlank(sdkman.getCandidate()) ? sdkman.getCandidate().trim() : context.getModel().getProject().getName();
|
||||
}, distribution -> distribution));
|
||||
|
||||
Boolean set = (Boolean) context.getModel().getAnnounce().getSdkman().getExtraProperties().remove(MAGIC_SET);
|
||||
if (distributions.isEmpty() && (set != null && !set)) {
|
||||
announceProject();
|
||||
if (distributions.isEmpty()) {
|
||||
if (set == null || !set) {
|
||||
announceProject();
|
||||
} else {
|
||||
context.getLogger().debug("disabled. Skipping");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user