sample code:
def ant = new AntBuilder()
ant.'antlib:org.jacoco.ant:agent'(
enabled: enabled,
property: 'agentvmparam')
When that "enabled" parameter is null, I'd like it to be not present in the ant task conversion, not merely "empty". "empty" gets evaluated to "true" http://ant.apache.org/manual/develop.html#set-magic which isn't what I want.
xml builder example:
def xml = new MarkupBuilder()
xml.omitNullAttributes = true
xml.root(
requiredAttribute:'required',
optionalAttribute: optionalAttribute
) { }
That "omitNullAttributes" will ensure that the "optionalAttribute" xml element parameter isn't even present if the Groovy parameter evaluates to null.
so I get
<root requiredAttribute='required' />
instead of
<root requiredAttribute='required' optionalAttribute='' />
Bit of a possible workaround, but does this work?
ie: use a
findAll
to remove the null entries of the param map