Modularize Gradle build into per-module build files - #11241
Conversation
cppwfs
commented
Aug 3, 2026
- Add a standalone build.gradle to all 42 spring-integration-* modules, each applying the shared conventions plus its own module-specific dependencies and plugin needs (protobuf for core/grpc, groovy plugin for the groovy module)
- Remove all per-module project('...') {} blocks and the configure(javaProjects) {} block from root build.gradle, cutting it from 1155 to roughly 300 lines
- Keep spring-integration-bom's configuration in root build.gradle since it is a java-platform aggregator, not a java-conventions consumer
- Defer schemaZip and distZip's subproject sourceSets/jar access into gradle.projectsEvaluated to fix task-registration-order failures that surfaced once modules stopped being eagerly configured inline with root
- Extract shared java/kotlin/checkstyle/publishing config from root build.gradle into buildSrc convention plugins (spring-integration.java-conventions and spring-integration.protobuf-conventions)
- Implement convention plugins as Plugin classes that delegate to resource .gradle scripts, working around a Gradle 9.6.1 bug where the groovy-gradle-plugin precompiled-script adapter throws UnknownServiceException when the same plugin is applied to more than one project
| testRuntimeOnly 'org.apache.logging.log4j:log4j-core' | ||
| testRuntimeOnly 'org.apache.logging.log4j:log4j-jcl' | ||
| testRuntimeOnly 'org.apache.logging.log4j:log4j-slf4j-impl' | ||
| testRuntimeOnly 'org.apache.logging.log4j:log4j-slf4j2-impl' |
There was a problem hiding this comment.
No, I don't want anything in buildSrc.
This is exta code to support and a bit confusing.
But it looks like it is spreading dependency management.
Why configure(javaProjects) doesn't work for us?
I don't want any custom Gradle plugins.
| @@ -0,0 +1,12 @@ | |||
| plugins { | |||
| id 'spring-integration.java-conventions' | |||
There was a problem hiding this comment.
Doesn't look like this custom plugin helps enough.
We still have to copy/paste it every where.
May we just split root config per modules and leave everything common as is?
That claim about decreasing size is a bit not fair since we are introduce much more complexity into that buildSrc
- Extract each module's dependency and plugin configuration from the monolithic root `build.gradle` into a dedicated `build.gradle` file within its own module directory. - Replace `configure(javaProjects)` with a `subprojects` block that skips `spring-integration-bom`. - Keep shared configuration (compiler options, checkstyle, publishing, etc.) centralized in the root `build.gradle`. - Simplify long-term maintenance by co-locating a module's build logic with its source rather than in one large shared file.
cae14ee to
bc7c165
Compare
|
I took a different tack and so I started from scratch. So there is only one commit. |
artembilan
left a comment
There was a problem hiding this comment.
Very cool!
Merging.
We can come back to any leftover concerns with new Gradle later on.
Thank you!