Hi guys,
I’m currently writing a Gradle plugin, where I need to add some steps (new tasks) within the Android build flow.
The Android build runs many tasks, but let’s assume for simplicity that it runs the javaCompile task, and then the Dex task.
The Dex task uses the output of the javaCompile task. So we have:
javaCompile > Dex
Now, I would like to add a step in the middle, so that it works like this:
javaCompile > MyTask > Dex
In other words, I would like to have MyTask work on the output of javaCompile, produce a new output, and have the Dex task use the output of MyTask instead of the output of javaCompile.
I was able to change the output folder of the javaCompile task, but then the Dex task took its files from the new folder, which was not what I wanted.
Eventually I was able to change the input dir of the Dex task, so that it takes its files from MyTask instead of javaCompile. However, I did it by looking at the Android plugin source code, and relied on the input field inside the Dex task. This means that if Google decide to change their implementation later on – my plugin will stop working.
I was wondering whether there was a better way, sort of a “standard way” of achieving what I want within Gradle, without relying at all on the internals of the Android implementation?
Thanks!
Ariel