[announce] Support announcing to Mattermost. Resolves #167

This commit is contained in:
Andres Almiray
2021-05-24 12:06:04 +02:00
parent 65b0e520d3
commit cc7ea8eba4
18 changed files with 651 additions and 0 deletions

View File

@@ -35,6 +35,7 @@ public class Announce implements Domain, EnabledAware {
private final Gitter gitter = new Gitter();
private final Mail mail = new Mail();
private final Mastodon mastodon = new Mastodon();
private final Mattermost mattermost = new Mattermost();
private final Sdkman sdkman = new Sdkman();
private final Slack slack = new Slack();
private final Teams teams = new Teams();
@@ -49,6 +50,7 @@ public class Announce implements Domain, EnabledAware {
setGitter(announce.gitter);
setMail(announce.mail);
setMastodon(announce.mastodon);
setMattermost(announce.mattermost);
setSdkman(announce.sdkman);
setSlack(announce.slack);
setTeams(announce.teams);
@@ -111,6 +113,14 @@ public class Announce implements Domain, EnabledAware {
this.mastodon.setAll(mastodon);
}
public Mattermost getMattermost() {
return mattermost;
}
public void setMattermost(Mattermost mattermost) {
this.mattermost.setAll(mattermost);
}
public Sdkman getSdkman() {
return sdkman;
}
@@ -160,6 +170,7 @@ public class Announce implements Domain, EnabledAware {
map.putAll(gitter.asMap(full));
map.putAll(mail.asMap(full));
map.putAll(mastodon.asMap(full));
map.putAll(mattermost.asMap(full));
map.putAll(sdkman.asMap(full));
map.putAll(slack.asMap(full));
map.putAll(teams.asMap(full));
@@ -196,6 +207,8 @@ public class Announce implements Domain, EnabledAware {
return (A) getMail();
case Mastodon.NAME:
return (A) getMastodon();
case Mattermost.NAME:
return (A) getMattermost();
case Sdkman.NAME:
return (A) getSdkman();
case Slack.NAME:
@@ -218,6 +231,7 @@ public class Announce implements Domain, EnabledAware {
set.add(Gitter.NAME);
set.add(Mail.NAME);
set.add(Mastodon.NAME);
set.add(Mattermost.NAME);
set.add(Sdkman.NAME);
set.add(Slack.NAME);
set.add(Teams.NAME);

View File

@@ -0,0 +1,111 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2020-2021 Andres Almiray.
*
* 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;
import org.jreleaser.util.Env;
import java.io.IOException;
import java.io.Reader;
import java.nio.file.Path;
import java.util.Map;
import static org.jreleaser.util.Constants.HIDE;
import static org.jreleaser.util.Constants.KEY_TAG_NAME;
import static org.jreleaser.util.Constants.UNSET;
import static org.jreleaser.util.MustacheUtils.applyTemplate;
import static org.jreleaser.util.StringUtils.isNotBlank;
/**
* @author Andres Almiray
* @since 0.4.0
*/
public class Mattermost extends AbstractAnnouncer {
public static final String NAME = "mattermost";
public static final String MATTERMOST_WEBHOOK = "MATTERMOST_WEBHOOK";
private String webhook;
private String message;
private String messageTemplate;
public Mattermost() {
super(NAME);
}
void setAll(Mattermost mattermost) {
super.setAll(mattermost);
this.webhook = mattermost.webhook;
this.message = mattermost.message;
this.messageTemplate = mattermost.messageTemplate;
}
public String getResolvedMessage(JReleaserContext context) {
Map<String, Object> props = context.props();
return applyTemplate(message, props);
}
public String getResolvedMessageTemplate(JReleaserContext context, Map<String, Object> extraProps) {
Map<String, Object> props = context.props();
props.put(KEY_TAG_NAME, context.getModel().getRelease().getGitService()
.getEffectiveTagName(context.getModel()));
props.putAll(extraProps);
Path templatePath = context.getBasedir().resolve(messageTemplate);
try {
Reader reader = java.nio.file.Files.newBufferedReader(templatePath);
return applyTemplate(reader, props);
} catch (IOException e) {
throw new JReleaserException("Unexpected error reading template " +
context.getBasedir().relativize(templatePath));
}
}
public String getResolvedWebhook() {
return Env.resolve(MATTERMOST_WEBHOOK, webhook);
}
public String getWebhook() {
return webhook;
}
public void setWebhook(String webhook) {
this.webhook = webhook;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getMessageTemplate() {
return messageTemplate;
}
public void setMessageTemplate(String messageTemplate) {
this.messageTemplate = messageTemplate;
}
@Override
protected void asMap(Map<String, Object> props) {
props.put("webhook", isNotBlank(getResolvedWebhook()) ? HIDE : UNSET);
props.put("message", message);
props.put("messageTemplate", messageTemplate);
}
}

View File

@@ -26,6 +26,7 @@ import static org.jreleaser.model.validation.DiscussionsValidator.validateDiscus
import static org.jreleaser.model.validation.GitterValidator.validateGitter;
import static org.jreleaser.model.validation.MailValidator.validateMail;
import static org.jreleaser.model.validation.MastodonValidator.validateMastodon;
import static org.jreleaser.model.validation.MattermostValidator.validateMattermost;
import static org.jreleaser.model.validation.SdkmanValidator.validateSdkman;
import static org.jreleaser.model.validation.SlackValidator.validateSlack;
import static org.jreleaser.model.validation.TeamsValidator.validateTeams;
@@ -50,6 +51,7 @@ public abstract class AnnouncersValidator extends Validator {
validateGitter(context, announce.getGitter(), errors);
validateMail(context, announce.getMail(), errors);
validateMastodon(context, announce.getMastodon(), errors);
validateMattermost(context, announce.getMattermost(), errors);
validateSdkman(context, announce.getSdkman(), errors);
validateSlack(context, announce.getSlack(), errors);
validateTeams(context, announce.getTeams(), errors);
@@ -62,6 +64,7 @@ public abstract class AnnouncersValidator extends Validator {
announce.getGitter().isEnabled() ||
announce.getMail().isEnabled() ||
announce.getMastodon().isEnabled() ||
announce.getMattermost().isEnabled() ||
announce.getSdkman().isEnabled() ||
announce.getSlack().isEnabled() ||
announce.getTeams().isEnabled() ||

View File

@@ -0,0 +1,68 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2020-2021 Andres Almiray.
*
* 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.validation;
import org.jreleaser.model.JReleaserContext;
import org.jreleaser.model.Mattermost;
import org.jreleaser.util.Errors;
import java.nio.file.Files;
import static org.jreleaser.model.Mattermost.MATTERMOST_WEBHOOK;
import static org.jreleaser.util.StringUtils.isBlank;
import static org.jreleaser.util.StringUtils.isNotBlank;
/**
* @author Andres Almiray
* @since 0.4.0
*/
public abstract class MattermostValidator extends Validator {
private static final String DEFAULT_MATTERMOST_TPL = "src/jreleaser/templates/mattermost.tpl";
public static void validateMattermost(JReleaserContext context, Mattermost mattermost, Errors errors) {
if (!mattermost.resolveEnabled(context.getModel().getProject())) return;
context.getLogger().debug("announce.mattermost");
mattermost.setWebhook(
checkProperty(context.getModel().getEnvironment(),
MATTERMOST_WEBHOOK,
"mattermost.webhook",
mattermost.getWebhook(),
errors));
if (isBlank(mattermost.getMessage()) && isBlank(mattermost.getMessageTemplate())) {
if (Files.exists(context.getBasedir().resolve(DEFAULT_MATTERMOST_TPL))) {
mattermost.setMessageTemplate(DEFAULT_MATTERMOST_TPL);
} else {
mattermost.setMessage("\uD83D\uDE80 {{projectNameCapitalized}} {{projectVersion}} has been released! {{releaseNotesUrl}}");
}
}
if (isNotBlank(mattermost.getMessageTemplate()) &&
!Files.exists(context.getBasedir().resolve(mattermost.getMessageTemplate().trim()))) {
errors.configuration("mattermost.messageTemplate does not exist. " + mattermost.getMessageTemplate());
}
if (mattermost.getConnectTimeout() <= 0 || mattermost.getConnectTimeout() > 300) {
mattermost.setConnectTimeout(20);
}
if (mattermost.getReadTimeout() <= 0 || mattermost.getReadTimeout() > 300) {
mattermost.setReadTimeout(60);
}
}
}

View File

@@ -22,6 +22,7 @@ dependencies {
api project(':gitter-java-sdk')
api project(':mail-java-sdk')
api project(':mastodon-java-sdk')
api project(':mattermost-java-sdk')
api project(':sdkman-java-sdk')
api project(':slack-java-sdk')
api project(':teams-java-sdk')

View File

@@ -40,6 +40,8 @@ interface Announce {
Mastodon getMastodon()
Mattermost getMattermost()
Sdkman getSdkman()
Slack getSlack()
@@ -60,6 +62,8 @@ interface Announce {
void mastodon(Action<? super Mastodon> action)
void mattermost(Action<? super Mattermost> action)
void sdkman(Action<? super Sdkman> action)
void slack(Action<? super Slack> action)
@@ -80,6 +84,8 @@ interface Announce {
void mastodon(@DelegatesTo(strategy = Closure.DELEGATE_FIRST, value = Mastodon) Closure<Void> action)
void mattermost(@DelegatesTo(strategy = Closure.DELEGATE_FIRST, value = Mattermost) Closure<Void> action)
void sdkman(@DelegatesTo(strategy = Closure.DELEGATE_FIRST, value = Sdkman) Closure<Void> action)
void slack(@DelegatesTo(strategy = Closure.DELEGATE_FIRST, value = Slack) Closure<Void> action)

View File

@@ -0,0 +1,36 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2020-2021 Andres Almiray.
*
* 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.gradle.plugin.dsl
import groovy.transform.CompileStatic
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.Property
/**
*
* @author Andres Almiray
* @since 0.4.0
*/
@CompileStatic
interface Mattermost extends Announcer {
Property<String> getWebhook()
Property<String> getMessage()
RegularFileProperty getMessageTemplate()
}

View File

@@ -28,6 +28,7 @@ import org.jreleaser.gradle.plugin.dsl.Discussions
import org.jreleaser.gradle.plugin.dsl.Gitter
import org.jreleaser.gradle.plugin.dsl.Mail
import org.jreleaser.gradle.plugin.dsl.Mastodon
import org.jreleaser.gradle.plugin.dsl.Mattermost
import org.jreleaser.gradle.plugin.dsl.Sdkman
import org.jreleaser.gradle.plugin.dsl.Slack
import org.jreleaser.gradle.plugin.dsl.Teams
@@ -50,6 +51,7 @@ class AnnounceImpl implements Announce {
final GitterImpl gitter
final MailImpl mail
final MastodonImpl mastodon
final MattermostImpl mattermost
final SdkmanImpl sdkman
final SlackImpl slack
final TeamsImpl teams
@@ -64,6 +66,7 @@ class AnnounceImpl implements Announce {
gitter = objects.newInstance(GitterImpl, objects)
mail = objects.newInstance(MailImpl, objects)
mastodon = objects.newInstance(MastodonImpl, objects)
mattermost = objects.newInstance(MattermostImpl, objects)
sdkman = objects.newInstance(SdkmanImpl, objects)
slack = objects.newInstance(SlackImpl, objects)
teams = objects.newInstance(TeamsImpl, objects)
@@ -96,6 +99,11 @@ class AnnounceImpl implements Announce {
action.execute(mastodon)
}
@Override
void mattermost(Action<? super Mattermost> action) {
action.execute(mattermost)
}
@Override
void sdkman(Action<? super Sdkman> action) {
action.execute(sdkman)
@@ -146,6 +154,11 @@ class AnnounceImpl implements Announce {
ConfigureUtil.configure(action, mastodon)
}
@Override
void mattermost(@DelegatesTo(strategy = Closure.DELEGATE_FIRST, value = Mattermost) Closure<Void> action) {
ConfigureUtil.configure(action, mattermost)
}
@Override
void sdkman(@DelegatesTo(strategy = Closure.DELEGATE_FIRST, value = Sdkman) Closure<Void> action) {
ConfigureUtil.configure(action, sdkman)
@@ -179,6 +192,7 @@ class AnnounceImpl implements Announce {
if (gitter.isSet()) announce.gitter = gitter.toModel()
if (mail.isSet()) announce.mail = mail.toModel()
if (mastodon.isSet()) announce.mastodon = mastodon.toModel()
if (mattermost.isSet()) announce.mattermost = mattermost.toModel()
if (sdkman.isSet()) announce.sdkman = sdkman.toModel()
if (slack.isSet()) announce.slack = slack.toModel()
if (teams.isSet()) announce.teams = teams.toModel()

View File

@@ -0,0 +1,68 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2020-2021 Andres Almiray.
*
* 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.gradle.plugin.internal.dsl
import groovy.transform.CompileStatic
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.internal.provider.Providers
import org.gradle.api.model.ObjectFactory
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Internal
import org.jreleaser.gradle.plugin.dsl.Mattermost
import javax.inject.Inject
/**
*
* @author Andres Almiray
* @since 0.4.0
*/
@CompileStatic
class MattermostImpl extends AbstractAnnouncer implements Mattermost {
final Property<String> webhook
final Property<String> message
final RegularFileProperty messageTemplate
@Inject
MattermostImpl(ObjectFactory objects) {
super(objects)
webhook = objects.property(String).convention(Providers.notDefined())
message = objects.property(String).convention(Providers.notDefined())
messageTemplate = objects.fileProperty().convention(Providers.notDefined())
}
@Override
@Internal
boolean isSet() {
super.isSet() ||
webhook.present ||
message.present ||
messageTemplate.present
}
org.jreleaser.model.Mattermost toModel() {
org.jreleaser.model.Mattermost mattermost = new org.jreleaser.model.Mattermost()
fillProperties(mattermost)
if (webhook.present) mattermost.webhook = webhook.get()
if (message.present) mattermost.message = message.get()
if (messageTemplate.present) {
mattermost.messageTemplate = messageTemplate.asFile.get().absolutePath
}
mattermost
}
}

View File

@@ -27,6 +27,7 @@ public class Announce implements EnabledAware {
private final Gitter gitter = new Gitter();
private final Mail mail = new Mail();
private final Mastodon mastodon = new Mastodon();
private final Mattermost mattermost = new Mattermost();
private final Sdkman sdkman = new Sdkman();
private final Slack slack = new Slack();
private final Teams teams = new Teams();
@@ -103,6 +104,14 @@ public class Announce implements EnabledAware {
this.mastodon.setAll(mastodon);
}
public Mattermost getMattermost() {
return mattermost;
}
public void setMattermost(Mattermost mattermost) {
this.mattermost.setAll(mattermost);
}
public Sdkman getSdkman() {
return sdkman;
}

View File

@@ -0,0 +1,69 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2020-2021 Andres Almiray.
*
* 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.maven.plugin;
import static org.jreleaser.util.StringUtils.isNotBlank;
/**
* @author Andres Almiray
* @since 0.4.0
*/
public class Mattermost extends AbstractAnnouncer {
private String webhook;
private String message;
private String messageTemplate;
void setAll(Mattermost mattermost) {
super.setAll(mattermost);
this.webhook = mattermost.webhook;
this.message = mattermost.message;
this.messageTemplate = mattermost.messageTemplate;
}
public String getWebhook() {
return webhook;
}
public void setWebhook(String webhook) {
this.webhook = webhook;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getMessageTemplate() {
return messageTemplate;
}
public void setMessageTemplate(String messageTemplate) {
this.messageTemplate = messageTemplate;
}
@Override
public boolean isSet() {
return super.isSet() ||
isNotBlank(webhook) ||
isNotBlank(message) ||
isNotBlank(messageTemplate);
}
}

View File

@@ -51,6 +51,7 @@ import org.jreleaser.maven.plugin.Jlink;
import org.jreleaser.maven.plugin.Jreleaser;
import org.jreleaser.maven.plugin.Mail;
import org.jreleaser.maven.plugin.Mastodon;
import org.jreleaser.maven.plugin.Mattermost;
import org.jreleaser.maven.plugin.Milestone;
import org.jreleaser.maven.plugin.NativeImage;
import org.jreleaser.maven.plugin.Packagers;
@@ -369,6 +370,7 @@ public final class JReleaserModelConverter {
if (announce.getGitter().isSet()) a.setGitter(convertGitter(announce.getGitter()));
if (announce.getMail().isSet()) a.setMail(convertMail(announce.getMail()));
if (announce.getMastodon().isSet()) a.setMastodon(convertMastodon(announce.getMastodon()));
if (announce.getMattermost().isSet()) a.setMattermost(convertMattermost(announce.getMattermost()));
if (announce.getSdkman().isSet()) a.setSdkman(convertSdkman(announce.getSdkman()));
if (announce.getSlack().isSet()) a.setSlack(convertSlack(announce.getSlack()));
if (announce.getTeams().isSet()) a.setTeams(convertTeams(announce.getTeams()));
@@ -442,6 +444,17 @@ public final class JReleaserModelConverter {
return a;
}
private static org.jreleaser.model.Mattermost convertMattermost(Mattermost mattermost) {
org.jreleaser.model.Mattermost a = new org.jreleaser.model.Mattermost();
a.setActive(mattermost.resolveActive());
a.setWebhook(mattermost.getWebhook());
a.setMessage(mattermost.getMessage());
a.setMessageTemplate(mattermost.getMessageTemplate());
a.setConnectTimeout(mattermost.getConnectTimeout());
a.setReadTimeout(mattermost.getReadTimeout());
return a;
}
private static org.jreleaser.model.Sdkman convertSdkman(Sdkman sdkman) {
org.jreleaser.model.Sdkman a = new org.jreleaser.model.Sdkman();
a.setActive(sdkman.resolveActive());

View File

@@ -0,0 +1,19 @@
#
# SPDX-License-Identifier: Apache-2.0
#
# Copyright 2020-2021 Andres Almiray.
#
# 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.
#
project_description = Java SDK for Mattermost

View File

@@ -0,0 +1,24 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2020-2021 Andres Almiray.
*
* 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.
*/
dependencies {
compileOnly "org.kordamp.jipsy:jipsy-annotations:${jipsyVersion}"
annotationProcessor "org.kordamp.jipsy:jipsy-processor:${jipsyVersion}"
api project(':jreleaser-model')
api project(':java-sdk-commons')
}

View File

@@ -0,0 +1,78 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2020-2021 Andres Almiray.
*
* 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.sdk.mattermost;
import org.jreleaser.model.Mattermost;
import org.jreleaser.model.JReleaserContext;
import org.jreleaser.model.announcer.spi.AnnounceException;
import org.jreleaser.model.announcer.spi.Announcer;
import org.jreleaser.sdk.commons.ClientUtils;
import org.jreleaser.util.Constants;
import org.jreleaser.util.MustacheUtils;
import java.util.LinkedHashMap;
import java.util.Map;
import static org.jreleaser.util.StringUtils.isNotBlank;
/**
* @author Andres Almiray
* @since 0.4.0
*/
public class MattermostAnnouncer implements Announcer {
private final JReleaserContext context;
MattermostAnnouncer(JReleaserContext context) {
this.context = context;
}
@Override
public String getName() {
return org.jreleaser.model.Mattermost.NAME;
}
@Override
public boolean isEnabled() {
return context.getModel().getAnnounce().getMattermost().isEnabled();
}
@Override
public void announce() throws AnnounceException {
Mattermost mattermost = context.getModel().getAnnounce().getMattermost();
String message = "";
if (isNotBlank(mattermost.getMessage())) {
message = mattermost.getResolvedMessage(context);
} else {
Map<String, Object> props = new LinkedHashMap<>();
props.put(Constants.KEY_CHANGELOG, MustacheUtils.passThrough(context.getChangelog()));
context.getModel().getRelease().getGitService().fillProps(props, context.getModel());
message = mattermost.getResolvedMessageTemplate(context, props);
}
context.getLogger().info("message: {}", message);
if (!context.isDryrun()) {
ClientUtils.webhook(context.getLogger(),
mattermost.getResolvedWebhook(),
mattermost.getConnectTimeout(),
mattermost.getReadTimeout(),
Message.of(message));
}
}
}

View File

@@ -0,0 +1,33 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2020-2021 Andres Almiray.
*
* 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.sdk.mattermost;
import org.jreleaser.model.announcer.spi.AbstractAnnouncerBuilder;
/**
* @author Andres Almiray
* @since 0.4.0
*/
public class MattermostAnnouncerBuilder extends AbstractAnnouncerBuilder<MattermostAnnouncer> {
@Override
public MattermostAnnouncer build() {
validate();
return new MattermostAnnouncer(context);
}
}

View File

@@ -0,0 +1,38 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2020-2021 Andres Almiray.
*
* 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.sdk.mattermost;
import org.jreleaser.model.announcer.spi.AnnouncerBuilderFactory;
import org.kordamp.jipsy.annotations.ServiceProviderFor;
/**
* @author Andres Almiray
* @since 0.4.0
*/
@ServiceProviderFor(AnnouncerBuilderFactory.class)
public class MattermostAnnouncerBuilderFactory implements AnnouncerBuilderFactory<MattermostAnnouncer, MattermostAnnouncerBuilder> {
@Override
public String getName() {
return org.jreleaser.model.Mattermost.NAME;
}
@Override
public MattermostAnnouncerBuilder getBuilder() {
return new MattermostAnnouncerBuilder();
}
}

View File

@@ -0,0 +1,47 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2020-2021 Andres Almiray.
*
* 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.sdk.mattermost;
/**
* @author Andres Almiray
* @since 0.4.0
*/
public class Message {
private String text;
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
@Override
public String toString() {
return "Message[" +
"text='" + text + '\'' +
"]";
}
public static Message of(String text) {
Message message = new Message();
message.text = text;
return message;
}
}