I recently updated my Spring Boot apps development setup for a multi-module maven project
- MainProject
- AMQP
- APIGateway
- EurekaServer
- Customer
- Fraud
Then I have this structure in GitLab:
- Group - Main Folder
- Infra - Subgroup
- EurekaServer - project repository
- APIGateway - project repository
- Services - Subgroup
- AMQP - project repository
- Shared - Subgroup
- Customer - project repository
- Fraud - project repository
- Infra - Subgroup
Now I'd like to build the EurekaServer in CI but it needs to know where to locate the parent POM (which is only stored in my local machine). How can I configure this to GitLab so that succeeding build to other modules can lookup into the registry for the parent POM and other dependency modules? Should I create a repository only for the parent POM and pull that in the CI job?
I found this question during my research but this only works in local machine. Maven Modules + Building a Single Specific Module
UPDATE: I have this existing configuration for both the parent and module POMs.
<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/PROJECT-ID/packages/maven</url>
</repository>
<snapshotRepository>
<id>gitlab-maven</id>
<url>https://gitlab.com/api/v4/projects/PROJECT-ID/packages/maven</url>
</snapshotRepository>
</distributionManagement>
First, from the project root folder I executed this command to push the parent artifact into the registry
mvn deploy -N -s settings.xml
and succeeded.
Next, build docker image for the module (AMQP). Here's the CI config
stages:
- deploy
push-to-registry:
stage: deploy
image: maven:3.8.1-jdk-11-slim
script:
- mvn deploy -s settings.xml
tags:
- configuration
and this is the error log
[FATAL] Non-resolvable parent POM com.xyz:services:1.0-SNAPSHOT for com.xyz.module:amqp:[unknown-version]: Failure to find com.xyz:services:pom:1.0-20220114.024427-3 in https://gitlab.com/api/v4/groups/GROUP_ID/-/packages/maven was cached in the local repository, resolution will not be reattempted until the update interval of gitlab-maven has elapsed or updates are forced and 'parent.relativePath' points at wrong local POM @ line 5, column 11