Maven with multiple Github dependencies #58119
Replies: 2 comments
-
|
🕒 Discussion Activity Reminder 🕒 This Discussion has been labeled as dormant by an automated system for having no activity in the last 60 days. Please consider one the following actions: 1️⃣ Close as Out of Date: If the topic is no longer relevant, close the Discussion as 2️⃣ Provide More Information: Share additional details or context — or let the community know if you've found a solution on your own. 3️⃣ Mark a Reply as Answer: If your question has been answered by a reply, mark the most helpful reply as the solution. Note: This dormant notification will only apply to Discussions with the Thank you for helping bring this Discussion to a resolution! 💬 |
Beta Was this translation helpful? Give feedback.
-
|
I wish someone had answered this because it is definitely a problem: The instructions that work for one dependency do not work for two or more. Or maybe they do but there are so many things that can be wrong, it can be a nightmare. One big gotcha is that you need to USE LOWERCASE URLS, even if the owner or project name uses capitals. Apparently, this is a github thing. And don't forget the distributionManagement element in the published pom.xml. And then the ids for the repositories have to be unique. This causes a bit of duplication. This is a settings.xml file with two referenced projects (repo1 and repo2). You need this to avoid having personal-access-tokens in publicly visible pom.xml files. <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>github-repo1</id>
<username>owner</username>
<password>personal-access-code of-owner</password>
</server>
<server>
<id>github-repo2</id>
<username>owner</username>
<password>personal-access-code of-owner</password> <!-- just a duplicate of above -->
</server>
</servers>
<activeProfiles>
<activeProfile>github-repo1</activeProfile>
<activeProfile>github-repo2</activeProfile>
</activeProfiles>
<profiles>
<profile>
<id>github-repo1</id>
<repositories>
<repository>
<id>github-repo1</id>
<url>https://maven.pkg.github.com/owner/repo1</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
<profile>
<id>github-repo2</id>
<repositories>
<repository>
<id>github-repo2</id>
<url>https://maven.pkg.github.com/owner/repo2</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
</settings>In each of these project pom.xml files, make sure you have something like this: <distributionManagement>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/ownername/repo1</url>
</repository>
</distributionManagement>And then in your third project pom.xml that references these (either one or both projects), add the following. <repository>
<!-- The id is critical, as it maps to permissions in the settings.xml file-->
<id>github-repo1</id>
<url>https://maven.pkg.github.com/owner/repo1</url>
</repository>
<repository>
<!-- The id is critical, as it maps to permissions in the settings.xml file-->
<id>github-repo2</id>
<url>https://maven.pkg.github.com/owner/repo2</url>
</repository>There might be a cleaner way to do this, but it is the only way I've found that works. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Select Topic Area
Question
Body
Hello everyone,
I'm working on a project and with host all our Maven package on Github Repository, base on what the documentation said we have to add this :
For the case oh having multiple dependencies, just imagine like 10, do we need to add such line for all the dependencies?
I use to correctly make it work with one dependency and authorization works well, but with multiple a face a 401 Error.
Does someone have any advice?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions