Skip to content

Commit 21562ba

Browse files
authored
Merge pull request #15605 from apache/grailsBomRestructure
Backport Grails Bom Restructure from Hibernate 7 branch
2 parents 87a5523 + caa7473 commit 21562ba

201 files changed

Lines changed: 1683 additions & 203 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/gradle.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,32 @@ concurrency:
2525
group: ${{ github.workflow }}-${{ github.ref }}
2626
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
2727
jobs:
28+
validateDependencies:
29+
name: 'Validate Dependency Versions'
30+
runs-on: ubuntu-24.04
31+
steps:
32+
- name: "📥 Checkout repository"
33+
uses: actions/checkout@v6
34+
- name: "☕️ Setup JDK"
35+
uses: actions/setup-java@v4
36+
with:
37+
distribution: liberica
38+
java-version: 17
39+
- name: "🐘 Setup Gradle"
40+
uses: gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0
41+
with:
42+
develocity-access-key: ${{ secrets.GRAILS_DEVELOCITY_ACCESS_KEY }}
43+
- name: "🔍 Validate grails-core dependency versions"
44+
run: >
45+
./gradlew validateDependencyVersions
46+
--continue
47+
--stacktrace
48+
- name: "🔍 Validate grails-gradle dependency versions"
49+
working-directory: 'grails-gradle'
50+
run: >
51+
./gradlew validateDependencyVersions
52+
--continue
53+
--stacktrace
2854
buildGradle:
2955
name: 'Build Gradle Plugins'
3056
strategy:

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ prodDb.mv.db
5252
testWatchedFile.properties
5353
_alternativeTable.gsp
5454
**/src/en/ref/Versions/Grails BOM.adoc
55+
**/src/en/ref/Versions/Grails BOM Hibernate5.adoc
56+
**/src/en/ref/Versions/Grails BOM Micronaut.adoc
57+
**/src/en/ref/Configuration/Application Properties.adoc
5558
stacktrace.log
5659
target
5760
tmp/

build-logic/docs-core/src/main/groovy/org/apache/grails/gradle/tasks/bom/ExtractDependenciesTask.groovy

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import org.gradle.api.artifacts.DependencyConstraint
3232
import org.gradle.api.artifacts.ExcludeRule
3333
import org.gradle.api.artifacts.ModuleDependency
3434
import org.gradle.api.artifacts.component.ModuleComponentSelector
35+
import org.gradle.api.artifacts.component.ProjectComponentSelector
3536
import org.gradle.api.artifacts.result.DependencyResult
3637
import org.gradle.api.artifacts.result.ResolvedDependencyResult
3738
import org.gradle.api.file.ConfigurableFileCollection
@@ -83,12 +84,28 @@ abstract class ExtractDependenciesTask extends DefaultTask {
8384
@Input
8485
abstract MapProperty<String, String> getProjectCoordinateProperties()
8586

87+
/**
88+
* When {@code true}, transitive platform dependencies that are not explicitly
89+
* registered in {@code combinedPlatforms} / {@code dependencies.gradle} will be
90+
* auto-registered in {@link PropertyNameCalculator} instead of causing a build
91+
* failure. This is required for BOMs that import an external platform via the
92+
* gradle module format (e.g. {@code micronaut-platform}) which itself imports
93+
* many sub-BOMs that Grails does not manage directly.
94+
*
95+
* <p>Defaults to {@code false} so that existing BOMs (grails-bom, grails-base-bom)
96+
* retain the strict validation that every platform dependency has a known property
97+
* name in {@code dependencies.gradle}.</p>
98+
*/
99+
@Input
100+
abstract Property<Boolean> getAutoRegisterTransitivePlatforms()
101+
86102
void setConfiguration(NamedDomainObjectProvider<Configuration> config) {
87103
dependencyArtifacts.from(config)
88104
configurationName.set(config.name)
89105
}
90106

91107
ExtractDependenciesTask() {
108+
autoRegisterTransitivePlatforms.convention(false)
92109
doFirst {
93110
if (!project.pluginManager.hasPlugin('java-platform')) {
94111
throw new GradleException(/The 'java-platform' plugin must be applied to the project to use this task./)
@@ -188,6 +205,13 @@ abstract class ExtractDependenciesTask extends DefaultTask {
188205
}
189206

190207
ResolvedDependencyResult dep = (ResolvedDependencyResult) result
208+
209+
// Skip project dependencies (e.g. platform(project(':grails-bom'))) since their
210+
// constraints are already captured through the explicit constraints population
211+
if (dep.requested instanceof ProjectComponentSelector) {
212+
continue
213+
}
214+
191215
ModuleComponentSelector moduleComponentSelector = dep.requested as ModuleComponentSelector
192216

193217
// Any non-constraint via api dependency should *always* be a platform dependency, so expand each of those
@@ -199,6 +223,16 @@ abstract class ExtractDependenciesTask extends DefaultTask {
199223

200224
// fetch the BOM as a pom file so it can be expanded
201225
ExtractedDependencyConstraint constraint = propertyNameCalculator.calculate(bomCoordinate.groupId, bomCoordinate.artifactId, bomCoordinate.version, true)
226+
if (!constraint) {
227+
if (autoRegisterTransitivePlatforms.get()) {
228+
// Auto-register the transitive platform so it can be documented and expanded,
229+
// but without a version property reference since the version is managed by the
230+
// parent platform (e.g. micronaut-platform), not by a Grails property.
231+
constraint = new ExtractedDependencyConstraint(bomCoordinate.coordinates)
232+
} else {
233+
throw new GradleException("Failed to find a property name for BOM dependency: ${bomCoordinate.coordinates}. All platform dependencies must have a property name defined meeting the naming requirements.")
234+
}
235+
}
202236
constraint.source = bomCoordinate.artifactId
203237
constraints.put(bomCoordinate.toCoordinateHolder(), constraint)
204238

build-logic/plugins/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,9 @@ gradlePlugin {
7474
id = 'org.apache.grails.buildsrc.repo'
7575
implementationClass = 'org.apache.grails.buildsrc.GrailsRepoSettingsPlugin'
7676
}
77+
register('grailsDependencyValidator') {
78+
id = 'org.apache.grails.buildsrc.dependency-validator'
79+
implementationClass = 'org.apache.grails.buildsrc.GrailsDependencyValidatorPlugin'
80+
}
7781
}
7882
}

build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/GradleUtils.groovy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ class GradleUtils {
4848
def v = findProperty(project, name)
4949
return v == null ? null : Integer.valueOf(v as String) as T
5050
}
51+
if (type && (type == Boolean || type == boolean.class)) {
52+
def v = findProperty(project, name)
53+
return v == null ? null : Boolean.parseBoolean(v as String) as T
54+
}
5155

5256
findProperty(project, name) as T
5357
}

0 commit comments

Comments
 (0)