Reputation: 195
I have two projects, project A & project B.
Project B is a multi-module project where child modules 1-3 are JARs and the parent module is of packaging type pom
.
module-parent
|- module-child-1
|- module-child-2
|- module-child-3
The parent pom looks like such
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>my.group.id</groupId>
<artifactId>module-parent</artifactId>
<packaging>pom</packaging>
<version>2.4.0-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.0</version>
<relativePath />
</parent>
<modules>
<module>module-child-1</module>
<module>module-child-2</module>
<module>module-child-3</module>
</modules>
<properties>
<java.version>1.11</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
In all of the other child pom.xml files, we include the <parent>
as module-parent & for the maven-deploy-plugin <skip>
is set to false instead.
<parent>
<groupId>my.group.id</groupId>
<artifactId>module-parent</artifactId>
<version>2.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
Furthermore, module-child-1 is a <dependency>
that is defined & used in both module-child-2 & module-child-3
Project A is a completely separate normal project (it's NOT a multi-module project) that is simply able to use any of the 3 child modules as a dependency in its project.
<dependency>
<groupId>my.group.id</groupId>
<artifactId>module-child-2</artifactId> (or module-child-1/module-child-3)
<version>1.0.0-SNAPSHOT</version>
</dependency>
My issue is that when running the maven command dependency:tree
on Project A, it throws the following error as it attempts to search for module-parent in my <servers>
defined in my settings.xml file even though module-parent is of type pom
.
[ERROR] Failed to execute goal on Project-A: Could not resolve dependencies for project my.group.id:Project-A:jar:0.0.1-SNAPSHOT: Failed to collect dependencies at my.group.id:module-child-2:jar:1.0.0-SNAPSHOT: Failed to read artifact descriptor for my.group.id:module-child-2:jar:1.0.0-SNAPSHOT: Could not transfer artifact my.group.id:module-parent:pom:2.4.0-SNAPSHOT from/to MyServer-SNAPSHOT (https://example): Access Denied to: ......., ReasonPhrase:Forbidden.
Do pom artifacts need to be deployed remotely as well? Only the 3 child modules are already deployed. Do I seriously need to deploy a separate artifact for a single pom file?
The code from the child modules is brought in perfectly fine but, it just can't read from the <parent>
of any of the child modules is my guess, so instead it might rely on the <parent>
of project A instead.
Upvotes: 2
Views: 1954
Reputation: 784
Even if the common way is to deploy parent.
You should be able to avoid this by :
For a more detailed answer, see : https://stackoverflow.com/a/72830959/5088764
Upvotes: 1
Reputation: 35843
You can use the Flatten Maven Plugin to remove the parent from the finally deployed POM, so that it can be used without the parent.
The usual approach, though, is the one described by Luciano.
Upvotes: 2
Reputation: 444
Yes, you need to deploy parent POMs too. Without a parent POM, they cannot be read by Maven. You should deploy all modules including the parents to same place.
Upvotes: 3