You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@grails.apache.org by jd...@apache.org on 2026/04/27 03:47:48 UTC

(grails-gradle-publish) 01/01: Ensure versions are always published in the Gradle metadata

This is an automated email from the ASF dual-hosted git repository.

jdaugherty pushed a commit to branch gradle9VersionMapping
in repository https://gitbox.apache.org/repos/asf/grails-gradle-publish.git

commit 1cfd5f0a6d69aa8d9f0eb0c9685b8a20f1b0dd2a
Author: James Daugherty <jd...@jdresources.net>
AuthorDate: Sun Apr 26 23:47:15 2026 -0400

    Ensure versions are always published in the Gradle metadata
---
 .../gradle/publish/GrailsPublishGradlePlugin.groovy      | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/plugin/src/main/groovy/org/apache/grails/gradle/publish/GrailsPublishGradlePlugin.groovy b/plugin/src/main/groovy/org/apache/grails/gradle/publish/GrailsPublishGradlePlugin.groovy
index 921e2fb..4838624 100644
--- a/plugin/src/main/groovy/org/apache/grails/gradle/publish/GrailsPublishGradlePlugin.groovy
+++ b/plugin/src/main/groovy/org/apache/grails/gradle/publish/GrailsPublishGradlePlugin.groovy
@@ -331,6 +331,22 @@ Note: if project properties are used, the properties must be defined prior to ap
                             if (extraArtefact) {
                                 publication.artifact(extraArtefact)
                             }
+
+                            // Ensure Gradle module metadata includes resolved versions for
+                            // all dependencies. Without this, dependencies declared without
+                            // an explicit version (relying on a platform/BOM) are published
+                            // with no version in the .module file, causing resolution
+                            // failures for consumers since Gradle prefers .module over .pom.
+                            if (!project.extensions.findByType(JavaPlatformExtension)) {
+                                publication.versionMapping { strategy ->
+                                    strategy.usage('java-api') { variant ->
+                                        variant.fromResolutionOf('runtimeClasspath')
+                                    }
+                                    strategy.usage('java-runtime') { variant ->
+                                        variant.fromResolutionResult()
+                                    }
+                                }
+                            }
                         }
 
                         publication.pom { MavenPom pom ->