The child does not find the parent help in the maven build flat structured module

I am creating a project with several modules with a flat structure, that is, the parent and child objects are in the same base directory. Parent is defined as

<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/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>company</groupId> <artifactId>parent</artifactId> <packaging>pom</packaging> <version>1-0-SNAPSHOT</version> <name>child</name> <modules> <module>../child</module> </modules> (...) 

while the child that it defines as

 <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/maven-v4_0_0.xsd"> <parent> <groupId>company</groupId> <artifactId>parent</artifactId> <version>1.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <groupId>company</groupId> <artifactId>child/artifactId> <packaging>war</packaging> <version>1.0-SNAPSHOT</version> <name>child</name> (...) 

(The names of companies and projects are confused)

What happens is that the module (the child) complains that he cannot find the parent, i.e.

 Reason: Cannot find parent: company:child for project: company:child:war:1.0-SNAPSHOT for project company:child:war:1.0-SNAPSHOT 

Is there an obvious solution to this that I missed, or is he not recommended to use the flat design of the project?

Edit: Fixed a typo.

+7
maven-2
source share
3 answers

Use the <relativePath> element as described in Example 5 Introduction to POM :

 <project> <parent> <groupId>company</groupId> <artifactId>parent</artifactId> <version>1.0-SNAPSHOT</version> <relativePath>.../parent/pom.xml</relativePath> </parent> <modelVersion>4.0.0</modelVersion> <groupId>company</groupId> <artifactId>child</artifactId> <packaging>war</packaging> <version>1.0-SNAPSHOT</version> <name>child</name> ... </project> 
+13
source share

The parent version of POM is 1-0-SNAPSHOT, not 1.0-SNAPSHOT.

+2
source share

The child pom does not refer to the parent pom, it refers to another artifact named 'build'. It should read:

 <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/maven-v4_0_0.xsd"> <parent> <groupId>company</groupId> <artifactId>parent</artifactId> <version>1.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <groupId>company</groupId> <artifactId>child</artifactId> <packaging>war</packaging> <version>1.0-SNAPSHOT</version> <name>child</name> (...) 
0
source share

All Articles