I\'m trying to use Maven2 but my child projects cannot find the parent project.
Directory structure is as follows:
--parent
--pom.xml
--child
--p
You can't use a property for the parent version - it must match. At the moment this is required for the build to be reproducible at a later date. A number of people are tracking this on issue https://issues.apache.org/jira/browse/MNG-624
What I found was that you needed to install the parent pom first, then the subsequent child poms can read them from the repository.
use: mvn -N install
This will install the parent pom without running the other child poms.
You may have the packaging type and/or version id not matching. I got the same error as you but played around with the packaging type and got it to work. Try the following.
The following is fragment of the parent pom.xml. The packaging type is "pom". I don't have any code for the parent app, only a common pom.xml for sharing:
...
<groupId>com.mycompany.app</groupId>
<artifactId>parent</artifactId>
<version>${app.version}</version>
<packaging>pom</packaging>
Child's pom.xml. It is a webapp so packaging type is "war":
<parent>
<groupId>com.mycompany.app</groupId>
<artifactId>parent</artifactId>
<version>${app.version}</version>
<relativePath>../parent/pom.xml</relativePath>
<packaging>war</packaging>
</parent>
To my knowledge, variable expansion doesn't work in the parent element (see MNG-624 and comments for background around this), you need to set the version explicitly:
<parent>
<groupId>com.mycompany.app</groupId>
<artifactId>myapp</artifactId>
<version>1-SNAPSHOT</version><!-- or whatever version you use -->
<relativePath>../parent/pom.xml</relativePath>
</parent>
By the way, if you want to use the same version for all your modules, you should simply inherit it in your child project i.e. not override it (there is no real need for an ${app.version}
IMO), not the other way around.
It should be:
<parent>
<groupId>com.mycompany.app</groupId>
<artifactId>myapp</artifactId>
<version>${app.version}</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
The problem is likely that you used .../
instead of ../
.