'latest.release' version results with improper POM for uploadArchives task, doesn't it?

Following code at build.gradle:

dependencies {
    compile 'org.codehaus.groovy:groovy-all:latest.release'
}

When publishing to maven repo will result with such dependency respectively at created POM:

<dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-all</artifactId>
      <version>latest.release</version>
      <scope>compile</scope>
    </dependency>

That’s not a valid version for Maven, is it? Maven build will fail with a dependency at pom.xml specified like this.

Is there any way of replacing ‘latest.version’ (or any other ‘text’ variable version) with version of an actual resolved artifact upon archive upload?

OK, I guess it would be something like this:

uploadArchives {
    repositories {
        mavenDeployer {
            repository(url: '...')
            pom.whenConfigured { pom ->
                def resolvedIdentifiers = project.configurations.default.resolvedConfiguration.resolvedArtifacts*.moduleVersion.id
                pom.dependencies.findAll { it.version == 'latest.release' }.each { dependency ->
                    def id = resolvedIdentifiers.find { dependency.groupId == it.group && dependency.artifactId == it.name }
                    dependency.version = id.version
                }
            }
        }
    }
}

Probably it would be better to do it for all configurations and even without filtering by it.version == ‘latest.release’. Just overwrite all.

By the way, why maven plugin doesn’t do it by default? Or maybe there is some simpler approach available via its API?

It rather doesn’t make sense, to generate POM upon deploying to maven repo and then not being able to use deployed artifact as maven dependency because any maven build will fail on unrecognised version of transitive dependencies.

It’s a known limitation. I’ve raised GRADLE-3021 to track it.

Thanks, Peter.

Can I log to JIRA with the same credentials as to the forum? I guess no…

Unfortunately not, we don’t currently have that integrated.

Thanks Peter, Is there a workaround to this? i.e. if we use Artifactory and dependencies can have either latest.release or latest.integration. Can both be resolved before pom is uploaded.