github / maven-plugins

Official GitHub Maven Plugins
MIT License
584 stars 198 forks source link

Problems resolving dependencies in private repository #86

Open jnehring opened 9 years ago

jnehring commented 9 years ago

Hey there,

this seems to be a great plugin but I have a problem using it. Im trying to use it with a private organization account. I have two project A and B. Project A is deployed via github maven on the server, that works fine. Project B has a dependency on project A. Therefore I have configured the GitHub repository in project B pom.xml like this

<repository>
    <id>github</id>
    <url>https://raw.githubusercontent.com/ORGANIZATION/REPOSITORY/BRANCH</url>
    <snapshots>
        <enabled>true</enabled>
        <updatePolicy>always</updatePolicy>
    </snapshots>
</repository>

my maven settings.xml has the credentials to this repo. I get the following error when trying to do mvn install on project B (I removed hints to my project from the URLs):

Downloading: https://raw.githubusercontent.com/.../0.0.1-SNAPSHOT/maven-metadata.xml
Downloading: https://raw.githubusercontent.com/...0.0.1-SNAPSHOT.pom
[WARNING] The POM for ...0.0.1-SNAPSHOT is missing, no dependency information available
Downloading: https://raw.githubusercontent.com/...0.0.1-SNAPSHOT/conversion-0.0.1-SNAPSHOT.jar

and then

[ERROR] Failed to execute goal on project Broker: Could not resolve dependencies
 for project ...:0.0.1-Snapshot: Could not find artifact ...:jar:0.0.1-SNAPSHOT in github 
(https://raw.githubusercontent.com/...) -> [Help 1]

When I check the URLs that maven tries to download I can see that the required access token / credentials are not attached to the URL.

So my question: How can I use this plugin together with a private repository?

WeipingGuo commented 9 years ago

I am facing the same issue. Any update on this? I tested by creating a public repository, and it works fine.

By applying the same approach, I can push and deploy to my company's repository. However, the other project which depends on this has trouble to get the jar.

Any suggestions are appreciated!

pasviegas commented 8 years ago

I am facing the same too :(

boldtrn commented 8 years ago

+1

einpaule commented 8 years ago

We're facing the same issue and the one thing that becomes clear is that the initial Downloading: https://raw.github.com/MyOrganization/MyProject/mvn-repo/com/company/CommonLibraries/0.1.4-SNAPSHOT/maven-metadata.xml already does not succeed. This is visible by adding -X to the command.

Following the steps in the accepted answer to this question (including comments) does not seem to work for me, did everyone else try that route?

DCCaldwell commented 8 years ago

+1

einpaule commented 8 years ago

We got a message from GitHub support after telling them what URLs were being hit (see above):

Raw URLs are not designed to be used this way. You should use the URL of a published release asset file rather than GitHub Raw URLs.

So I guess the approach for this plugin should change...

brwstar commented 8 years ago

+1

donkeysharp commented 7 years ago

Is there any update? I'm having the same issues with github enterprise

hareeshav commented 7 years ago

I'm also facing the same issue. Does anybody found any solution for this?

donkeysharp commented 7 years ago

I could solve it adding username and token as headers: On settings.xml I have this:


<settings>
  <servers>
    <server>
      <id>github</id>
      <username>{{github username}}</username>
      <password>{{github access token}}</password>
      <configuration>
        <httpHeaders>
          <property>
            <name>Authorization</name>
            <!-- Base64-encoded username:access_token -->
            <value>Basic {{base64 encoded content}}==</value>
          </property>
        </httpHeaders>
      </configuration>
    </server>
  </servers>

  <repositories>
    <repository>
      <id>github</id>
      <name>github</name>
      <!-- It's important to have the raw subdomain -->
      <url>{{raw_url_on_github}}</url>
    </repository>
  </repositories>
</settings>

Something silly I was doing is that I was confusing the SNAPSHOT version, but that was my mistake.

OliRoi commented 5 years ago

Hey guys, comment above didn't work for me. For some reason Maven wasn't sending the defined headers. Then I accidentally found that different structure for header definition works. Maybe it can be useful for somebody :) My Maven version is 3.6.1.

<configuration>
    <httpHeaders>
        <!-- Base64-encoded username:access_token -->
        <authorization>Basic {{base64 encoded content}} </authorization>
    </httpHeaders>
</configuration>
alampata-apps commented 2 years ago

This might help someone: https://stackoverflow.com/a/58464642/4816270

GitHub Package Doc which finally worked: https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-gradle-registry

manishsp21 commented 2 years ago

does any body got success with a working solution for this, please help iam stuck with the same issue https://stackoverflow.com/questions/71786277/maven-error-could-not-find-artifact-hosted-in-private-github-repository

solexmb commented 1 year ago

Any solution on this yet?