DevOps / Gradle8 Interview Questions
How do you configure a multi-project Gradle build?
A multi-project build starts with settings.gradle declaring the subprojects, then each subproject gets its own build.gradle, with shared configuration typically centralized at the root using allprojects {}/subprojects {} or, in modern Gradle, convention plugins.
// settings.gradle rootProject.name = 'my-app' include 'core', 'api', 'web' // root build.gradle — shared config subprojects { apply plugin: 'java' repositories { mavenCentral() } } // api/build.gradle — project-specific dependencies { implementation project(':core') }
While allprojects/subprojects blocks are still common in existing projects, Gradle's current guidance favors convention plugins (defined once in buildSrc or an included build, then applied explicitly in each subproject) instead, since cross-cutting configuration blocks can silently configure projects in ways that are hard to trace and are known to interfere with the configuration cache. Either way, the project-dependency mechanism (project(':core')) is what lets subprojects depend on and build against each other within the same overall build.
More Related questions...
