How to configure Gradle, Github Package Registry Maven

I was just playing with this and thought I would share what I have found so far.
Configuration is fairly straight forward when using the maven-publish plugin.

apply plugin: "maven-publish"

publishing {
  repositories {
    maven {
      name = "Github"
      url = uri("") //TODO update owner/repo
      credentials {
        //findProperty will allow these properties to be absent and still run the build, just won't publish
        username = findProperty("GITHUB_USERNAME")
        password = findProperty("GITHUB_API_TOKEN")
  publications {
    register("jar", MavenPublication) {
      pom {
        url.set("") //TODO update owner/repo

I am unable to upload classified artifacts, IE sources jar.

Could not PUT ''. Received status code 403 from server: Forbidden

 I sent in a support request on the classified artifacts being rejected, as well as a request to add gradle to the documentation. 

My hope is that they will also have decent support for gradle projects producing .module metadata by the time it reaches general release as well.


Hej man any news on that? 

I have the same issue that my sources.jar gets rejected

@marvinschramm They responded asking for reproduction steps which I provided and have not heard anything since then.

additionally they don’t handle the maven-metadata.xml correctly which results in 400 errors when gradle tries to read what is there before publishing a new snapshot.

1 Like

Yea i’ve noticed that.

Now we have 1 half published package on our repository which we cant delete…

I think we’ll wait until everything is out of beta.

Thank you!

I have the same issues, I’ve had nothing but issues, this looks like such a useful thing but it seems funamentally broken at the moment.

1 Like

Same Here! @marvinschramm did it work for u???

Same problems from me. I am able to publish the pom files with package registry, but beyond that, everything is rejected. People said that I might need pom properties in my jar, but that doesn’t help in any way.

Addiiton of pom properties:

The packages with pom only:

Anyone figured out how to uplaod sources and javadoc ? I am similarly with a half published package.

1 Like

I just ran into the same issue. For me it did upload the build .jar and the .pom file but it rejected the sources and javadoc. The publication can be found here:

@trevjonez Running into the same issue as well. Support ticket in but nothing yet. Any updates on your side?

I got an initial response that was “can you give a reproduction example” for the classified artifact issue, which I gave them immediately. Radio silence since then.

here is my reproduction:

as well as a gradle scan of the issue happening:

while doing the reproduction I also found that republishing snapshots fail when querying the maven metadata which is shown in this scan:

All of this was August 22 2019

I’ve exactly the same issue. Have you found any solution?

This should work now

I forked your project and ran gradle publish which works without errors.

BTW we’ve added a new help section for Gradle here:


Hey @clarkbw,

Still having issues with this on my end. When declaring the implementation for this in an Android project, how are you writing it so it finds the files? I can’t seem to get it to point to the files in that fork of yours correctly for the life of me.

Have tried 

implementation 'com.trevjonez:github-registry-repro:1.1'

and pretty much every other variation I can think of. Have set up the maven url to point to the repository correctly and provided authentication, but its not constructing a valid path to get the files from.

Any help would be greatly appreciated!


This is now working, my error was when setting the url in the maven block, we were only including the OWNER in the url, not the OWNER/REPOSITORY (on both the publishing and implementation sides). Though this does lead to published packages having the repository name in the name of the package itself, which isn’t ideal, it fixes it enough to use which is great.

Hi @clarkbw, thanks for posting this. FYI the Kotlin DSL instructions are broken on Gradle 5.6.3. I had to change this line:

register("gpr") {


register("gpr", MavenPublication::class) {

This does not appear to be solved. I’m still seeing this issue with my project.

1 Like

can you be more specific about your issue?

I have tried to publish a package from actions by running “gradle publish”, but is getting:

Could not transfer artifact dk.youtec:appupdater:jar:1.0.1 from/to remote ( Could not write to resource 'dk/youtec/appupdater/1.0.1/appupdater-1.0.1.jar'

Could not transfer artifact dk.youtec:appupdater:pom:1.0.1 from/to remote ( Could not write to resource 'dk/youtec/appupdater/1.0.1/appupdater-1.0.1.pom'
> Task :publishAppupdaterPluginPublicationToGitHubPackagesRepository FAILED

7 actionable tasks: 7 executed
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':publishAppupdaterPluginPublicationToGitHubPackagesRepository'.
> Failed to publish publication 'appupdaterPlugin' to repository 'GitHubPackages'
   > Could not deploy to remote repository | Failed to deploy artifacts: Could not transfer artifact dk.youtec:appupdater:jar:1.0.1 from/to remote ( Could not write to resource 'dk/youtec/appupdater/1.0.1/appupdater-1.0.1.jar'

build.gradle.kts looks like this:

publishing {
    repositories {
        maven {
            name = "GitHubPackages"
            url = uri("")
            credentials {
                username = project.findProperty("gpr.user") as String? ?: System.getenv("USERNAME")
                password = project.findProperty("gpr.key") as String? ?: System.getenv("PASSWORD")
    publications {
        register("appupdaterPlugin", {
            groupId = "dk.youtec"
            artifactId = "appupdater"
            version = "1.0.1"


Actions build.yml looks like this:

name: CI

on: [push]


    runs-on: ubuntu-latest

    - uses: actions/checkout@v1
    - name: set up JDK 1.8
      uses: actions/setup-java@v1
        java-version: 1.8
    - name: Build appupdater plugin
      run: |
        ./gradlew publish
1 Like

I figured it out. I just had to add the properties to the gradle command in build.yml myself, like so:

-name: Build appupdater plugin
run: |
./gradlew build
./gradlew -Pgpr.user=clhols -Pgpr.key=${{ secrets.GITHUB_TOKEN }} publishAppupdaterPluginPublicationToGitHubPackagesRepository

I ended up using


Basically the same thing, just throwing that out there :slight_smile: