Multiproject vs model with multicomponents

Hi,

I have a polyglot codebase with tens of C++ projects and tens of Java projects. I am not sure if today’s Gradle-speak calls them projects or components. I read in the user guide that the project space is going to be eventually replaced by the model space (https://docs.gradle.org/current/userguide/new_model.html#N17FCD).

What does this mean for how we are to organize our root level buildscripts? Does this mean we should create a model with components representing each of our subprojects, or should we be folding a model into a subproject? I have given an example below.

allprojects {
    model { platforms {
        ...
    } buildTypes {
        ...
    } }
}

project(':Project1') {
    apply plugin: 'cpp'
    model.components.project1(NativeLibrarySpec) {
    }
}

project(':Project2') {
    apply plugin: 'cpp'
    model.components.project2(NativeLibrarySpec) {
    }
}

As opposed to

project(':') { // for context only
    apply plugin: 'cpp'
    model { platforms {
        ...
    } buildTypes {
        ...
    } }
    model.components.project1(NativeLibrarySpec) {
    }
    model.components.project2(NativeLibrarySpec) {
    }
}

For the single root model approach I see in the components report that a binary has a path but we can’t call

$ ./gradlew component_name:platform_name:build_type:binary_spec

So it looks like having a project path adds more convenience:

$ ./gradlew projectA:build

as opposed to

$ ./gradlew win64ReleaseProject1StaticLibrary
1 Like