This is an automated email from the ASF dual-hosted git repository. jamesfredley pushed a commit to branch docs/grails-8-upgrade-guide-refresh in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit 14751c9cdeb3cf87fea96f07cf21a170d951e9fa Author: James Fredley <[email protected]> AuthorDate: Fri Jun 26 15:05:05 2026 -0400 Support Hibernate 7 Micronaut BOM selection Recognize the Hibernate 7 Micronaut BOM as a known enforced Grails BOM and cover automatic plus manual selection in the Gradle plugin functional tests. Assisted-by: hephaestus:openai/gpt-5.5 oracle --- .../gradle/plugin/core/GrailsExtension.groovy | 13 +++---- .../gradle/plugin/core/GrailsGradlePlugin.groovy | 9 +++-- .../plugin/core/BomPlatformFunctionalSpec.groovy | 31 ++++++++++++++++ .../build.gradle | 29 +++++++++++++++ .../gradle.properties | 1 + .../settings.gradle | 1 + .../build.gradle | 43 ++++++++++++++++++++++ .../gradle.properties | 1 + .../settings.gradle | 1 + 9 files changed, 119 insertions(+), 10 deletions(-) diff --git a/grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsExtension.groovy b/grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsExtension.groovy index 7fac362b10..f1864cca20 100644 --- a/grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsExtension.groovy +++ b/grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsExtension.groovy @@ -126,12 +126,10 @@ class GrailsExtension { * Whether the Micronaut auto-setup should run when the `grails-micronaut` plugin is detected. * When enabled, the Grails Gradle plugin: * <ul> - * <li>validates that `grails-micronaut-bom` is applied as `enforcedPlatform` and fails the build - * at configuration time with an actionable error if not (`grails-micronaut-bom` is the single - * source of truth for the Micronaut platform version);</li> - * <li>configures the Spring Boot `bootJar`/`bootWar` tasks to use the {@code CLASSIC} loader - * implementation (required for {@code java -jar} compatibility with the Micronaut-Spring - * integration).</li> + * <li>validates that a Micronaut-compatible Grails BOM is applied as `enforcedPlatform` and fails + * the build at configuration time with an actionable error if not;</li> + * <li>keeps Micronaut dependency management aligned with the Grails BOM variant selected by the + * application.</li> * </ul> * Disabling this is rarely appropriate; consumer projects should normally apply the BOM as * `enforcedPlatform` so that the Micronaut platform cannot override grails-bom-managed versions. @@ -190,7 +188,8 @@ class GrailsExtension { * </pre> * * <p>The Micronaut variants ({@code grails-micronaut-bom}, - * {@code grails-hibernate5-micronaut-bom}) are applied as an {@code enforcedPlatform} + * {@code grails-hibernate5-micronaut-bom}, and {@code grails-hibernate7-micronaut-bom}) + * are applied as an {@code enforcedPlatform} * because the Micronaut platform would otherwise override their managed versions via * conflict resolution. All other BOMs are applied as a regular {@code platform}.</p> * diff --git a/grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy b/grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy index 676556a84a..743c2dd811 100644 --- a/grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy +++ b/grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy @@ -439,7 +439,7 @@ ${importStatements} } // Exactly one Grails BOM may be applied. The BOMs are split by integration - // (default / hibernate5 / micronaut), so a project must select a single variant. + // (default / hibernate / micronaut), so a project must select a single variant. // If the build declares a Grails BOM by hand - for example a Micronaut application // declaring enforcedPlatform(grails-micronaut-bom), or an application generated by // Grails Forge / a profile that declares platform(grails-bom) directly - honor that @@ -450,7 +450,7 @@ ${importStatements} throw new GradleException( "Project '${project.name}' declares more than one Grails BOM (${declaredBoms.join(', ')}). " + 'Exactly one Grails BOM may be applied; the BOMs are split by integration ' + - '(default / hibernate5 / micronaut), so a project must select a single variant.' + '(default / hibernate / micronaut), so a project must select a single variant.' ) } def effectiveBom = declaredBoms.isEmpty() ? bomName : declaredBoms.first() @@ -505,6 +505,7 @@ ${importStatements} private static final Set<String> ENFORCED_PLATFORM_BOMS = [ 'grails-micronaut-bom', 'grails-hibernate5-micronaut-bom', + 'grails-hibernate7-micronaut-bom', ] as Set<String> /** @@ -516,8 +517,10 @@ ${importStatements} 'grails-bom', 'grails-base-bom', 'grails-hibernate5-bom', + 'grails-hibernate7-bom', 'grails-micronaut-bom', 'grails-hibernate5-micronaut-bom', + 'grails-hibernate7-micronaut-bom', ] as Set<String> /** @@ -665,7 +668,7 @@ ${importStatements} } // Exactly one Grails BOM is ever applied (the BOMs are split by integration: - // default / hibernate5 / micronaut). A Micronaut project selects the Micronaut + // default / hibernate / micronaut). A Micronaut project selects the Micronaut // variant either by setting grails { bom = 'grails-micronaut-bom' } (auto-applied // as an enforcedPlatform by applyGrailsBom) or by opting out via grails { bom = null } // and declaring enforcedPlatform(grails-micronaut-bom) by hand. Either way the diff --git a/grails-gradle/plugins/src/test/groovy/org/grails/gradle/plugin/core/BomPlatformFunctionalSpec.groovy b/grails-gradle/plugins/src/test/groovy/org/grails/gradle/plugin/core/BomPlatformFunctionalSpec.groovy index 3486f39b0e..1193fb00a4 100644 --- a/grails-gradle/plugins/src/test/groovy/org/grails/gradle/plugin/core/BomPlatformFunctionalSpec.groovy +++ b/grails-gradle/plugins/src/test/groovy/org/grails/gradle/plugin/core/BomPlatformFunctionalSpec.groovy @@ -65,4 +65,35 @@ class BomPlatformFunctionalSpec extends GradleSpecification { and: 'property-based version overrides are still enabled for the declared BOM' result.output.contains('HAS_BOM_PROPERTY_OVERRIDES=true') } + + def "plugin applies configured Hibernate 7 Micronaut BOM as enforced platform"() { + given: + setupTestResourceProject('bom-platform-hibernate7-micronaut-auto') + + when: + def result = executeTask('inspectBomSetup') + + then: + result.output.contains('HAS_H7_MICRONAUT_BOM=true') + result.output.contains('H7_MICRONAUT_BOM_ENFORCED=true') + result.output.contains('HAS_GRAILS_BOM=false') + result.output.contains('HAS_BOM_PROPERTY_OVERRIDES=true') + } + + def "plugin recognizes manually declared Hibernate 7 Micronaut BOM as the single Grails BOM"() { + given: + setupTestResourceProject('bom-platform-hibernate7-micronaut-manual') + + when: + def result = executeTask('inspectBomSetup') + + then: + result.output.contains('HAS_GRAILS_BOM=false') + result.output.contains('HAS_H7_MICRONAUT_BOM=true') + result.output.contains('H7_MICRONAUT_BOM_ENFORCED=true') + result.output.contains('SIBLING_HAS_H7_MICRONAUT_BOM=true') + result.output.contains('SIBLING_H7_MICRONAUT_BOM_ENFORCED=true') + result.output.contains('SIBLING_HAS_GRAILS_BOM=false') + result.output.contains('HAS_BOM_PROPERTY_OVERRIDES=true') + } } diff --git a/grails-gradle/plugins/src/test/resources/test-projects/bom-platform-hibernate7-micronaut-auto/build.gradle b/grails-gradle/plugins/src/test/resources/test-projects/bom-platform-hibernate7-micronaut-auto/build.gradle new file mode 100644 index 0000000000..9cf8ce588a --- /dev/null +++ b/grails-gradle/plugins/src/test/resources/test-projects/bom-platform-hibernate7-micronaut-auto/build.gradle @@ -0,0 +1,29 @@ +plugins { + id 'org.apache.grails.gradle.grails-app' +} + +grails { + bom = 'grails-hibernate7-micronaut-bom' +} + +tasks.register('inspectBomSetup') { + doLast { + def implDeps = configurations.implementation.allDependencies + + def hasGrailsBom = implDeps.any { dep -> + dep.group == 'org.apache.grails' && dep.name == 'grails-bom' + } + println "HAS_GRAILS_BOM=${hasGrailsBom}" + + def h7MicronautBom = implDeps.find { dep -> + dep.group == 'org.apache.grails' && dep.name == 'grails-hibernate7-micronaut-bom' + } + println "HAS_H7_MICRONAUT_BOM=${h7MicronautBom != null}" + + def enforced = h7MicronautBom?.attributes?.getAttribute(org.gradle.api.attributes.Category.CATEGORY_ATTRIBUTE)?.name == org.gradle.api.attributes.Category.ENFORCED_PLATFORM + println "H7_MICRONAUT_BOM_ENFORCED=${enforced}" + + def hasBomPropertyOverrides = project.plugins.findPlugin('org.apache.grails.gradle.bom-property-overrides') != null + println "HAS_BOM_PROPERTY_OVERRIDES=${hasBomPropertyOverrides}" + } +} diff --git a/grails-gradle/plugins/src/test/resources/test-projects/bom-platform-hibernate7-micronaut-auto/gradle.properties b/grails-gradle/plugins/src/test/resources/test-projects/bom-platform-hibernate7-micronaut-auto/gradle.properties new file mode 100644 index 0000000000..35c332fb87 --- /dev/null +++ b/grails-gradle/plugins/src/test/resources/test-projects/bom-platform-hibernate7-micronaut-auto/gradle.properties @@ -0,0 +1 @@ +grailsVersion=__PROJECT_VERSION__ diff --git a/grails-gradle/plugins/src/test/resources/test-projects/bom-platform-hibernate7-micronaut-auto/settings.gradle b/grails-gradle/plugins/src/test/resources/test-projects/bom-platform-hibernate7-micronaut-auto/settings.gradle new file mode 100644 index 0000000000..261cbedf9f --- /dev/null +++ b/grails-gradle/plugins/src/test/resources/test-projects/bom-platform-hibernate7-micronaut-auto/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'test-bom-platform-hibernate7-micronaut-auto' diff --git a/grails-gradle/plugins/src/test/resources/test-projects/bom-platform-hibernate7-micronaut-manual/build.gradle b/grails-gradle/plugins/src/test/resources/test-projects/bom-platform-hibernate7-micronaut-manual/build.gradle new file mode 100644 index 0000000000..08b6daf192 --- /dev/null +++ b/grails-gradle/plugins/src/test/resources/test-projects/bom-platform-hibernate7-micronaut-manual/build.gradle @@ -0,0 +1,43 @@ +plugins { + id 'org.apache.grails.gradle.grails-app' +} + +dependencies { + implementation enforcedPlatform("org.apache.grails:grails-hibernate7-micronaut-bom:$grailsVersion") +} + +tasks.register('inspectBomSetup') { + doLast { + def implDeps = configurations.implementation.allDependencies + + def hasGrailsBom = implDeps.any { dep -> + dep.group == 'org.apache.grails' && dep.name == 'grails-bom' + } + println "HAS_GRAILS_BOM=${hasGrailsBom}" + + def h7MicronautBom = implDeps.find { dep -> + dep.group == 'org.apache.grails' && dep.name == 'grails-hibernate7-micronaut-bom' + } + println "HAS_H7_MICRONAUT_BOM=${h7MicronautBom != null}" + + def enforced = h7MicronautBom?.attributes?.getAttribute(org.gradle.api.attributes.Category.CATEGORY_ATTRIBUTE)?.name == org.gradle.api.attributes.Category.ENFORCED_PLATFORM + println "H7_MICRONAUT_BOM_ENFORCED=${enforced}" + + def testImplDeps = configurations.testImplementation.allDependencies + def siblingH7MicronautBom = testImplDeps.find { dep -> + dep.group == 'org.apache.grails' && dep.name == 'grails-hibernate7-micronaut-bom' + } + println "SIBLING_HAS_H7_MICRONAUT_BOM=${siblingH7MicronautBom != null}" + + def siblingEnforced = siblingH7MicronautBom?.attributes?.getAttribute(org.gradle.api.attributes.Category.CATEGORY_ATTRIBUTE)?.name == org.gradle.api.attributes.Category.ENFORCED_PLATFORM + println "SIBLING_H7_MICRONAUT_BOM_ENFORCED=${siblingEnforced}" + + def siblingHasGrailsBom = testImplDeps.any { dep -> + dep.group == 'org.apache.grails' && dep.name == 'grails-bom' + } + println "SIBLING_HAS_GRAILS_BOM=${siblingHasGrailsBom}" + + def hasBomPropertyOverrides = project.plugins.findPlugin('org.apache.grails.gradle.bom-property-overrides') != null + println "HAS_BOM_PROPERTY_OVERRIDES=${hasBomPropertyOverrides}" + } +} diff --git a/grails-gradle/plugins/src/test/resources/test-projects/bom-platform-hibernate7-micronaut-manual/gradle.properties b/grails-gradle/plugins/src/test/resources/test-projects/bom-platform-hibernate7-micronaut-manual/gradle.properties new file mode 100644 index 0000000000..35c332fb87 --- /dev/null +++ b/grails-gradle/plugins/src/test/resources/test-projects/bom-platform-hibernate7-micronaut-manual/gradle.properties @@ -0,0 +1 @@ +grailsVersion=__PROJECT_VERSION__ diff --git a/grails-gradle/plugins/src/test/resources/test-projects/bom-platform-hibernate7-micronaut-manual/settings.gradle b/grails-gradle/plugins/src/test/resources/test-projects/bom-platform-hibernate7-micronaut-manual/settings.gradle new file mode 100644 index 0000000000..e90335d758 --- /dev/null +++ b/grails-gradle/plugins/src/test/resources/test-projects/bom-platform-hibernate7-micronaut-manual/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'test-bom-platform-hibernate7-micronaut-manual'
