Reputation: 95
I have one java-spring application with 2 maven dependencies in different repositories, but in the same group. I used gitlab-ci to deploy the jar in 2 project package registries, but I cannot retrieve them (I can with only one dependency, setting its project repo, in the spring application pom)
.
For the 2 dependencies, I wrote the same ci-settings.xm
l:
<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
<servers>
<server>
<id>gitlab-maven</id>
<configuration>
<httpHeaders>
<property>
<name>Job-Token</name>
<value>${env.CI_JOB_TOKEN}</value>
</property>
</httpHeaders>
</configuration>
</server>
</servers>
with the same gitlab-ci.yml
:
deploy:
image: maven:3.6-jdk-11
script:
- 'mvn deploy -s ci_settings.xml'
only:
- master
In the the pom.xml for the 1st dependency (sp1) I have:
<groupId>ch.myCompany.dep</groupId>
<artifactId>sp_1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<repositories>
<repository>
<id>gitlab-maven</id>
<url>https://gitlab.com/api/v4/groups/GROUP_ID/-/packages/maven</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>gitlab-maven</id>
<url>https://gitlab.com/api/v4/projects/SP1_REPO_ID/packages/maven</url>
</repository>
<snapshotRepository>
<id>gitlab-maven</id>
<url>https://gitlab.com/api/v4/projects/SP1_REPO_ID/packages/maven</url>
</snapshotRepository>
</distributionManagement>
And in the the pom.xml for the 2st dependency (sp2) I have:
<groupId>ch.myCompany.dep</groupId>
<artifactId>sp_2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<repositories>
<repository>
<id>gitlab-maven</id>
<url>https://gitlab.com/api/v4/groups/GROUP_ID/-/packages/maven</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>gitlab-maven</id>
<url>https://gitlab.com/api/v4/projects/SP2_REPO_ID/packages/maven</url>
</repository>
<snapshotRepository>
<id>gitlab-maven</id>
<url>https://gitlab.com/api/v4/projects/SP2_REPO_ID/packages/maven</url>
</snapshotRepository>
</distributionManagement>
In the spring application, I set the 2 artifacts as a dependency but I'm not able to retrieve them. This is part of the pom.xml:
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>ch.myCompany.dep</groupId>
<artifactId>sp_service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>sp_service</name>
<description>Service Layer for Spring Boot</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>ch.myCompany.dep</groupId>
<artifactId>sp_1</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>ch.myCompany.dep</groupId>
<artifactId>sp_2</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>gitlab-maven</id>
<url>https://gitlab.com/api/v4/projects/GROUP_ID/packages/maven</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Upvotes: 1
Views: 4479
Reputation: 6659
In the dependencies' pom.xml distributionManagement
section, you are using the correct url:
<url>https://gitlab.com/api/v4/groups/GROUP_ID/-/packages/maven</url>
However, in your spring application pom.xml repositories
section, the url is incorrect:
<url>https://gitlab.com/api/v4/projects/GROUP_ID/packages/maven</url>
You're missing /-/
between GROUP_ID
and packages
.
Upvotes: 1