mirror of
https://github.com/jlengrand/jreleaser.git
synced 2026-03-10 08:31:24 +00:00
[chore] simpligy tag name resolution
This commit is contained in:
@@ -64,7 +64,7 @@ public class Discord extends AbstractAnnouncer {
|
||||
Map<String, Object> props = context.props();
|
||||
applyTemplates(props, getResolvedExtraProperties());
|
||||
props.put(KEY_TAG_NAME, context.getModel().getRelease().getGitService()
|
||||
.getEffectiveTagName(context.getModel()));
|
||||
.getEffectiveTagName());
|
||||
props.putAll(extraProps);
|
||||
|
||||
Path templatePath = context.getBasedir().resolve(messageTemplate);
|
||||
|
||||
@@ -69,7 +69,7 @@ public class Discussions extends AbstractAnnouncer {
|
||||
Map<String, Object> props = context.props();
|
||||
applyTemplates(props, getResolvedExtraProperties());
|
||||
props.put(Constants.KEY_TAG_NAME, context.getModel().getRelease().getGitService()
|
||||
.getEffectiveTagName(context.getModel()));
|
||||
.getEffectiveTagName());
|
||||
props.putAll(extraProps);
|
||||
|
||||
Path templatePath = context.getBasedir().resolve(messageTemplate);
|
||||
|
||||
@@ -145,7 +145,7 @@ public abstract class GitService implements Releaser, CommitAuthorAware, OwnerAw
|
||||
|
||||
public String getResolvedTagName(JReleaserModel model) {
|
||||
if (isBlank(cachedTagName)) {
|
||||
cachedTagName = Env.resolve(TAG_NAME, cachedTagName);
|
||||
cachedTagName = getConfiguredTagName();
|
||||
}
|
||||
|
||||
if (isBlank(cachedTagName)) {
|
||||
@@ -157,17 +157,17 @@ public abstract class GitService implements Releaser, CommitAuthorAware, OwnerAw
|
||||
return cachedTagName;
|
||||
}
|
||||
|
||||
public String getEffectiveTagName(JReleaserModel model) {
|
||||
if (model.getProject().isSnapshot()) {
|
||||
return TAG_EARLY_ACCESS;
|
||||
}
|
||||
|
||||
public String getEffectiveTagName() {
|
||||
return cachedTagName;
|
||||
}
|
||||
|
||||
public String getConfiguredReleaseName() {
|
||||
return Env.resolve(RELEASE_NAME, cachedReleaseName);
|
||||
}
|
||||
|
||||
public String getResolvedReleaseName(JReleaserModel model) {
|
||||
if (isBlank(cachedReleaseName)) {
|
||||
cachedReleaseName = Env.resolve(RELEASE_NAME, cachedReleaseName);
|
||||
cachedReleaseName = getConfiguredReleaseName();
|
||||
}
|
||||
|
||||
if (isBlank(cachedReleaseName)) {
|
||||
@@ -620,6 +620,7 @@ public abstract class GitService implements Releaser, CommitAuthorAware, OwnerAw
|
||||
props.put(Constants.KEY_PROJECT_NAME_CAPITALIZED, getClassNameForLowerCaseHyphenSeparatedName(project.getName()));
|
||||
props.put(Constants.KEY_PROJECT_VERSION, project.getVersion());
|
||||
props.put(Constants.KEY_PROJECT_EFFECTIVE_VERSION, project.getEffectiveVersion());
|
||||
props.put(Constants.KEY_PROJECT_SNAPSHOT, String.valueOf(project.isSnapshot()));
|
||||
if (isNotBlank(project.getDescription())) {
|
||||
props.put(Constants.KEY_PROJECT_DESCRIPTION, MustacheUtils.passThrough(project.getDescription()));
|
||||
}
|
||||
@@ -687,7 +688,7 @@ public abstract class GitService implements Releaser, CommitAuthorAware, OwnerAw
|
||||
props.put(Constants.KEY_REPO_BRANCH, branch);
|
||||
props.put(Constants.KEY_REVERSE_REPO_HOST, getReverseRepoHost());
|
||||
props.put(Constants.KEY_CANONICAL_REPO_NAME, getCanonicalRepoName());
|
||||
props.put(Constants.KEY_TAG_NAME, getEffectiveTagName(model));
|
||||
props.put(Constants.KEY_TAG_NAME, getEffectiveTagName());
|
||||
props.put(Constants.KEY_RELEASE_NAME, getEffectiveReleaseName());
|
||||
props.put(Constants.KEY_MILESTONE_NAME, milestone.getEffectiveName());
|
||||
props.put(Constants.KEY_REPO_URL, getResolvedRepoUrl(model));
|
||||
|
||||
@@ -64,7 +64,7 @@ public class Gitter extends AbstractAnnouncer {
|
||||
Map<String, Object> props = context.props();
|
||||
applyTemplates(props, getResolvedExtraProperties());
|
||||
props.put(KEY_TAG_NAME, context.getModel().getRelease().getGitService()
|
||||
.getEffectiveTagName(context.getModel()));
|
||||
.getEffectiveTagName());
|
||||
props.putAll(extraProps);
|
||||
|
||||
Path templatePath = context.getBasedir().resolve(messageTemplate);
|
||||
|
||||
@@ -69,7 +69,7 @@ public class GoogleChat extends AbstractAnnouncer {
|
||||
Map<String, Object> props = context.props();
|
||||
applyTemplates(props, getResolvedExtraProperties());
|
||||
props.put(KEY_TAG_NAME, context.getModel().getRelease().getGitService()
|
||||
.getEffectiveTagName(context.getModel()));
|
||||
.getEffectiveTagName());
|
||||
props.putAll(extraProps);
|
||||
|
||||
Path templatePath = context.getBasedir().resolve(messageTemplate);
|
||||
|
||||
@@ -330,7 +330,7 @@ public class JReleaserContext {
|
||||
props.put(KEY_PROJECT_VERSION, project.getVersion());
|
||||
props.put(KEY_PROJECT_SNAPSHOT, String.valueOf(project.isSnapshot()));
|
||||
GitService gitService = model.getRelease().getGitService();
|
||||
props.put(KEY_TAG_NAME, gitService.getEffectiveTagName(model));
|
||||
props.put(KEY_TAG_NAME, gitService.getEffectiveTagName());
|
||||
if (gitService.isReleaseSupported()) {
|
||||
props.put(KEY_RELEASE_NAME, gitService.getEffectiveReleaseName());
|
||||
props.put(KEY_MILESTONE_NAME, gitService.getMilestone().getEffectiveName());
|
||||
|
||||
@@ -241,6 +241,7 @@ public class JReleaserModel implements Domain {
|
||||
props.put(Constants.KEY_PROJECT_NAME_CAPITALIZED, getClassNameForLowerCaseHyphenSeparatedName(project.getName()));
|
||||
props.put(Constants.KEY_PROJECT_VERSION, project.getVersion());
|
||||
props.put(Constants.KEY_PROJECT_EFFECTIVE_VERSION, project.getEffectiveVersion());
|
||||
props.put(Constants.KEY_PROJECT_SNAPSHOT, String.valueOf(project.isSnapshot()));
|
||||
if (isNotBlank(project.getDescription())) {
|
||||
props.put(Constants.KEY_PROJECT_DESCRIPTION, MustacheUtils.passThrough(project.getDescription()));
|
||||
}
|
||||
@@ -290,7 +291,7 @@ public class JReleaserModel implements Domain {
|
||||
props.put(Constants.KEY_REPO_OWNER, service.getOwner());
|
||||
props.put(Constants.KEY_REPO_NAME, service.getName());
|
||||
props.put(Constants.KEY_REPO_BRANCH, service.getBranch());
|
||||
props.put(Constants.KEY_TAG_NAME, service.getEffectiveTagName(this));
|
||||
props.put(Constants.KEY_TAG_NAME, service.getEffectiveTagName());
|
||||
props.put(Constants.KEY_RELEASE_NAME, service.getEffectiveReleaseName());
|
||||
props.put(Constants.KEY_MILESTONE_NAME, service.getMilestone().getEffectiveName());
|
||||
props.put(Constants.KEY_REVERSE_REPO_HOST, service.getReverseRepoHost());
|
||||
|
||||
@@ -83,14 +83,14 @@ public class Mail extends AbstractAnnouncer {
|
||||
public String getResolvedSubject(JReleaserContext context) {
|
||||
Map<String, Object> props = context.props();
|
||||
applyTemplates(props, getResolvedExtraProperties());
|
||||
props.put(KEY_TAG_NAME, context.getModel().getRelease().getGitService().getEffectiveTagName(context.getModel()));
|
||||
props.put(KEY_TAG_NAME, context.getModel().getRelease().getGitService().getEffectiveTagName());
|
||||
return applyTemplate(subject, props);
|
||||
}
|
||||
|
||||
public String getResolvedMessage(JReleaserContext context) {
|
||||
Map<String, Object> props = context.props();
|
||||
applyTemplates(props, getResolvedExtraProperties());
|
||||
props.put(KEY_TAG_NAME, context.getModel().getRelease().getGitService().getEffectiveTagName(context.getModel()));
|
||||
props.put(KEY_TAG_NAME, context.getModel().getRelease().getGitService().getEffectiveTagName());
|
||||
return applyTemplate(message, props);
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ public class Mail extends AbstractAnnouncer {
|
||||
Map<String, Object> props = context.props();
|
||||
applyTemplates(props, getResolvedExtraProperties());
|
||||
props.put(KEY_TAG_NAME, context.getModel().getRelease().getGitService()
|
||||
.getEffectiveTagName(context.getModel()));
|
||||
.getEffectiveTagName());
|
||||
props.putAll(extraProps);
|
||||
|
||||
Path templatePath = context.getBasedir().resolve(messageTemplate);
|
||||
|
||||
@@ -64,7 +64,7 @@ public class Mattermost extends AbstractAnnouncer {
|
||||
Map<String, Object> props = context.props();
|
||||
applyTemplates(props, getResolvedExtraProperties());
|
||||
props.put(KEY_TAG_NAME, context.getModel().getRelease().getGitService()
|
||||
.getEffectiveTagName(context.getModel()));
|
||||
.getEffectiveTagName());
|
||||
props.putAll(extraProps);
|
||||
|
||||
Path templatePath = context.getBasedir().resolve(messageTemplate);
|
||||
|
||||
@@ -42,13 +42,13 @@ public class Milestone implements Domain {
|
||||
this.name = changelog.name;
|
||||
}
|
||||
|
||||
public String getEffectiveName() {
|
||||
return cachedName;
|
||||
public String getConfiguredName() {
|
||||
return Env.resolve(MILESTONE_NAME, cachedName);
|
||||
}
|
||||
|
||||
public String getResolvedName(Map<String, Object> props) {
|
||||
if (isBlank(cachedName)) {
|
||||
cachedName = Env.resolve(MILESTONE_NAME, cachedName);
|
||||
cachedName = getConfiguredName();
|
||||
}
|
||||
|
||||
if (isBlank(cachedName)) {
|
||||
@@ -60,6 +60,10 @@ public class Milestone implements Domain {
|
||||
return cachedName;
|
||||
}
|
||||
|
||||
public String getEffectiveName() {
|
||||
return cachedName;
|
||||
}
|
||||
|
||||
public Boolean isClose() {
|
||||
return close == null || close;
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public class Slack extends AbstractAnnouncer {
|
||||
Map<String, Object> props = context.props();
|
||||
applyTemplates(props, getResolvedExtraProperties());
|
||||
props.put(KEY_TAG_NAME, context.getModel().getRelease().getGitService()
|
||||
.getEffectiveTagName(context.getModel()));
|
||||
.getEffectiveTagName());
|
||||
props.putAll(extraProps);
|
||||
|
||||
Path templatePath = context.getBasedir().resolve(messageTemplate);
|
||||
|
||||
@@ -56,7 +56,7 @@ public class Teams extends AbstractAnnouncer {
|
||||
Map<String, Object> props = context.props();
|
||||
applyTemplates(props, getResolvedExtraProperties());
|
||||
props.put(KEY_TAG_NAME, context.getModel().getRelease().getGitService()
|
||||
.getEffectiveTagName(context.getModel()));
|
||||
.getEffectiveTagName());
|
||||
props.putAll(extraProps);
|
||||
|
||||
Path templatePath = context.getBasedir().resolve(messageTemplate);
|
||||
|
||||
@@ -64,7 +64,7 @@ public class Webhook extends AbstractAnnouncer {
|
||||
Map<String, Object> props = context.props();
|
||||
applyTemplates(props, getResolvedExtraProperties());
|
||||
props.put(KEY_TAG_NAME, context.getModel().getRelease().getGitService()
|
||||
.getEffectiveTagName(context.getModel()));
|
||||
.getEffectiveTagName());
|
||||
props.putAll(extraProps);
|
||||
|
||||
Path templatePath = context.getBasedir().resolve(messageTemplate);
|
||||
|
||||
@@ -78,7 +78,7 @@ public class Zulip extends AbstractAnnouncer {
|
||||
Map<String, Object> props = context.props();
|
||||
applyTemplates(props, getResolvedExtraProperties());
|
||||
props.put(KEY_TAG_NAME, context.getModel().getRelease().getGitService()
|
||||
.getEffectiveTagName(context.getModel()));
|
||||
.getEffectiveTagName());
|
||||
props.putAll(extraProps);
|
||||
|
||||
Path templatePath = context.getBasedir().resolve(messageTemplate);
|
||||
|
||||
@@ -26,7 +26,6 @@ import org.jreleaser.model.JReleaserModel;
|
||||
import org.jreleaser.model.Project;
|
||||
import org.jreleaser.model.UpdateSection;
|
||||
import org.jreleaser.util.Errors;
|
||||
import org.jreleaser.util.StringUtils;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.util.List;
|
||||
@@ -178,13 +177,10 @@ public abstract class GitServiceValidator extends Validator {
|
||||
}
|
||||
|
||||
if (project.isSnapshot()) {
|
||||
String projectName = StringUtils.getClassNameForLowerCaseHyphenSeparatedName(project.getName());
|
||||
projectName = StringUtils.getNaturalName(projectName);
|
||||
service.getChangelog().setEnabled(true);
|
||||
service.getChangelog().setExternal(null);
|
||||
service.getChangelog().setSort(Changelog.Sort.DESC);
|
||||
if (service.isReleaseSupported()) {
|
||||
service.setReleaseName(projectName + " Early-Access");
|
||||
service.setOverwrite(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package org.jreleaser.model.validation;
|
||||
|
||||
import org.jreleaser.model.Distribution;
|
||||
import org.jreleaser.model.GitService;
|
||||
import org.jreleaser.model.JReleaserContext;
|
||||
import org.jreleaser.model.Project;
|
||||
import org.jreleaser.model.VersionPattern;
|
||||
@@ -67,6 +68,10 @@ public abstract class ProjectValidator extends Validator {
|
||||
project.getSnapshotPattern(),
|
||||
DEFAULT_SNAPSHOT_PATTERN));
|
||||
|
||||
if (project.isSnapshot()) {
|
||||
context.getModel().getRelease().getGitService().setTagName(GitService.TAG_EARLY_ACCESS);
|
||||
}
|
||||
|
||||
boolean javaDistributions = context.getModel().getDistributions().values().stream()
|
||||
.map(Distribution::getType)
|
||||
.anyMatch(type -> type == Distribution.DistributionType.JAVA_BINARY ||
|
||||
|
||||
@@ -47,7 +47,7 @@ public class GenericGitReleaser implements Releaser {
|
||||
org.jreleaser.model.GenericGit generic = context.getModel().getRelease().getGeneric();
|
||||
context.getLogger().info("Releasing to a generic Git repository is not supported");
|
||||
context.getLogger().info("Tagging {}", repository.getHttpUrl());
|
||||
String tagName = generic.getEffectiveTagName(context.getModel());
|
||||
String tagName = generic.getEffectiveTagName();
|
||||
|
||||
context.getLogger().debug("looking up tag {}", tagName);
|
||||
boolean tagged = git.findTag(tagName);
|
||||
|
||||
@@ -166,7 +166,7 @@ public class ChangelogGenerator {
|
||||
List<Ref> tags = git.tagList().call();
|
||||
|
||||
GitService gitService = context.getModel().getRelease().getGitService();
|
||||
String effectiveTagName = gitService.getEffectiveTagName(context.getModel());
|
||||
String effectiveTagName = gitService.getEffectiveTagName();
|
||||
String tagName = gitService.getConfiguredTagName();
|
||||
String tagPattern = tagName.replaceAll("\\{\\{.*}}", "\\.\\*");
|
||||
Pattern vp = Pattern.compile(tagName.replaceAll("\\{\\{.*}}", "\\(\\.\\*\\)"));
|
||||
|
||||
@@ -61,7 +61,7 @@ public class GiteaReleaser implements Releaser {
|
||||
public void release() throws ReleaseException {
|
||||
org.jreleaser.model.Gitea gitea = resolveGiteaFromModel();
|
||||
context.getLogger().info("Releasing to {}", gitea.getResolvedRepoUrl(context.getModel()));
|
||||
String tagName = gitea.getEffectiveTagName(context.getModel());
|
||||
String tagName = gitea.getEffectiveTagName();
|
||||
|
||||
try {
|
||||
String changelog = context.getChangelog();
|
||||
|
||||
@@ -51,7 +51,7 @@ public class GithubReleaser implements Releaser {
|
||||
public void release() throws ReleaseException {
|
||||
org.jreleaser.model.Github github = context.getModel().getRelease().getGithub();
|
||||
context.getLogger().info("Releasing to {}", github.getResolvedRepoUrl(context.getModel()));
|
||||
String tagName = github.getEffectiveTagName(context.getModel());
|
||||
String tagName = github.getEffectiveTagName();
|
||||
|
||||
try {
|
||||
String changelog = context.getChangelog();
|
||||
|
||||
@@ -52,7 +52,7 @@ public class GitlabReleaser implements Releaser {
|
||||
public void release() throws ReleaseException {
|
||||
org.jreleaser.model.Gitlab gitlab = context.getModel().getRelease().getGitlab();
|
||||
context.getLogger().info("Releasing to {}", gitlab.getResolvedRepoUrl(context.getModel()));
|
||||
String tagName = gitlab.getEffectiveTagName(context.getModel());
|
||||
String tagName = gitlab.getEffectiveTagName();
|
||||
|
||||
try {
|
||||
String changelog = context.getChangelog();
|
||||
|
||||
Reference in New Issue
Block a user