How to transparently pass a lot of optional configuration options to Ant task as a map?

(Marcin Zajączkowski) #1

I’m writing a plugin that internally uses Ant tasks. There is a lot of configuration options which can be passed to Ant task (most of them are optional and I don’t care about set value). Currently I am using ConventionMapping, Extension/Convention object and the @Input fields in a task which works fine for required options and those I have to set value in a plugin. But it would be very unpleasant and error prone to have to copy a value of all those fields from Extension object to conventionMapping in task and later get the value from @Input filed in task and build a map which would be passed to Ant task.

Is it possible to simple transfer all of the fields defined in a configuration closure in build.gradle to a task as a map (which would be passed to Ant task)?