How to invoke subtasks of subprojects in the parent build.gradle?

I have a project like this: / - parent

|- subproject1

|- subproject2

Each of the subprojects has a task ‘installWithConfig’ which depends on ‘installApp’ task (from application plugin) and the only thing it does is to add some files to the ‘bin/’ directory.

So running gradle in the subprojects with ‘gradle installWithConfig’ produces good stuff in ‘build/install/’. I want to make an “ubertask” (named ‘uberBuild’) in the parent build.gradle which copies the contents together.

My problems: * I can’t write this: ‘task uberBuild(dependsOn: project(’:subproject1’).installWithConfig) << { … }’ cause gradle says ‘installWithConfig’ is not a valid property of the project * When I invoke it manually with ‘project(’:BIGlossary’).installWithConfig.execute()’ – it only does the job defined in the actual task and not the dependencies (e.g.: ‘installApp’ nor its further dependencies)

Please help me to provide a valid way to achieve something like this in Gradle. Thanks!

Try writing ‘dependsOn: “:subproject1:installWithConfig”’ instead of ‘dependsOn: project(’:subproject1’).installWithConfig’.

EDIT: Quotes should be included as well.

1 Like

Thanks, it works like a charm!

And is it possible to reach properties of these tasks? so I can I use dot notation for further properties?

No, but you can use your original approach in the ‘doLast’ (’<<’). Or in some other way you have to ensure that that task has been configured when you are trying to access its properties.

yes, thanks. I’ve just thought the same solution and it works, the problem was only during configuration but that was solved with your help. Thanks again!