jamesfredley commented on code in PR #15467:
URL: https://github.com/apache/grails-core/pull/15467#discussion_r3164048016


##########
grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy:
##########
@@ -354,35 +352,83 @@ ${importStatements}
     protected void applyDefaultPlugins(Project project) {
         applySpringBootPlugin(project)
 
-        project.afterEvaluate {
-            GrailsExtension ge = project.extensions.getByType(GrailsExtension)
-            if (ge.springDependencyManagement) {
-                Plugin dependencyManagementPlugin = 
project.plugins.findPlugin(DependencyManagementPlugin)
-                if (dependencyManagementPlugin == null) {
-                    project.plugins.apply(DependencyManagementPlugin)
-                }
+        applyGrailsBom(project)
+    }
 
-                DependencyManagementExtension dme = 
project.extensions.findByType(DependencyManagementExtension)
+    /**
+     * Applies the Grails BOM as a Gradle platform and configures 
property-based
+     * version overrides. This replaces the Spring Dependency Management 
plugin with
+     * a lightweight mechanism that:
+     * <ol>
+     *   <li>Imports {@code grails-bom} via Gradle's native {@code platform()} 
support</li>
+     *   <li>Parses the BOM POM chain to discover which Maven properties 
control which artifact versions</li>
+     *   <li>Checks project properties ({@code gradle.properties} or {@code 
ext['property.name']}) for overrides</li>
+     *   <li>Applies any overrides via {@code 
ResolutionStrategy.eachDependency()}</li>
+     * </ol>
+     *
+     * <p>Usage: to override a version managed by the Grails or Spring Boot 
BOM, set the
+     * corresponding property in {@code gradle.properties} or {@code 
build.gradle}:</p>
+     * <pre>
+     * // gradle.properties
+     * slf4j.version=1.7.36
+     *
+     * // or build.gradle
+     * ext['slf4j.version'] = '1.7.36'
+     * </pre>
+     *
+     * @see BomManagedVersions
+     * @since 8.0
+     */
+    protected void applyGrailsBom(Project project) {
+        String grailsVersion = (project.findProperty('grailsVersion') ?: 
BuildSettings.grailsVersion) as String

Review Comment:
   Done in 2ca302b - extracted into a new standalone subproject 
`grails-gradle/bom-property-overrides` (published as 
`grails-gradle-bom-property-overrides`). The plugin id 
`org.apache.grails.gradle.bom-property-overrides` is BOM-agnostic and can be 
applied directly to any project that consumes a Maven-style BOM, no Grails 
dependency required.
   
   Highlights:
   - `BomManagedVersions` moved to `org.grails.gradle.plugin.bom` and now 
accepts a `Collection<String>` of BOM coordinates
   - New `BomPropertyOverridesPlugin` exposes a `bomPropertyOverrides` 
extension with both modes you asked for: `autoDetect` (default `true`, scans 
every declared `platform()`/`enforcedPlatform()`) and an explicit `bom 
'group:artifact:version'` list
   - `GrailsGradlePlugin.applyGrailsBom` now just applies the new plugin 
instead of inlining `BomManagedVersions.resolve(...)`; auto-detect handles both 
the plugin-injected `platform(grails-bom)` and any user-declared 
`enforcedPlatform(grails-micronaut-bom)` automatically
   - Tests: 4 unit specs for `BomManagedVersions`, 7 `ProjectBuilder` specs for 
the plugin, 1 TestKit functional spec for standalone application, plus 
`BomPlatformFunctionalSpec` updated to verify the plugin is applied through 
`grails-app` (13 + 12 = 25 tests, all passing)
   - Standalone usage is documented in `grails-doc/.../gradleDependencies.adoc`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to