Skip to content

Commit

Permalink
2020.5.14
Browse files Browse the repository at this point in the history
  • Loading branch information
BuildTools committed Jun 11, 2020
1 parent 2a322f0 commit 2117e08
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.github.terefang</groupId>
<artifactId>template-maven-plugin</artifactId>
<version>2020.5.12</version>
<version>2020.5.14</version>

<packaging>maven-plugin</packaging>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -34,13 +35,28 @@ 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<String, Object> context) {
if(additionalContext.exists())
{
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<String, Object> context)
Expand Down

0 comments on commit 2117e08

Please sign in to comment.