I’m currently migrating a bunch of ant build scripts to Gradle, and there’s one particular construct that I find hard to express in a reasonably succinct way.
We’re generating Java code using wsdl2java by defining a target for each WSDL file that besides the actual code generation also moves files around and does a bit of post processing - IOW basically something like
<target name="generate"> <delete dir="generated"/> <java classname="org.apache.axis2.wsdl.WSDL2Java" ... /> <copy todir="src/main/java"> <fileset dir="generated/src"/> </copy> <antcall target="postprocess"> <param name="file" value="package/path/FoobarStub.java"/> </antcall> </target>
Other than the name of the WSDL file and the resulting Java stub class the targets and actions are identical, so the file management and post processing is the same in all targets.
It’s perfectly possible to do something similar in Gradle using multiple tasks that depend on each other, but that’s much more verbose than the ant based solution and it kind of hides the “pipeline” nature of the process, so what’s the canonical way of doing this?
I suppose that I’m missing out on something really obvious here as the process we’re trying to implement is so simple - can (should) it be done using doFirst()/doLast() or finalizers?