I have a legacy ant build and am trying to slowly migrate to gradle. I created a trivial build.gradle file that simply imports the legacy build.xml file. This allows me to call 'gradle ’ just fine. But now I want to add inputs and outputs to targets in order to take advantage of the incremental build feature in gradle.
Let’s say I a simple ant target that just copies files from one location to another. Let’s call it the copyStuff target. I can then augment this ant target in my new gradle build like this:
copyStuff {
inputs.files
"foo.bar",
"some.thing"
outputs.files "/new/location/foo.bar",
"/new/location/some.thing"
}
Running “gradle copyStuff” works as expected. The first time it runs the ant target, and the second time it says UP-TO-DATE.
This does NOT work though if the legacy target copyStuff is wrapped inside another ant target. Let’s say my legacy ant build has 10 steps, of which copyStuff is just one step. My legacy ant build has a “build” target which includes calls to 10 other ant targets. If I run “gradle build”, it proceeds to call the ant build target and subsequently all 10 other targets. And it ALWAYS calls those 10, despite the fact that copyStuff now has declared inputs and outputs.
So in summary, “gradle copyStuff” works as expected. But “gradle build” does not.
Any ideas on how to get around this problem because I’d love to start the slow migration from ant to gradle without having to muck around with the old ant build.
Thanks!