Best way to import multimodule Maven project?

I have tried with various settings to import an existing multimodule maven project where the root pom is different from the parent pom.  The root pom does nothing but declare the <modules> in it, and one of the modules is the true parent pom (in the directory parent-pom in the root directory).  Here's my root pom:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<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>org.example</groupId>

<artifactId>app-root</artifactId>

<packaging>pom</packaging>

<version>0.1.0.BUILD-SNAPSHOT</version>

<name>Application Multimodule Root POM</name>


<modules>

<module>parent-pom</module>

<module>test-support</module>

<module>support</module>

<module>domain</module>

<module>dto</module>

<module>service</module>

<module>rest</module>

<module>web</module>

</modules>


</project>



With this Maven setup, each child module (except parent-pom, of course) declares its parent-pom like this:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<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>

 <parent>

  <groupId>org.example</groupId>

  <artifactId>parent-pom</artifactId>

  <version>0.1.0.BUILD-SNAPSHOT</version>

  <relativePath>../parent-pom/pom.xml</relativePath>

 </parent>

 <artifactId>app-domain</artifactId>

 <packaging>jar</packaging>

<name>Application Domain Model</name>

...



It seems that each time I try to import the project with different settings, I end up with two copies of the .iml files (with " (1).iml" and " (2).iml" suffixes) in each of the project subdirs.

I'm wasting time on this.

Can someone please enlighten me as to what the best practice is for importing a multimodule Maven project where the parent pom is not the root pom?  I just want to end up with a single IntelliJ project that has one project for each Maven module defined in the root pom, including the parent pom module (located at ./parent-pom/pom.xml, where "." is the multimodule root).

Thanks,
Matthew
1 comment
Comment actions Permalink

hi! did you find a way for this?

0

Please sign in to leave a comment.