168

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
messivanio
  • 2,263
  • 18
  • 24
simpatico
  • 10,709
  • 20
  • 81
  • 126

6 Answers6

314

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.

Ortomala Lokni
  • 56,620
  • 24
  • 188
  • 240
Raghuram
  • 51,854
  • 11
  • 110
  • 122
  • But actually it's only a warning. It only loads the (implicit) relative pom if groupId and artifactId match, too. – Tarion Jul 16 '13 at 14:02
  • 17
    Believe it or not, warnings do scare some people. My boss just asked me to investigate why we are getting this warning and this post made my day. – Pierre Oct 10 '13 at 14:30
  • 26
    Warnings don't come falling out of the skies. There's a reason for it. Adding an empty without knowing why isn't a solution.... – Lawrence Apr 20 '14 at 19:16
  • 1
    I am trying to build apache-spark. This solution is not working in my case. – WestCoastProjects Oct 31 '15 at 20:20
  • THANK you! This has cut the output for one aggregator project for 300+ lines. – Rade_303 Nov 06 '15 at 17:15
  • 38
    If you don't fix warnings you train people to ignore warnings. – Paul Jackson Dec 14 '15 at 21:06
  • @Lawrence this answer explains HOW, the answer below by mkleint explains WHY. – Amedee Van Gasse Mar 07 '16 at 10:33
  • 7
    IMHO `` looks better – Ilya Serbis Jul 04 '18 at 13:32
  • As the referenced documentation says, `` is only when you are using a parent POM locally. Does Maven give this warning even when it can locate the POM from a public repository? Here `org.apache:apache:8` is a public POM available from Maven Central, so I'm having trouble understanding why there is a warning in the first place, unless for some reason Maven Central was down or there was no Internet connection—in which case I would expect some different error message. – Garret Wilson Mar 20 '19 at 00:30
21

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.

mkleint
  • 2,281
  • 1
  • 14
  • 17
  • I suspect this default behavior is causing some other problems. What do you mean by 'enter the element'? – simpatico May 14 '11 at 20:09
  • I meant you should write the correct value for element based on where your parent pom is relative to the current pom. – mkleint Jun 16 '11 at 10:18
  • 2
    The path to `org.apache:apache` is probably not locally on the computer at all (except in the local .m2 repository). In such cases, an *empty* relativePath should be specified. – Simon Forsberg Oct 24 '17 at 20:54
2

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.

leo
  • 3,528
  • 3
  • 20
  • 19
  • 3
    Correct, but your answer doesn't explain the solution. The path to `org.apache:apache` is probably not locally on the computer at all (except in the local .m2 repository). In such cases, an *empty* relativePath should be specified. – Simon Forsberg Oct 24 '17 at 20:53
  • This was the cause in my case. This warning started appearing one day for no apparent reason (same maven version, same project code). Finally noticed a 'pom.xml' file right outside the project's folder, which was being picked up by maven. – sudeep Nov 28 '18 at 20:13
2

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"

granadaCoder
  • 26,328
  • 10
  • 113
  • 146
2

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.

JBStonehenge
  • 192
  • 3
  • 15
1

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>
Raja Anbazhagan
  • 4,092
  • 1
  • 44
  • 64
  • 2
    The path to `org.apache:apache` is probably not locally on the computer at all (except in the local .m2 repository). In such cases, an *empty* relativePath should be specified. – Simon Forsberg Oct 24 '17 at 20:53