Gradle and native cpp with multiple build.gradle files in hierachy?

well, for my first little bigger project (more then one build.gradle) with gradle and cpp, i would like to use a hierarchical project layout where each subproject got its own build.gradle (and settings.gradle if it got its own subprojects…)

when i search the forums this is the closest i got, thats not to old (as much as gradle dsl broke with android cpp during the expremental plugin, i guess its the same way here but somewhat more stable…)

when using one build.gradle, its not a problem, cause everything is in the same component, but how do i reference a task in a native sub software projects build.gradle?

another linked question, in settings.gradle i just wrote include, and the foldername inside quotes which is relative from settings.gradle in top project root/submodules/the foldername in settings.gradle

gradle doesnt complain, but it does not seem to find my custom tasks ether…

how is a include to a native submodule supposed to look like?

i hope its readable, as theres no preview function it might look messy…


alright i solved this one… was kinda obvous when i found out how it works.

in settings.gradle:
include ‘submodules:cpp-gradle-submodule’

then when i run gradle tasks --all, it shows all my tasks and i find the task i want along all the cpp tasks:


when i run gradle submodules:cpp-gradle-submodule:developmentBuild

it builds just fine…

so the hierarchy in gradle seems to be based on folderdepth too, that part i had missed from the docs.

I’m a bit late to the game, but it’s also possible to rewrite where each of your projects is located. By default, the Gradle path you specify (with column) is the on-disk path that will be used. However, you can configure that. Look at Gradle’s own settings.gradle file. That been said, it a decision that should come from engineering your build as oppose to “that’s how other build tool does it”.

I hope this helps,


Hello Daniel,

thats how i solved it when i reworked my build files from scratch earlier this spring,
i include the whole project and set the projectdir from settings.gradle…

it was accually pretty easy when i figured out how to do it…