diff --git a/src/main/java/mpern/sap/commerce/build/tasks/HybrisAntTask.java b/src/main/java/mpern/sap/commerce/build/tasks/HybrisAntTask.java index 78ee381..185b4ef 100644 --- a/src/main/java/mpern/sap/commerce/build/tasks/HybrisAntTask.java +++ b/src/main/java/mpern/sap/commerce/build/tasks/HybrisAntTask.java @@ -2,13 +2,14 @@ import static mpern.sap.commerce.build.HybrisPlugin.HYBRIS_EXTENSION; -import java.util.HashMap; import java.util.Map; import org.gradle.api.Task; import org.gradle.api.execution.TaskExecutionAdapter; import org.gradle.api.file.ConfigurableFileTree; +import org.gradle.api.provider.MapProperty; import org.gradle.api.provider.Property; +import org.gradle.api.tasks.Input; import org.gradle.api.tasks.Internal; import org.gradle.api.tasks.JavaExec; @@ -20,14 +21,18 @@ public class HybrisAntTask extends JavaExec { private static final Version V_2205 = Version.parseVersion("2205.0"); - private Map antProperties; + private final MapProperty antProperties; + + private final MapProperty fallbackAntProperties; private final Property noOp; public HybrisAntTask() { super(); - antProperties = new HashMap<>(); noOp = getProject().getObjects().property(Boolean.class); + fallbackAntProperties = getProject().getObjects().mapProperty(String.class, String.class); + antProperties = getProject().getObjects().mapProperty(String.class, String.class); + antProperties.put("maven.update.dbdrivers", "false"); } @Override @@ -53,8 +58,11 @@ public void beforeExecute(Task task) { t.systemProperty("ant.home", platform.getAntHome().get().getAsFile()); t.systemProperty("file.encoding", "UTF-8"); - t.antProperty("maven.update.dbdrivers", "false"); - t.antProperties.forEach((k, v) -> t.args("-D" + k + "=" + v)); + Map props = t.antProperties.get(); + + t.fallbackAntProperties.get().forEach(props::putIfAbsent); + + props.forEach((k, v) -> t.args("-D" + k + "=" + v)); final HybrisPluginExtension plugin = (HybrisPluginExtension) t.getProject().getExtensions() .getByName(HYBRIS_EXTENSION); @@ -97,11 +105,31 @@ public void antProperty(String key, String value) { * @param antProperties ant properties to use for the target */ public void setAntProperties(Map antProperties) { - this.antProperties = new HashMap<>(antProperties); + this.antProperties.set(antProperties); + } + + /** + * Add a new runtime property to configure the ant target + * + * @param key key of the property + * @param value value of the property + */ + public void fallbackAntProperty(String key, String value) { + fallbackAntProperties.put(key, value); } @Internal public Property getNoOp() { return noOp; } + + @Input + public MapProperty getAntProperties() { + return antProperties; + } + + @Input + public MapProperty getFallbackAntProperties() { + return fallbackAntProperties; + } }