[GRADLE-3021] 'latest.release' version results with improper POM for uploadArchives task Created: 12/Feb/14  Updated: 13/Jan/15  Resolved: 09/Dec/14

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: 2.3-rc-1

Type: Bug
Reporter: Gradle Forums Assignee: René Gröschke (Inactive)
Resolution: Fixed Votes: 0


 Description   

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?



 Comments   
Comment by Gradle Forums [ 12/Feb/14 ]

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.

Generated at Wed Jun 30 12:37:45 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.