'parent.relativePath' points at my com.mycompany:MyProject instead of org.apache:apache - Why?

Maven

Maven Problem Overview


What is true is that Solr project directory is inside MyProject parent directory (but there's no module or any maven relationship between the 2, just FS convenience). Do I have to place it out?

$ mvn -DskipTests clean install
[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for org.apache.lucene:lucene-solr-grandparent:pom:3.1-SNAPSHOT
[WARNING] 'parent.relativePath' points at com.mycompany:MyProject instead of org.apache:apache, please verify your project structure @ line 23, column 11
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 

from pom.xml:

<parent>
    <groupId>org.apache</groupId>
    <artifactId>apache</artifactId>
    <version>8</version>
  </parent>

$ pwd
/Users/simpatico/ws/MyProjectBaseDir/solr

Maven Solutions


Solution 1 - Maven

Add an empty <relativePath> to <parent> so that it resolves the parent pom from the repositories.

  <parent>
    <groupId>org.apache</groupId>
    <artifactId>apache</artifactId>
    <version>8</version>
    <relativePath></relativePath>
  </parent>

Here is the relevant doc.

> This feature is only for enhancing the development in a local checkout of that project. Set the value to an empty string in case you want to disable the feature and always resolve the parent POM from the repositories.
> Default value is: ../pom.xml.

Solution 2 - Maven

either ignore the warning, move the sources out of the unrelated parent or enter the correct value of to the element. The problem is caused by the default value for relativePath which is ../pom.xml and that default value gets injected in your effective pom, triggering the warning.

Solution 3 - Maven

That message might be caused by a pom.xml in the parent directory relative to your current project. The pom in the parent directory does not match the project.parent config of the current pom.

Solution 4 - Maven

I have a fringe case. A fat finger case on my part.

My pom parent had this:

<?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>com.mygroup </groupId>
	<artifactId>pom-parent</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>pom</packaging>
	<name>pom-parent</name>

and my (child) pom

<parent>
	<groupId>com.mygroup</groupId>
	<artifactId>pom-parent</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<relativePath>../pom-parent/pom.xml</relativePath>
</parent>  

My group id in my parent had a fat finger space at the end of the name. "com.mygroup " instead of the correct "com.mygroup".

Because of this fat finger mistake........the "groupId" names did not match....and I got the error.

Aka, check for fat finger mistakes before you go to too many extremes to resolve.

error I got for internet-searching

> "Project build error: 'parent.relativePath' of POM" "points at" > "please verify your project structure"

Solution 5 - Maven

I think you have missed out the <relativePath> tag in the question. I'm saying that because, without it This error will not arise. That being said,

The line you will have to concentrate is the below warning statement.

> 'parent.relativePath' points at com.mycompany:MyProject instead of > org.apache:apache

It clearly says that the relative path of tag on your module points to a pom file which has different artifactId compared to what is specified

This is because there is a mismatch between the artifactId of your parent/pom.xml and the artifactId you have mentioned in the <parent> tag of module/pom.xml. To avoid the warning change the <parent> in your module/pom.xml as shown below.

  <parent>
    <groupId>com.mycompany</groupId>
    <artifactId>MyProject</artifactId>
    <version>8</version>
    <relativePath>path-to-your-parent-pom.xml</relativePath>
  </parent>

Solution 6 - Maven

I had the same warning quite a long time. The cause was simply a pom.xml in the parent folder of the project where the warning occured.

As soon as I had removed the ../pom.xml the warning was gone.

This was kind of indicated in some of the above comments/answers. Normally you don't set the <relativePath> field at all when it is remote.

The pom.xml was there by mistake; obviously the result of an errornous action within another project or just an errornous copy destination by myself.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionsimpaticoView Question on Stackoverflow
Solution 1 - MavenRaghuramView Answer on Stackoverflow
Solution 2 - MavenmkleintView Answer on Stackoverflow
Solution 3 - MavenleoView Answer on Stackoverflow
Solution 4 - MavengranadaCoderView Answer on Stackoverflow
Solution 5 - MavenRaja AnbazhaganView Answer on Stackoverflow
Solution 6 - MavenJBStonehengeView Answer on Stackoverflow