I have a Gradle script that uses a previously released version of its own artifact as a dependency (one of my tasks runs a diff process between the version I just built and the last release). For some reason, even when I specify the version that’s on Maven Central, Gradle resolves the dependency as being the local artifact that I just built.
Script (snippet):
group = 'com.foo'
version = '0.3.5'
configurations {
bar
}
dependencies {
bar group: 'com.foo', name: 'bar', version: '0.3.4', transitive: false
}
task checkDependency {
configurations.bar.each { println it }
}
‘D:\myProject>gradle checkDependency’
Output:
D:\myProject\build\libs\bar-0.3.5.jar
It will resolve this way even if the 0.3.5 jar (or the build directory entirely) doesn’t exist! If I change the buildscript’s group to have a typo in it such as “com.ffoo” thus giving the artifact a different namespace from what’s in the dependency, then it properly resolves the 0.3.4 version in my local cache downloaded from Maven Central. Why doesn’t the same work for the version?
At first I thought this was an issue with pulling the latest integration, as I initially had “latest.integration” as the version for my dependency, but I have no idea why this would be happening when the version is now hard coded.