-
-
Notifications
You must be signed in to change notification settings - Fork 968
feat: Replace Spring Dependency Management plugin with Gradle platform + lightweight BOM property overrides #15467
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 8.0.x
Are you sure you want to change the base?
Changes from all commits
ca495ab
531041b
5e89656
1a2cea3
30a46f6
96fea95
5607ddb
575b77f
a4511eb
28a6817
77932f2
54fbe93
4d1bcdb
90c1238
a2363ae
f0c1934
2ca302b
bbf5e53
9204972
0178a10
ba8459f
e1f8fc8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The versions are only supported by your plugin. Also, the dependency management plugin causes the bom versions to resolve to the spring version and not to the highest version. We should discuss this side effect in the weekly
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated in 2ca302b. The relevant section in
Happy to refine the side-effect wording further after the weekly discussion - leaving this thread open in case you want to expand on it.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure this sentence is 100% accurate. How about: "This is thanks to the Grails Gradle Plugin, which adds |
||
|
|
||
| For a Grails App, applying `org.apache.grails.gradle.grails-web` will automatically configure the `grails-bom`. No other steps required. | ||
| ==== Overriding Managed Versions | ||
|
|
||
| For Plugins and Projects which do not use `org.apache.grails.gradle.grails-web`, you can apply the `grails-bom` in one of the following two ways. | ||
| To override a managed version, set the corresponding property in `gradle.properties` or `build.gradle`: | ||
| [source,groovy] | ||
| ---- | ||
| // gradle.properties | ||
| slf4j.version=1.7.36 | ||
|
|
||
| // or build.gradle | ||
| ext['slf4j.version'] = '1.7.36' | ||
| ---- | ||
|
|
||
| The property override mechanism is a feature of the **Grails BOM Property Overrides Gradle plugin** (`org.apache.grails.gradle.bom-property-overrides`); standalone Gradle does not natively read `<properties>` from BOM POMs (see https://github.com/gradle/gradle/issues/9160[Gradle issue #9160]). The plugin parses the BOM POM, builds a property→artifact mapping, and applies overrides via Gradle's `ResolutionStrategy.eachDependency()`. | ||
|
|
||
| [NOTE] | ||
| ==== | ||
| The plugin participates in Gradle's standard dependency resolution. When the same artifact is requested at multiple versions across a build (for example, when both `grails-bom` and a transitive dependency declare `slf4j-api`), Gradle's default *highest-version-wins* conflict resolution applies _before_ the property override is consulted. Setting `slf4j.version` therefore pins the version that will be used after conflict resolution rather than overriding the resolved version after the fact. This differs from the legacy Spring Dependency Management plugin, which forced BOM versions to win unconditionally and could mask transitive version drift. If you need stricter behaviour, declare `enforcedPlatform(grails-bom)` on the relevant configuration. | ||
| ==== | ||
|
|
||
| ==== Applying the BOM in Different Project Types | ||
|
|
||
| For a Grails App, applying `org.apache.grails.gradle.grails-web` will automatically configure the `grails-bom` _and_ apply the `bom-property-overrides` plugin. No other steps required. | ||
|
|
||
| For Plugins and Projects which do not use `org.apache.grails.gradle.grails-web`, you can apply the `grails-bom` using Gradle Platforms: | ||
|
|
||
| build.gradle, using Gradle Platforms: | ||
| [source,groovy] | ||
| ---- | ||
| dependencies { | ||
|
|
@@ -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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This syntax will not work in |
||
| 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: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By default, ... (add comma?) |
||
|
|
||
| [source,groovy] | ||
| ---- | ||
| dependencyManagement { | ||
| imports { | ||
| mavenBom 'org.apache.grails:grails-bom:{GrailsVersion}' | ||
| } | ||
| applyMavenExclusions false | ||
| bomPropertyOverrides { | ||
| // Disable scanning declared platforms (default: true) | ||
| autoDetect = false | ||
|
|
||
| // Register specific BOMs (e.g. ones referenced indirectly) | ||
| bom 'com.example:my-bom:1.0.0' | ||
| bom 'com.example:other-bom:2.0.0' | ||
| } | ||
| ---- | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be under the Gradle package to match our other plugins |
||
|
|
||
| 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.' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we break this line? |
||
| pomMavenPublicationName = 'pluginMaven' | ||
| } | ||
|
|
||
| dependencies { | ||
| implementation platform(project(':grails-gradle-bom')) | ||
|
|
||
| // compile with the Groovy version provided by Gradle | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment does not seem to be accurate anymore? Isn't the groovy version taken from the |
||
| // see: https://docs.gradle.org/current/userguide/compatibility.html#groovy | ||
| compileOnly 'org.apache.groovy:groovy' | ||
|
|
||
| // Testing - Gradle TestKit is auto-added by java-gradle-plugin | ||
| testImplementation('org.spockframework:spock-core') { transitive = false } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we still need to exclude transitive dependencies here? |
||
| testImplementation 'org.apache.groovy:groovy-test-junit5' | ||
| testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine' | ||
| } | ||
|
|
||
| configurations { | ||
| testCompileClasspath.exclude group: 'org.apache.groovy', module: 'groovy' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use parentheses for method calls?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we excluding these anyhow? |
||
| testRuntimeClasspath.exclude group: 'org.apache.groovy', module: 'groovy' | ||
| } | ||
|
|
||
| gradlePlugin { | ||
| plugins { | ||
| bomPropertyOverrides { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||
| displayName = 'Grails BOM Property Overrides Plugin' | ||
| description = 'Enables Maven-style property-based version overrides for any Gradle platform() BOM. ' + | ||
| 'Apply this plugin and override versions via gradle.properties or ext[\'property.name\']. ' + | ||
| 'Auto-detects declared platform() BOMs by default, or accepts an explicit list via the ' + | ||
| 'bomPropertyOverrides extension.' | ||
| id = 'org.apache.grails.gradle.bom-property-overrides' | ||
| implementationClass = 'org.grails.gradle.plugin.bom.BomPropertyOverridesPlugin' | ||
| } | ||
| } | ||
| } | ||
|
|
||
| tasks.withType(Copy) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||
| configure { | ||
| duplicatesStrategy = DuplicatesStrategy.INCLUDE | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is causing the duplicate? We typically fix these so it's not needed |
||
| } | ||
| } | ||
|
|
||
| apply { | ||
| from rootProject.layout.projectDirectory.file('gradle/docs-config.gradle') | ||
| from rootProject.layout.projectDirectory.file('gradle/test-config.gradle') | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should remove this change or merge up 7.2 to pickup the graphql change