Gradle fails to download package from Github Package Registry
Asked Answered
P

2

8

Uploading the public package with gradle works: https://github.com/ttiganik/hrd-java-test-registry/packages/61312

But I am unable to download it. I tried different URL-s and package names, but none of them work.

According to documentation the correct URL-s should be:

repositories {
    maven {
        url "https://maven.pkg.github.com/ttiganik/hrd-java-test-registry"
        credentials {
            username = System.properties['hmGithubUser']
            password = System.properties['hmGithubToken']
        }
    }
}

dependencies {
    implementation 'com.ttiganik:test:1.0.0'
}

The credentials are the same as for uploading.

gradle installDebug says it looks from the correct location:

> Could not find com.ttiganik:test:1.0.0.
  Searched in the following locations:
    - https://maven.pkg.github.com/ttiganik/com/ttiganik/test/1.0.0/test-1.0.0.pom
    - https://maven.pkg.github.com/ttiganik/com/ttiganik/test/1.0.0/test-1.0.0.jar
  Required by:

but it doesn't install it.

If I comment out the credentials in maven repository, it says 401 unauthorised. So the location seems to be correct.

What is wrong with my GPR configuration?

Posture answered 22/11, 2019 at 4:8 Comment(1)
After reading this I suspect you need a READ token on GitHub just to pull the package: proandroiddev.com/…Where
P
0

The problem was that I didn't include correct package name. You need to include package name 2x.

-     implementation 'com.ttiganik:test:1.0.0'
+     implementation 'com.ttiganik.test:test:1.0.0'

It's easier to just copy the dependency straight from Github. They include the correct name

Posture answered 16/12, 2022 at 2:20 Comment(0)
H
0

Had this same issue and discovered that if you're part of an organization on Github, you might have to grant/authorise your token to be able to access your organisation for it to be able to work. Go to your personal access token in Account -> Settings -> Developer Settings -> Personal Access Token -> Tokens (classic).

Then click on Configure SSO if applicable, then find your organisation and click authorise.

Hydracid answered 2/2, 2023 at 18:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.