Eldy
Eldy

Reputation: 1096

Multiple level inheritance for Maven project

I have a Maven project (let's call it project B) with the following content in its pom.xml:

<modelVersion>4.0.0</modelVersion>

<artifactId>ui-tests</artifactId>
<name>UI tests</name>

<parent>
    <groupId>net.mycompany</groupId>
    <artifactId>root</artifactId>
    <version>1.0-SNAPSHOT</version>
</parent>

This Maven project is destined to create a JAR used to run some tests. As you can see, it is inheriting from another Maven project (let's call it project A).

What I would like to do is create a project C which would be inheriting from project B (project A → project B → project C). This would be in order to generate a separate JARs for some tests that should be ran in isolation.

However, I am not sure how to write the corresponding pom.xml.

<modelVersion>4.0.0</modelVersion>

<artifactId>isolated</artifactId>
<name>Isolated UI tests</name>

<parent>
    <groupId><!-- ??? --></groupId>
    <artifactId>ui-tests</artifactId>
    <version>1.0-SNAPSHOT</version>
</parent>

What should I put in the groupId tag? Also, in the artifactId tag, sghould I put root (from project A) or ui-tests (from project B)?

Upvotes: 0

Views: 338

Answers (1)

J Fabian Meier
J Fabian Meier

Reputation: 35901

Your project B has the coordinates:

<groupId>net.mycompany</groupId>
<artifactId>ui-tests</artifactId>
<version>1.0-SNAPSHOT</version>

You specified the artifactId yourself and inherited the other coordinates from project A. Therefore, when you want to use project B as parent pom, you need to specify exactly these three coordinates.

Upvotes: 1

Related Questions