|
8 | 8 | import java.util.Date;
|
9 | 9 | import java.util.List;
|
10 | 10 | import java.util.Map;
|
| 11 | +import java.util.HashMap; |
11 | 12 | import org.apache.maven.plugin.AbstractMojo;
|
12 | 13 | import org.apache.maven.plugin.MojoExecutionException;
|
13 | 14 | import org.apache.maven.plugins.annotations.Mojo;
|
@@ -36,6 +37,10 @@ public class GitChangelogMojo extends AbstractMojo {
|
36 | 37 | @Parameter(property = "extendedVariables", required = false)
|
37 | 38 | private Map extendedVariables;
|
38 | 39 |
|
| 40 | + //map variables cannot be passed through maven cli use this property as a workaround |
| 41 | + @Parameter(property = "extendedVariablesCli", required = false) |
| 42 | + private String[] extendedVariablesCli; |
| 43 | + |
39 | 44 | @Parameter(property = "templateFile", required = false)
|
40 | 45 | private String templateFile;
|
41 | 46 |
|
@@ -136,6 +141,9 @@ public void execute() throws MojoExecutionException {
|
136 | 141 | return;
|
137 | 142 | }
|
138 | 143 | try {
|
| 144 | + Map<String,String> extendedVariablesCliAsMap = this.convertExtendedVariablesCli2Map(); |
| 145 | + this.extendedVariables.putAll(extendedVariablesCliAsMap); |
| 146 | + |
139 | 147 | GitChangelogApi builder;
|
140 | 148 | builder = gitChangelogApiBuilder();
|
141 | 149 | if (this.isSupplied(this.settingsFile)) {
|
@@ -273,4 +281,18 @@ private boolean isSupplied(final String parameter) {
|
273 | 281 | private boolean isSupplied(final Map<?, ?> parameter) {
|
274 | 282 | return parameter != null && !parameter.isEmpty();
|
275 | 283 | }
|
| 284 | + |
| 285 | + private Map<String, String> convertExtendedVariablesCli2Map() { |
| 286 | + Map<String, String> map = new HashMap<>(); |
| 287 | + if (this.extendedVariablesCli != null) { |
| 288 | + for (int i=0;i< this.extendedVariablesCli.length;i++) { |
| 289 | + String entry = this.extendedVariablesCli[i]; |
| 290 | + int equalsPosition = entry.indexOf( "=" ); |
| 291 | + map.put( |
| 292 | + entry.substring( 0, equalsPosition ), |
| 293 | + entry.substring( equalsPosition + 1 ) ); |
| 294 | + } |
| 295 | + } |
| 296 | + return map; |
| 297 | + } |
276 | 298 | }
|
0 commit comments