[announce] discussions should have a default message. Related to
@@ -32,6 +32,8 @@ import static org.jreleaser.util.StringUtils.isNotBlank;
* @since 0.1.0
*/
public abstract class DiscussionsValidator extends Validator {
+ private static final String DEFAULT_DISCUSSIONS_TPL = "src/jreleaser/templates/discussions.tpl";
+
public static void validateDiscussions(JReleaserContext context, Discussions discussions, List<String> errors) {
if (!discussions.isEnabled()) return;
@@ -57,6 +59,14 @@ public abstract class DiscussionsValidator extends Validator {
discussions.setMessageTemplate("src/jreleaser/templates/discussions.tpl");
}
+ if (isBlank(discussions.getMessage()) && isBlank(discussions.getMessageTemplate())) {
+ if (Files.exists(context.getBasedir().resolve(DEFAULT_DISCUSSIONS_TPL))) {
+ discussions.setMessageTemplate(DEFAULT_DISCUSSIONS_TPL);
+ } else {
+ discussions.setMessage("\uD83D\uDE80 {{projectNameCapitalized}} {{projectVersion}} has been released! {{releaseNotesUrl}}");
+ }
+ }
+
if (isNotBlank(discussions.getMessageTemplate()) &&
!Files.exists(context.getBasedir().resolve(discussions.getMessageTemplate().trim()))) {
errors.add("discussions.messageTemplate does not exist. " + discussions.getMessageTemplate());
