Skip to content

Commit

Permalink
[announce] let sdkman.releaseNotesUrl be configurable. Resolves #296
Browse files Browse the repository at this point in the history
  • Loading branch information
aalmiray committed Jul 18, 2021
1 parent 4ca0bfa commit 2ec572a
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 2 deletions.
11 changes: 11 additions & 0 deletions core/jreleaser-model/src/main/java/org/jreleaser/model/Sdkman.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class Sdkman extends AbstractAnnouncer {
private String consumerKey;
private String consumerToken;
private String candidate;
private String releaseNotesUrl;
private boolean major = true;

public Sdkman() {
Expand All @@ -48,6 +49,7 @@ void setAll(Sdkman sdkman) {
this.consumerKey = sdkman.consumerKey;
this.consumerToken = sdkman.consumerToken;
this.candidate = sdkman.candidate;
this.releaseNotesUrl = sdkman.releaseNotesUrl;
this.major = sdkman.major;
}

Expand Down Expand Up @@ -88,6 +90,14 @@ public void setCandidate(String candidate) {
this.candidate = candidate;
}

public String getReleaseNotesUrl() {
return releaseNotesUrl;
}

public void setReleaseNotesUrl(String releaseNotesUrl) {
this.releaseNotesUrl = releaseNotesUrl;
}

public boolean isMajor() {
return major;
}
Expand All @@ -101,6 +111,7 @@ protected void asMap(Map<String, Object> props, boolean full) {
props.put("consumerKey", isNotBlank(getResolvedConsumerKey()) ? HIDE : UNSET);
props.put("consumerToken", isNotBlank(getResolvedConsumerToken()) ? HIDE : UNSET);
props.put("candidate", candidate);
props.put("releaseNotesUrl", releaseNotesUrl);
props.put("major", major);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import static org.jreleaser.model.Sdkman.SDKMAN_CONSUMER_KEY;
import static org.jreleaser.model.Sdkman.SDKMAN_CONSUMER_TOKEN;
import static org.jreleaser.util.StringUtils.isBlank;

/**
* @author Andres Almiray
Expand Down Expand Up @@ -54,6 +55,10 @@ public static void validateSdkman(JReleaserContext context, Sdkman sdkman, Error
errors,
context.isDryrun()));

if (isBlank(sdkman.getReleaseNotesUrl())) {
sdkman.setReleaseNotesUrl(context.getModel().getRelease().getGitService().getReleaseNotesUrl());
}

if (context.getModel().getActiveDistributions().isEmpty()) {
context.getLogger().warn("There are no active distributions. Disabling Sdkman announcer");
sdkman.disable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,7 @@ interface Sdkman extends Announcer {

Property<String> getCandidate()

Property<String> getReleaseNotesUrl()

Property<Boolean> getMajor()
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class SdkmanImpl extends AbstractAnnouncer implements Sdkman {
final Property<String> consumerKey
final Property<String> consumerToken
final Property<String> candidate
final Property<String> releaseNotesUrl
final Property<Boolean> major

@Inject
Expand All @@ -44,6 +45,7 @@ class SdkmanImpl extends AbstractAnnouncer implements Sdkman {
consumerKey = objects.property(String).convention(Providers.notDefined())
consumerToken = objects.property(String).convention(Providers.notDefined())
candidate = objects.property(String).convention(Providers.notDefined())
releaseNotesUrl = objects.property(String).convention(Providers.notDefined())
major = objects.property(Boolean).convention(Providers.notDefined())
}

Expand All @@ -54,6 +56,7 @@ class SdkmanImpl extends AbstractAnnouncer implements Sdkman {
consumerKey.present ||
consumerToken.present ||
candidate.present ||
releaseNotesUrl.present ||
major.present
}

Expand All @@ -63,6 +66,7 @@ class SdkmanImpl extends AbstractAnnouncer implements Sdkman {
if (consumerKey.present) sdkman.consumerKey = consumerKey.get()
if (consumerToken.present) sdkman.consumerToken = consumerToken.get()
if (candidate.present) sdkman.candidate = candidate.get()
if (releaseNotesUrl.present) sdkman.releaseNotesUrl = releaseNotesUrl.get()
sdkman.major = major.getOrElse(true)
sdkman
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ public class Sdkman extends AbstractAnnouncer {
private String consumerKey;
private String consumerToken;
private String candidate;
private String releaseNotesUrl;
private boolean major = true;

void setAll(Sdkman sdkman) {
super.setAll(sdkman);
this.consumerKey = sdkman.consumerKey;
this.consumerToken = sdkman.consumerToken;
this.candidate = sdkman.candidate;
this.releaseNotesUrl = sdkman.releaseNotesUrl;
this.major = sdkman.major;
}

Expand Down Expand Up @@ -61,6 +63,14 @@ public void setCandidate(String candidate) {
this.candidate = candidate;
}

public String getReleaseNotesUrl() {
return releaseNotesUrl;
}

public void setReleaseNotesUrl(String releaseNotesUrl) {
this.releaseNotesUrl = releaseNotesUrl;
}

public boolean isMajor() {
return major;
}
Expand All @@ -74,6 +84,7 @@ public boolean isSet() {
return super.isSet() ||
isNotBlank(consumerKey) ||
isNotBlank(consumerToken) ||
isNotBlank(candidate);
isNotBlank(candidate) ||
isNotBlank(releaseNotesUrl);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@ private static org.jreleaser.model.Sdkman convertSdkman(Sdkman sdkman) {
a.setConsumerKey(sdkman.getConsumerKey());
a.setConsumerToken(sdkman.getConsumerToken());
a.setCandidate(sdkman.getCandidate());
a.setReleaseNotesUrl(sdkman.getReleaseNotesUrl());
a.setMajor(sdkman.isMajor());
a.setConnectTimeout(sdkman.getConnectTimeout());
a.setReadTimeout(sdkman.getReadTimeout());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void announce() throws AnnounceException {

try {
String candidate = isNotBlank(sdkman.getCandidate()) ? sdkman.getCandidate().trim() : context.getModel().getProject().getName();
String releaseNotesUrl = context.getModel().getRelease().getGitService().getResolvedReleaseNotesUrl(context.getModel());
String releaseNotesUrl = applyTemplate(sdkman.getReleaseNotesUrl(), context.props());

if (sdkman.isMajor()) {
context.getLogger().info("Announcing major release of '{}' candidate", candidate);
Expand Down

0 comments on commit 2ec572a

Please sign in to comment.