tools.bestquality.maven.ci.VersionTemplate Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ci-maven-plugin Show documentation
Show all versions of ci-maven-plugin Show documentation
Maven plugin for building and releasing from CI pipelines
package tools.bestquality.maven.ci;
import static java.lang.String.format;
import static org.codehaus.plexus.util.StringUtils.isEmpty;
@FunctionalInterface
public interface VersionTemplate {
String expand(String revision, String sha1, String changelist)
throws Exception;
static VersionTemplate template(String template) {
return (revision, sha1, changelist) -> {
// First expand all ci-friendly property references
String expanded = template
.replace("${revision}", revision != null ? revision : "${revision}")
.replace("${sha1}", sha1 != null ? sha1 : "${sha1}")
.replace("${changelist}", changelist != null ? changelist : "${changelist}");
// Next update the property definitions
if (revision != null) {
expanded = expanded.replaceAll(".* | ",
isEmpty(revision)
? " "
: format("%s ", revision));
}
if (sha1 != null) {
expanded = expanded.replaceAll(".* | ",
isEmpty(sha1)
? " "
: format("%s ", sha1));
}
if (changelist != null) {
expanded = expanded.replaceAll(".* | ",
isEmpty(changelist)
? " "
: format("%s ", changelist));
}
return expanded;
};
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy