GitHub Packages as Maven repo with dynamic version resolution: 404 retrieving maven-metadata.xml

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 \<sometokenhere\>' 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' } } }

I have raised a GitHub Enterprise support ticket and been told that there is a known issue that they are aware of where (some?) users get 404s when requesting maven-metadata.xml, but they have said they cannot confirm when or even if the issue will ever be fixed. I have not been given any further information by GitHub.

My question is: has anyone managed to get dynamic version resolution working with GitHub Packages?

Cross-posted on StackOverflow here: https://stackoverflow.com/questions/59264015/github-packages-404-for-maven-metadata-xml-does-it-support-dynamic-version-res

6 Likes

Same problem here. Interestingly they told me they are discussing this feature, so I thought it is not yet possible in general?

This is the main reason that keeps my team from moving completely to GH-actions/packages, which is rather sad