1

Iam trying to pull an artifact hosted in github(company's private repo) but it is throwing an error:

[INFO] Scanning for projects...
[INFO] 
[INFO] -------------------------< com.my:package-order >-------------------------
[INFO] Building order 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
Downloading from org-name-common-utility: https://github.com/{ORG-ID}/{REPO-NAME}/tree/mvn-repo/path/to/org-name-common-utility-1.0.pom
Downloading from central: https://repo.maven.apache.org/maven2/path/to/org-name-common-utility-1.0.pom
[WARNING] The POM for com.org.common-utility:org-name-common-utility:jar:1.0 is missing, no dependency information available
[WARNING] The artifact org.hibernate:hibernate-validator:jar:6.0.14.Final has been relocated to org.hibernate.validator:hibernate-validator:jar:6.0.14.Final
Downloading from org-name-common-utility: https://github.com/{ORG-ID}/{REPO-NAME}/tree/mvn-repo/path/to/org-name-common-utility-1.0.jar
Downloading from central: https://repo.maven.apache.org/maven2/path/to/org-name-common-utility-1.0.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.171 s
[INFO] Finished at: 2022-04-07T21:31:01+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project package-order: Could not resolve dependencies for project com.org:package-order:jar:0.0.1-SNAPSHOT: Could not find artifact com.org.common-utility:org-name-common-utility:jar:1.0 in github (https://github.com/{ORG-ID}/{REPO-NAME}/tree/mvn-repo/) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

my settings.xml

<settings>
  <servers>
    <server>
      <id>github</id>
      <password>MY-GITHUB-TOKEN</password>
    </server>
  </servers>
</settings>

added these lines in POM file of the project in which i want add the dependency(keeping same as id defined in server)

<repositories>
        <repository>
            <id>github</id>
            <url>https://github.com/{ORG-ID}/{REPO-NAME}/tree/mvn-repo/</url>
        </repository>
    </repositories>

added dependency

<dependency>
            <groupId>com.org.common-utility</groupId>
            <artifactId>org-name-common-utility</artifactId>
            <version>1.0</version>
        </dependency>

NOTE: aritfact upload is working properly fine and binaries uploaded successfully to mvn-repo branch. followed this article: https://dev.to/iamthecarisma/hosting-a-maven-repository-on-github-site-maven-plugin-9ch

Eldad Assis
  • 10,464
  • 11
  • 52
  • 78
manish
  • 73
  • 1
  • 6
  • Were you able to figure out why a particular artifact wasn't downloading? I am running into the same issue. The artifact I am not able to reach from a github action was uploaded using the mvn release plugin. Other artifacts that I can reach were installed with the mvn deploy plugin. I believe the same settings.xml was used for both. – Scot Oct 04 '22 at 23:55
  • Github packages creates a namespace for each repository, so GitHub actions from one will not be able to reach the namespace for another if this pattern is used: https://github.com/{ORG-ID}/{REPO-NAME}. REPO-NAME-A won't be able to reach REPO-NAME-B in some setups. – Scot Oct 05 '22 at 17:48
  • @Scot so are you trying this in an open repository or a repository managed by an org. If open repo then it will work completely fine both pull and push. If you are trying this for a org managed repo then this what I got know after applying many approaches with no success. So it's simple private repo can't be accessed while adding it as an dependency, but if you will try to create a mvn repo in GitHub packages then it will work completely fine in every case: pull push in local, pull push under a cicd pipeline (gh action or others as well). So now we using gh packages to achieve this. – manish Oct 16 '22 at 17:05

0 Answers0