Skip to content

cannot read dependency from GitHub packages #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sothawo opened this issue Jun 3, 2021 · 4 comments
Closed

cannot read dependency from GitHub packages #3

sothawo opened this issue Jun 3, 2021 · 4 comments

Comments

@sothawo
Copy link
Contributor

sothawo commented Jun 3, 2021

Thanks for providing this, I just wanted to do a first test. Maybe I am missing something, but I don't get the dependency, I am getting an error about not being authorized:

$ ./gradlew classes
> Task :compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Could not resolve all files for configuration ':compileClasspath'.
   > Could not resolve co.elastic.clients:elasticsearch-java:8.0.0-SNAPSHOT.
     Required by:
         project :
      > Could not resolve co.elastic.clients:elasticsearch-java:8.0.0-SNAPSHOT.
         > Unable to load Maven meta-data from https://maven.pkg.github.com/elastic/elasticsearch-java/co/elastic/clients/elasticsearch-java/8.0.0-SNAPSHOT/maven-metadata.xml.
            > Could not get resource 'https://maven.pkg.github.com/elastic/elasticsearch-java/co/elastic/clients/elasticsearch-java/8.0.0-SNAPSHOT/maven-metadata.xml'.
               > Could not GET 'https://maven.pkg.github.com/elastic/elasticsearch-java/co/elastic/clients/elasticsearch-java/8.0.0-SNAPSHOT/maven-metadata.xml'. Received status code 401 from server: Unauthorized

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 2s
1 actionable task: 1 executed

$  https maven.pkg.github.com/elastic/elasticsearch-java/co/elastic/clients/elasticsearch-java/8.0.0-SNAPSHOT/maven-metadata.xml                                                                             1 ↵
HTTP/1.1 401 Unauthorized
Access-Control-Allow-Origin: *
Content-Length: 0
Content-Security-Policy: default-src 'none';
Date: Thu, 03 Jun 2021 15:52:04 GMT
Server: GitHub Registry
Strict-Transport-Security: max-age=31536000;
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-GitHub-Request-Id: FC2A:7EF3:13680D:168AD5:60B8FAA4
X-XSS-Protection: 1; mode=block
access-control-allow-methods: GET, HEAD, OPTIONS
www-authenticate: Basic realm="GitHub Package Registry"

My setup for gradle is as in the documentation, when I try to open the link to the metada file, my browser wants me to login as well.

@sothawo
Copy link
Contributor Author

sothawo commented Jun 4, 2021

I was missing the token to be able to read packages from GitHub packages. I created a Personal Access Token (https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token) that only has the read packages access defined.

After that I changed the gradle repository definition to:

repositories {
    mavenCentral()
    maven {
        name = "GitHubPackages"
        url = uri("https://maven.pkg.github.com/elastic/elasticsearch-java")
        credentials(PasswordCredentials)
    }
}

and added my username and the token as password to my ~/.gradle/gradle.properties file:

GitHubPackagesUsername=USERNAME
GitHubPackagesPassword=PERSONAL_ACCESS_TOKEN

Now it works

@sothawo sothawo closed this as completed Jun 4, 2021
@swallez
Copy link
Member

swallez commented Jun 11, 2021

Oh, indeed GitHub requires a token even for read access. I've updated the README with additional instructions in 99e191d. Thanks!

@sothawo
Copy link
Contributor Author

sothawo commented Jun 11, 2021

I suppose once the client is final, it will be available via maven central? Because otherwise everyone who is using Spring Data Elasticsearch would need to create a PAT.

@swallez
Copy link
Member

swallez commented Jun 11, 2021

Absolutely! We're working on it, as it has to be part of Elastic's "unified release process" that coordinates artifact construction and publication for all Elastic products.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants