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


##########
grails-doc/src/en/guide/commandLine/gradleBuild/gradleDependencies.adoc:
##########
@@ -60,28 +60,26 @@ dependencies {
 
 Note that version numbers are not present in the majority of the dependencies.
 
-This is thanks to the Spring dependency management plugin which automatically 
configures `grails-bom` as a Maven BOM via the Grails Gradle Plugin.  This 
defines the default dependency versions for most commonly used dependencies and 
plugins.
+This is thanks to Gradle's platform support which automatically imports 
`grails-bom` as a managed dependency platform via the Grails Gradle Plugin.  
This defines the default dependency versions for most commonly used 
dependencies and plugins.

Review Comment:
   Just to keep this thread current after the recent rework: the 
property-override mechanism is now its own standalone plugin 
(`org.apache.grails.gradle.bom-property-overrides`), and the doc section on 
this page was rewritten to (a) clearly attribute the feature to that plugin 
(not native Gradle) and (b) describe the *highest-version-wins* + 
property-override-after-conflict-resolution behaviour in the NOTE block, 
including the contrast against Spring DM and the `enforcedPlatform(grails-bom)` 
escape hatch. Happy to refine wording further once we land the weekly 
discussion - leaving open.



##########
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 the standalone subproject 
`grails-gradle/bom-property-overrides` published as 
`org.apache.grails.gradle.bom-property-overrides`. 
`GrailsGradlePlugin.applyGrailsBom` now just calls 
`project.plugins.apply(BomPropertyOverridesPlugin)`; the plugin's `autoDetect` 
mode picks up the platform(grails-bom) we inject plus any user-declared 
`enforcedPlatform(grails-micronaut-bom)`. Standalone usage with the 
`bomPropertyOverrides` extension (`autoDetect`, `bom 'g:a:v'`) is documented in 
`grails-doc/.../gradleDependencies.adoc`. Resolving.



##########
grails-doc/src/en/guide/commandLine/gradleBuild/gradleDependencies.adoc:
##########
@@ -60,13 +60,33 @@ dependencies {
 
 Note that version numbers are not present in the majority of the dependencies.
 
-This is thanks to the Spring dependency management plugin which automatically 
configures `grails-bom` as a Maven BOM via the Grails Gradle Plugin.  This 
defines the default dependency versions for most commonly used dependencies and 
plugins.
+This is thanks to Gradle's platform support which automatically imports 
`grails-bom` as a managed dependency platform via the Grails Gradle Plugin.  
This defines the default dependency versions for most commonly used 
dependencies and plugins.

Review Comment:
   Applied verbatim in 7948432 - merged the two paragraphs into one and 
rephrased to attribute the BOM to the Grails Gradle Plugin (rather than 
crediting Gradle's platform support directly). Thanks for the cleaner wording.



##########
grails-doc/src/en/guide/commandLine/gradleBuild/gradleDependencies.adoc:
##########
@@ -75,13 +95,35 @@ dependencies {
 }
 ----
 
-build.gradle, using Spring dependency management plugin:
+==== Using `bom-property-overrides` Standalone (Non-Grails Projects)
+
+The property-override mechanism is published as a standalone, BOM-agnostic 
Gradle plugin so it can be reused with any BOM that follows the Maven 
`<properties>` convention. Apply it directly when you want the same 
`gradle.properties` / `ext['…']` override workflow without applying any Grails 
plugin:
+
+[source,groovy]
+----
+plugins {
+    id 'java-library'
+    id 'org.apache.grails.gradle.bom-property-overrides' version 
'{GrailsVersion}'
+}
+
+dependencies {
+    implementation platform('com.example:my-bom:1.0.0')
+}
+
+// gradle.properties or build.gradle

Review Comment:
   Good catch - the `ext['...']` syntax is Groovy `build.gradle` only, not 
`gradle.properties`. Fixed in 7948432: split the `Overriding Managed Versions` 
example into two separate code blocks (one Groovy `ext[...]` for 
`build.gradle`, one `name=value` for `gradle.properties`), with an explicit 
note about the syntax difference. Same fix applied to the standalone plugin 
example further down (5254097).



##########
grails-doc/src/en/guide/commandLine/gradleBuild/gradleDependencies.adoc:
##########
@@ -75,13 +95,35 @@ dependencies {
 }
 ----
 
-build.gradle, using Spring dependency management plugin:
+==== Using `bom-property-overrides` Standalone (Non-Grails Projects)
+
+The property-override mechanism is published as a standalone, BOM-agnostic 
Gradle plugin so it can be reused with any BOM that follows the Maven 
`<properties>` convention. Apply it directly when you want the same 
`gradle.properties` / `ext['…']` override workflow without applying any Grails 
plugin:
+
+[source,groovy]
+----
+plugins {
+    id 'java-library'
+    id 'org.apache.grails.gradle.bom-property-overrides' version 
'{GrailsVersion}'
+}
+
+dependencies {
+    implementation platform('com.example:my-bom:1.0.0')
+}
+
+// gradle.properties or build.gradle
+ext['slf4j.version'] = '2.0.13'
+----
+
+By default the plugin auto-detects every `platform()` and `enforcedPlatform()` 
dependency declared on the project's configurations and registers each one for 
property-override processing. You can disable auto-detection or register 
additional BOMs explicitly via the `bomPropertyOverrides` extension:

Review Comment:
   Comma added in 5254097.



##########
grails-gradle/bom-property-overrides/build.gradle:
##########
@@ -0,0 +1,81 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    https://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+plugins {
+    id 'groovy'
+    id 'java-gradle-plugin'
+    id 'org.apache.grails.buildsrc.properties'
+    id 'org.apache.grails.buildsrc.dependency-validator'
+    id 'org.apache.grails.buildsrc.compile'
+    id 'org.apache.grails.buildsrc.publish'
+    id 'org.apache.grails.buildsrc.sbom'
+    id 'org.apache.grails.gradle.grails-code-style'
+}
+
+version = projectVersion
+group = 'org.apache.grails'
+
+ext {
+    pomTitle = 'Grails BOM Property Overrides Gradle Plugin'
+    pomDescription = 'A standalone Gradle plugin that enables Maven-style 
property-based version overrides for any Gradle platform() BOM. Reads the BOM 
POM <properties> block and lets consumers override versions via 
gradle.properties or ext[\'property.name\']. Reusable independently of Grails.'

Review Comment:
   Broken across multiple string-concat lines in 5254097 to match the existing 
pattern used for the `gradlePlugin` plugin description below it.



-- 
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