Skip to content

Commit 5e89656

Browse files
committed
fix: apply grails-bom platform to all declarable configurations
The Spring Dependency Management plugin applied version constraints globally to every configuration via configurations.all() and resolutionStrategy.eachDependency(). With the switch to Gradle's native platform(), version constraints must be added explicitly. Apply the grails-bom platform to all declarable configurations using configureEach, matching the previous global behavior. Non-declarable configurations (apiElements, runtimeElements, etc.) inherit constraints through their parent configurations. Code quality tool configurations (checkstyle, codenarc, etc.) are excluded because platform() constraints participate in version conflict resolution and can upgrade transitive dependencies, breaking the tools. Also ensure the developmentOnly configuration always exists via maybeCreate. Assisted-by: Claude Code <Claude@Claude.ai>
1 parent 531041b commit 5e89656

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,25 @@ ${importStatements}
384384
String grailsVersion = (project.findProperty('grailsVersion') ?: BuildSettings.grailsVersion) as String
385385
String bomCoordinates = "org.apache.grails:grails-bom:${grailsVersion}" as String
386386

387-
project.dependencies.add('implementation', project.dependencies.platform(bomCoordinates))
387+
// Ensure the developmentOnly configuration exists. Spring Boot's plugin
388+
// normally creates this, but using maybeCreate guarantees it is available
389+
// even if plugin ordering changes or Spring Boot is not applied.
390+
project.configurations.maybeCreate('developmentOnly')
391+
392+
// Apply the BOM platform to all declarable project configurations, matching
393+
// the behavior of the Spring Dependency Management plugin which applied version
394+
// constraints globally via configurations.all() + resolutionStrategy.eachDependency().
395+
// Non-declarable configurations (e.g. apiElements, runtimeElements) inherit
396+
// constraints through their parent configurations. Code quality tool
397+
// configurations (checkstyle, codenarc, etc.) are excluded because adding BOM
398+
// constraints to tool classpaths can upgrade transitive dependencies and break
399+
// the tools - unlike resolutionStrategy hooks, platform() constraints
400+
// participate in version conflict resolution.
401+
project.configurations.configureEach { Configuration conf ->
402+
if (conf.canBeDeclared && !isCodeQualityConfiguration(conf.name)) {
403+
project.dependencies.add(conf.name, project.dependencies.platform(bomCoordinates))
404+
}
405+
}
388406

389407
project.afterEvaluate {
390408
BomManagedVersions managedVersions = BomManagedVersions.resolve(project, bomCoordinates)
@@ -396,6 +414,17 @@ ${importStatements}
396414
}
397415
}
398416

417+
/**
418+
* Returns {@code true} if the given configuration name belongs to a code quality
419+
* tool (Checkstyle, CodeNarc, PMD, SpotBugs). These configurations hold tool
420+
* classpaths and must not receive the BOM platform because {@code platform()}
421+
* constraints can upgrade transitive dependencies and break the tools.
422+
*/
423+
private static boolean isCodeQualityConfiguration(String name) {
424+
name == 'checkstyle' || name == 'codenarc' || name == 'pmd' ||
425+
name == 'spotbugs' || name == 'spotbugsPlugins'
426+
}
427+
399428
protected void applySpringBootPlugin(Project project) {
400429
def springBoot = project.extensions.findByType(SpringBootExtension)
401430
if (!springBoot) {

0 commit comments

Comments
 (0)