-
Notifications
You must be signed in to change notification settings - Fork 22
Description
Specifying an empty parameter value in a transformationSet results in build failure. Obviously, an empty value in configuration/transformationSets/transformationSet/parameters/parameter/value is translated to null. With recent versions of Saxon, i.e. 9.9.1-8, this results in the following error:
[ERROR] Failed to execute goal org.codehaus.mojo:xml-maven-plugin:1.2.0:transform (xyz) on project my-transformation: Execution xyz of goal org.codehaus.mojo:xml-maven-plugin:1.2.0:transform failed: Transformer.setParameter() - value is null -> [Help 1]
As newer versions of Saxon throw an exception when a null value is passed to the Transformer instead of an empty value, it is not possible to pass an empty value for a parameter, in short "null-for-empty". In my understanding this is caused by the POM interface of Maven passing empty values as null and xml-maven-plugin not translating the null value into an empty value.
The right place to solve the problem seems to me TransformMojo.java.transform(Resolver, TransformationSet). The solution would be to replace the lines processing the parameters, more precisely lines 453 to 455, with a null-aware version which restores the empty value in the configuration of the plugin, i.e. compensates null-for-empty by empty-for-null:
NameValuePair key = parameters[j];
String value = (key.getValue() == null) ? "" : key.getValue();
getLog().debug("Setting Parameter: " + key.getName() + "=" + value);
t.setParameter(key.getName(), value);
I will gladly apply the change and create a pull request if nothing speaks against it.