-
-
Notifications
You must be signed in to change notification settings - Fork 969
Solve BOM existential crisis - Fixes #15258 #15259
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: 7.1.x
Are you sure you want to change the base?
Changes from 3 commits
d2f0ace
92fac55
82179b1
f95445f
9690f5e
157bf0d
50e9af2
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 |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ | |
| import org.apache.grails.gradle.tasks.bom.ExtractDependenciesTask | ||
| import org.apache.grails.gradle.tasks.bom.ExtractedDependencyConstraint | ||
| import org.apache.grails.gradle.tasks.bom.PropertyNameCalculator | ||
| import org.gradle.api.publish.tasks.GenerateModuleMetadata | ||
|
|
||
| buildscript { | ||
| apply from: rootProject.layout.projectDirectory.file('dependencies.gradle') | ||
|
|
@@ -39,6 +40,12 @@ javaPlatform { | |
| allowDependencies() | ||
| } | ||
|
|
||
| // Disable Gradle Module Metadata (.module files) for the BOM | ||
| // This allows properties to be overridden with the Spring dependency management plugin | ||
| tasks.withType(GenerateModuleMetadata).configureEach { | ||
|
||
| enabled = false | ||
| } | ||
|
|
||
| ext { | ||
| isReleaseBuild = System.getenv('GRAILS_PUBLISH_RELEASE') == 'true' | ||
| isPublishedExternal = System.getenv().containsKey('NEXUS_PUBLISH_STAGING_PROFILE_ID') | ||
|
|
@@ -160,6 +167,9 @@ ext { | |
| def deps = depMgmt?.dependencies?.getAt(0) | ||
| if (deps) { | ||
| Map<String, String> pomProperties = [:] | ||
| PropertyNameCalculator propertyNameCalculator = new PropertyNameCalculator(combinedPlatforms, combinedDependencies, combinedVersions) | ||
| propertyNameCalculator.addProjects(rootProject.subprojects, projectVersion) | ||
|
|
||
| deps.dependency.each { dep -> | ||
| String groupId = dep.groupId.text().trim() | ||
| String artifactId = dep.artifactId.text().trim() | ||
|
|
@@ -171,8 +181,6 @@ ext { | |
| } | ||
|
|
||
| if (inlineVersion) { | ||
| PropertyNameCalculator propertyNameCalculator = new PropertyNameCalculator(combinedPlatforms, combinedDependencies, combinedVersions) | ||
| propertyNameCalculator.addProjects(rootProject.subprojects) | ||
| ExtractedDependencyConstraint extractedConstraint = propertyNameCalculator.calculate(groupId, artifactId, inlineVersion, isBom) | ||
| if (extractedConstraint?.versionPropertyReference) { | ||
| // use the property reference instead of the hard coded version so that it can be | ||
|
|
@@ -183,18 +191,17 @@ ext { | |
| pomProperties.put(extractedConstraint.versionPropertyName, inlineVersion) | ||
| } | ||
|
|
||
| if (gradle.includedBuilds*.any { it.name == artifactId && groupId.startsWith('org.apache.grails') }) { | ||
| String baseVersionName = artifactId.replaceAll('-', '.') | ||
| String versionName = "${baseVersionName}.version" as String | ||
| dep.version[0].value = "\${${versionName}}" as String | ||
| pomProperties.put(versionName, inlineVersion) | ||
| // For included builds (grails-gradle), also use grails.version | ||
| if (gradle.includedBuilds.any { it.name == artifactId && groupId.startsWith('org.apache.grails') }) { | ||
| dep.version[0].value = "\${${PropertyNameCalculator.GRAILS_VERSION_PROPERTY}}" as String | ||
| pomProperties.put(PropertyNameCalculator.GRAILS_VERSION_PROPERTY, inlineVersion) | ||
| } | ||
| } else if (!inlineVersion) { | ||
| throw new GradleException("Dependency $groupId:$artifactId does not have a version.") | ||
| } | ||
| } | ||
|
|
||
| for (Map.Entry<String, String> property : pomProperties.entrySet()) { | ||
| for (Map.Entry<String, String> property : pomProperties.sort().entrySet()) { | ||
| propertiesNode.appendNode(property.key, property.value) | ||
| } | ||
| } | ||
|
|
||
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.
Why would you ever override different versions of grails projects? Why not just change the version of the bom you're using instead?
Uh oh!
There was an error while loading. Please reload this page.
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.
@jdaugherty Compare the before (M3) and after BOMs.
I am saying overriding is better than using a grails property for everyone because if you did that you would get version conflicts from transitive dependencies.
I am recommending using
instead of