|
1 | 1 | package com.igormaznitsa.jcp.gradle; |
2 | 2 |
|
| 3 | +import static java.util.Collections.emptyMap; |
3 | 4 | import static org.gradle.api.tasks.SourceSet.MAIN_SOURCE_SET_NAME; |
4 | 5 |
|
5 | 6 |
|
|
14 | 15 | import java.util.ArrayList; |
15 | 16 | import java.util.Arrays; |
16 | 17 | import java.util.Collections; |
17 | | -import java.util.HashMap; |
18 | 18 | import java.util.List; |
19 | 19 | import java.util.stream.Collectors; |
20 | 20 | import javax.annotation.Nullable; |
@@ -165,7 +165,7 @@ public JcpPreprocessTask() { |
165 | 165 | this.sourceEncoding = factory.property(String.class).convention(StandardCharsets.UTF_8.name()); |
166 | 166 | this.eol = factory.property(String.class).convention(System.lineSeparator()); |
167 | 167 |
|
168 | | - this.vars = factory.mapProperty(String.class, String.class).convention(new HashMap<>()); |
| 168 | + this.vars = factory.mapProperty(String.class, String.class); |
169 | 169 |
|
170 | 170 | final JavaPluginConvention javaPluginConvention = this.getProject().getConvention().findPlugin(JavaPluginConvention.class); |
171 | 171 | if (javaPluginConvention == null) { |
@@ -392,7 +392,7 @@ public void warning(@Nullable final String message) { |
392 | 392 | preprocessorContext.setUnknownVariableAsFalse(this.unknownVarAsFalse.get()); |
393 | 393 | preprocessorContext.setVerbose(this.verbose.get()); |
394 | 394 |
|
395 | | - this.vars.get().forEach((key, value) -> { |
| 395 | + this.vars.getOrElse(emptyMap()).forEach((key, value) -> { |
396 | 396 | logger.debug(String.format("Registering global variable: %s=%s", key, value)); |
397 | 397 | preprocessorContext.setGlobalVariable(key, Value.recognizeRawString(value)); |
398 | 398 | }); |
|
0 commit comments