diff --git a/README.md b/README.md index 157e82e..96a1f82 100644 --- a/README.md +++ b/README.md @@ -83,5 +83,4 @@ the following file formats are supported: * toml/tml -- ie. TOML 0.4 -- https://github.com/toml-lang/toml/blob/master/versions/en/toml-v0.4.0.md * json -- ie. JSON -- https://www.json.org/json-en.html * hson/hjson -- ie. human JSON -- https://hjson.github.io/ -* plist -- ie. ASCII plist files, NeXT / OpenStep style configuration diff --git a/pom.xml b/pom.xml index 6a1bc64..682b4d6 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.github.terefang template-maven-plugin - 2020.5.12 + 2020.5.14 maven-plugin diff --git a/src/main/java/com/github/terefang/template_maven_plugin/AbstractTmpMojo.java b/src/main/java/com/github/terefang/template_maven_plugin/AbstractTmpMojo.java index f2e45fd..521c872 100644 --- a/src/main/java/com/github/terefang/template_maven_plugin/AbstractTmpMojo.java +++ b/src/main/java/com/github/terefang/template_maven_plugin/AbstractTmpMojo.java @@ -8,6 +8,7 @@ import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; +import org.codehaus.plexus.util.StringUtils; import java.io.File; import java.io.FileReader; @@ -34,6 +35,12 @@ public abstract class AbstractTmpMojo extends AbstractMojo @Parameter(defaultValue = "context") protected String additionalContextRoot; + /** + * additional global variable + */ + @Parameter(defaultValue = "") + protected String additionalVariables; + @SneakyThrows public void prepareAdditionalContext(Map context) { if(additionalContext.exists()) @@ -41,6 +48,15 @@ public void prepareAdditionalContext(Map context) { getLog().info(MessageFormat.format("loading context {0} from {1}", additionalContextRoot, additionalContext.getName())); context.put(additionalContextRoot, ContextUtil.loadContextFrom(additionalContext)); } + if(StringUtils.isNotEmpty(additionalVariables)) + { + String[] entries = StringUtils.split(additionalVariables); + for(String entry : entries) + { + String[] keyValue = StringUtils.split(entry, "="); + context.put(keyValue[0], keyValue[1]); + } + } } public void prepareStandardContext(Map context)