Skip to content

Commit b4a1ccc

Browse files
Volker Hochsteintomasbjerre
Volker Hochstein
authored andcommitted
Allow to pass extendedVariables using maven cli #24
1 parent 0b7016b commit b4a1ccc

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/main/java/se/bjurr/gitchangelog/plugin/GitChangelogMojo.java

+22
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import java.util.Date;
99
import java.util.List;
1010
import java.util.Map;
11+
import java.util.HashMap;
1112
import org.apache.maven.plugin.AbstractMojo;
1213
import org.apache.maven.plugin.MojoExecutionException;
1314
import org.apache.maven.plugins.annotations.Mojo;
@@ -36,6 +37,10 @@ public class GitChangelogMojo extends AbstractMojo {
3637
@Parameter(property = "extendedVariables", required = false)
3738
private Map extendedVariables;
3839

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+
3944
@Parameter(property = "templateFile", required = false)
4045
private String templateFile;
4146

@@ -136,6 +141,9 @@ public void execute() throws MojoExecutionException {
136141
return;
137142
}
138143
try {
144+
Map<String,String> extendedVariablesCliAsMap = this.convertExtendedVariablesCli2Map();
145+
this.extendedVariables.putAll(extendedVariablesCliAsMap);
146+
139147
GitChangelogApi builder;
140148
builder = gitChangelogApiBuilder();
141149
if (this.isSupplied(this.settingsFile)) {
@@ -273,4 +281,18 @@ private boolean isSupplied(final String parameter) {
273281
private boolean isSupplied(final Map<?, ?> parameter) {
274282
return parameter != null && !parameter.isEmpty();
275283
}
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+
}
276298
}

0 commit comments

Comments
 (0)