How to organise build.gradle files among sub projects

Hi,

Im trying to setup a native cpp project with gradle. I had one root folder with multiple sub folders and am unsure the best way to set this up:

root/

build.gradle

settings.gradle

subproject1/

subproject2/

main/main.cpp

Basically, I want to allow access to the source files in subproject1 & 2 to main.cpp. I don’t want to create any libraries at this point…I would prefer to create build.gradle files inside each subproject, rather than listing all sources in the root build.gradle file

please help?

If subproject1 and 2 aren’t libraries, you could just add them as additional source sets to the main component (so you’d only have one project).

Here’s how you can add a new CppSourceSet:

model {
    components {
        main(NativeExecutableSpec) {
            sources {
                subproject1(CSourceSet) {
                    source.srcDir "subproject1/src"
                }
            }
        }
    }
}

They’ll get compiled as part of the main executable.