How to generate a maven pom using maven-publish plugin with *actual version numbers*?

I have a gradle file that defines dependencies using wildcards:

dependencies {
    compile 'ch.qos.logback:logback-core:1.1.+'
    compile 'ch.qos.logback:logback-classic:1.1.+'
    compile 'com.codahale.metrics:metrics-core:3.0.+'
    ...
}

When I use the maven-publish plugin to generate a pom I get:

<dependency>
  <groupId>javax.el</groupId>
  <artifactId>javax.el-api</artifactId>
  <version>2.2.+</version>
  <scope>runtime</scope>
</dependency>
<dependency>
  <groupId>org.glassfish.web</groupId>
  <artifactId>javax.el</artifactId>
  <version>2.2.+</version>
  <scope>runtime</scope>
</dependency>

Which (obviously) maven cannot deal with. How do I get the pom to only contain resolved version numbers? I tried to modify the pom closure using:

subprojects {
    apply plugin: 'java'
    apply plugin: 'maven-publish'
    apply plugin: 'signing'
      //...
      publishing {
        repositories {
            maven {
                url "${mavenPublishRepo}"
                credentials {
                    username mavenPublishUser
                    password mavenPublishPass
                }
            }
        }
          publications {
            mavenJava(MavenPublication) {
                artifactId "baseline-${project.name}"
                  from components.java
                  artifact srcJar {
                    classifier 'sources'
                }
                  artifact docJar {
                    classifier 'javadoc'
                }
                  pom.withXml {
                    def root = asNode()
                                          // ...
                                          // remove the dependency entries gradle inserts
                    // this is because gradle uses wildcard versions
                    // in a maven pom, making the artifact unusable
                    // in straight-up maven projects
                    root.dependencies.children.each { node -> root.dependencies.remove(node) }
                      // re-add dependencies with fully-qualified versions
                    def dependencies = root.dependencies[0]
                    project.configurations.runtime.resolvedConfiguration.firstLevelModuleDependencies.each { dep ->
                        def dependency = dependencies.appendNode('dependency')
                        dependency.appendNode('groupId', dep.moduleGroup)
                        dependency.appendNode('artifactId', dep.moduleName)
                        dependency.appendNode('version', dep.moduleVersion)
                        dependency.appendNode('scope', 'runtime')
                    }
                }
            }
        }
    }
}

But the maven-publish plugin simply adds the wildcard dependencies along with my fully-resolved ones

This is currently an outstanding issue (see GRADLE-3224). There are a few things to take into consideration when fixing this issue, particularly how to ensure compatibility with Maven/Ivy yet not introduce a lossy conversion when using Gradle. There has been a discussion on the developer mailing list here if you are interested. In the mean time, if you want to retain compatibility with Maven you will have to either use static versions or ‘latest.release’ which is translated to ‘RELEASE’ in the pom.xml. The latter option is only available in Gradle 2.3.

Well - that’s disappointing. Good to know it’s tracked though. I’ll use fixed version numbers for now.