I am trying to setup 2 GitLab projects (project a & project b) as the remote maven repository for my other project (project c) using GitLab Maven Package Registry.
Now I have 2 GitLab Maven Package Registry
- project A -> id : 112233
- project B -> id : 445566
So, now I need to set the registry setup in my project C pom.xml file
How I can do that, because we can't have multiple in our pom.xml file
<!--registry setup for project a-->
<repositories>
<repository>
<id>gitlab-maven</id>
<url>https://gitlab.com/api/v4/projects/112233/packages/maven</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>gitlab-maven</id>
<url>https://gitlab.com/api/v4/projects/112233/packages/maven</url>
</repository>
<snapshotRepository>
<id>gitlab-maven</id>
<url>https://gitlab.com/api/v4/projects/112233/packages/maven</url>
</snapshotRepository>
</distributionManagement>
<!--registry setup for project b-->
<repositories>
<repository>
<id>gitlab-maven</id>
<url>https://gitlab.com/api/v4/projects/445566/packages/maven</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>gitlab-maven</id>
<url>https://gitlab.com/api/v4/projects/445566/packages/maven</url>
</repository>
<snapshotRepository>
<id>gitlab-maven</id>
<url>https://gitlab.com/api/v4/projects/445566/packages/maven</url>
</snapshotRepository>
</distributionManagement>
CodePudding user response:
If project A and B sit in the same group, then you shall use the group-level Maven endpoint in project C's pom.xml
:
<repositories>
<repository>
<id>gitlab-maven</id>
<url>https://gitlab.example.com/api/v4/groups/GROUP_ID/-/packages/maven</url>
</repository>
</repositories>
Else, I guess you should be able to specify one repository for each:
<repositories>
<repository>
<id>gitlab-maven-a</id>
<url>https://gitlab.com/api/v4/projects/112233/packages/maven</url>
</repository>
<repository>
<id>gitlab-maven-b</id>
<url>https://gitlab.com/api/v4/projects/445566/packages/maven</url>
</repository>
</repositories>
/!\ Don't forget to set your Maven authentication credentials in your settings.xml
file in either case (unless your project has public visibility).
Prefer using the CI_JOB_TOKEN.