Has anyone managed to get Maven dynamic version resolution working with GitHub packages?
I want to be able to declare a dependency with a dynamic version and have it resolved, like this:
dependencies {
compile 'com.example:my-package:1.+'
}
Under the covers, Gradle (and Maven too, I assume), uses the information inside a file called maven-metadata.xml
which contains details of which packages & versions exist in the repository to resolve the dynamic version to a particular version (e.g. 1.+
might resolve to 1.1.2
). However, when I publish to GitHub Packages, the Gradle logs show that the maven-metadata.xml
file resource does not exist, so it uploads a new one without error. However, when I try and curl that file, I get a 404 (meaning I am either publishing and GitHub is silently dropping the file, or the file is inside GitHub and is not visible to me after publishing).
// inside the Gradle debug logs, showing successful upload
14:43:16.332 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Upload https://maven.pkg.github.com/ORG/REPO/com/example/group/artifact-id/maven-metadata.xml' completed
This gives a 404 (when it should either resolve to a file or give me a redirect that I can follow with a -L
flag on the curl
command):
curl -X GET -v -H 'Authorization: token <some token here>' https://maven.pkg.github.com/ORG/REPO/com/example/group/artifact-id/maven-metadata.xml
Here is my repository configuration closure for dependency resolution; I use an identical one for publishing using the maven-publish
plugin inside a publishing{}
closure.
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/ORG/REPO")
credentials {
username = 'some-user'
password = 'github-token-with-repo-scope'
}
}
}