Search code examples
mavengithub-package-registry

How to use Github Packages for Maven properly with multiple repositories


I have just started moving several github projects that use maven to GitHub packages.

Now I ran into the following problem: One Maven project is dependent on two other libraries that are published via gh packages. Accordingly, I have added the two repositories to the pom.

In order to access the artifacts, I need to put a token (or something to identify) in the maven settings. The credentials are matched by the ID of the servers and repositories. But creating multiple equivalent configurations seems strange to me. Especially, this procedure does not scale as more repositories are added.

Is there a way to avoid creating the same configuration (one per repository in GH) in the settings? I have not found one.


Solution

  • Ok, I've found a workaround: It seems that you can download any github artifact from any github packages maven repository.

    Therefore, I set a dependency in each pom.xml to the github package repository of the certain project. This maven repository can be used (at least it seems so) to download the other projects as well.

    EDIT: For me this does not work anymore. I've migrated all projects to maven central.