I want to create a simple synchronization task that will slightly change its behavior depending on the type of assembly (for example, debug / release), and I use the 'dummy' decrared boolean variable in gradle.taskGraph.whenReady:
gradle.taskGraph.whenReady {taskGraph -> dummy = false if (taskGraph.hasTask(':dummybuild')) { dummy = true } }
The problem is that the task configured as follows has a configuration area, that is, before Ready, so it does not have access to the 'dummy' variable:
task copySkins(type: Sync) { from skinsFrom into skinsInto rename skinsRename exclude symbianExclude if (!dummy) exclude dummyExclude }
I am using this workaround now
task copySkins { inputs.dir skinsFrom outputs.dir skinsInto doLast { task skins(type: Sync) { from skinsFrom into skinsInto rename skinsRename exclude symbianExclude if (!dummy) exclude dummyExclude } skins.execute() } }
Is it possible
- Detect / configure some properties of the assembly in any other place, except whenReady
- move synchronization task task to doLast
- or at least have a shortcut for the synchronization task (.execute () looks pretty ugly)
source share