DevOps / Gradle8 Interview Questions
When would you choose a convention plugin over applying plugins directly in each module?
A convention plugin bundles a set of plugin applications and shared configuration (Java version, common dependencies, code-quality tool setup) into one reusable, versioned plugin, applied with a single id '...' line in each module, instead of repeating the same block of configuration in every module's build.gradle.
// buildSrc/src/main/groovy/myapp.java-conventions.gradle plugins { id 'java' } java { toolchain { languageVersion = JavaLanguageVersion.of(21) } } // any-module/build.gradle plugins { id 'myapp.java-conventions' }
It's the right call once the same configuration is duplicated across three or more modules, since at that point a change (bumping the Java version, adding a new required dependency) means editing one file instead of hunting down every copy. It's less necessary for a single-module project or one where every module genuinely needs different configuration with little in common — forcing shared conventions onto modules that don't actually share requirements just adds an extra layer of indirection without the payoff.
More Related questions...
