diff --git a/src/main/java/de/dentrassi/maven/osgi/dp/AbstractDpMojo.java b/src/main/java/de/dentrassi/maven/osgi/dp/AbstractDpMojo.java index bc7257b..fc72fd5 100644 --- a/src/main/java/de/dentrassi/maven/osgi/dp/AbstractDpMojo.java +++ b/src/main/java/de/dentrassi/maven/osgi/dp/AbstractDpMojo.java @@ -30,12 +30,15 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Optional; +import java.util.Properties; import java.util.Set; import java.util.jar.Attributes; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.jar.JarOutputStream; import java.util.jar.Manifest; +import java.util.regex.Pattern; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.AbstractMojo; @@ -125,6 +128,9 @@ public abstract class AbstractDpMojo extends AbstractMojo { @Parameter(property = "version") private String version; + @Parameter(property = "versionPartsSubstitutions") + private Properties versionPartsSubstitutions; + public AbstractDpMojo() { super(); } @@ -316,7 +322,16 @@ private Version makeQualifiedVersion() { getLog().debug("Failed to get qualified tycho version", e); } - String version = this.project.getVersion(); + + String version = Optional.ofNullable(versionPartsSubstitutions) + .orElseGet(Properties::new) + .entrySet() + .stream() + .reduce( + this.project.getVersion(), + (aVersion, substitution) -> aVersion.replaceAll(Pattern.quote(String.valueOf(substitution.getKey())), String.valueOf(substitution.getValue())), + (v1, v2) -> v2); + if (version.endsWith("-SNAPSHOT")) { version = version.replaceAll("-SNAPSHOT$", "." + this.session.getStartTime().toInstant().getEpochSecond()); }