How to combine 3 maven projects into single window

Answered

Hi,

I've recently shifted to IDEA and finding it hard to get simple things from Eclipse get working here.

I would like to see 3 maven projects in single window how to achieve the same ?

 

Thanks & Regards,

Vikram

 

0
8 comments

Check this sample project: https://github.com/jamesward/maven-multi-module-example.

Notice that it has the root pom.xml file listing sub-projects (modules):

<modules>
<module>core</module>
<module>app</module>
</modules>

Every module has a separate pom.xml file in the module subdirectory.

App module depends on the core module, this dependency is specified in the app's module pom.xml file:

<dependency>
<groupId>com.jamesward</groupId>
<artifactId>core</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>

IntelliJ IDEA correctly adds this dependency when you open/import the root pom.xml file:

Project view lists all the imported modules:

 

The same way you can specify as many modules as you need.

1

Thanks a ton Serge, this answer helped to get my project up and running.

https://stackoverflow.com/questions/44954034/intellij-idea-how-to-give-dependency-between-projects

Regards,

Vikram

 

 

0

Are you able to have multiple modules that depend on each other to catch changes on the fly withou using mvn clean install.

What I mean is project A and B imported and maven modules into intellij 2023.3 where

── A
    ├── pom.xml
           ├── version 1.0.0.0-SNAPSHOT

── B
    ├── pom.xml
           ├── version 2.0.0.0-SNAPSHOT

            ├── dependency to A:1.0.0.0-SNAPSHOT

If you make a change on a java class @A does project B catch that change. I allways have to execute mvn clean install to get it from me local m2 repository.

my expectation is:

  1. if the gav of my dependency(ies) matchs one that I have imported on my project use that version (resolve workspace artifacts)
  2. if the gav of my dependency(ies) does not match what I have imported in my project use my local maven repository
  3. if the gav of my dependency(ies) does not match what I have in my local maven repository tries to fetch it from the maven remote repository
0

> Are you able to have multiple modules that depend on each other to catch changes on the fly withou using mvn clean install.

Sure, if you use module dependencies as outlined in my comment above, the IDE will resolve the dependencies via sources and the code will be updated on the fly.

0

I'm not able to make it work not sure why?!!!

I have a more complex scenario

── A
    ├── pom.xml
           ├── version 1.0.0.0-SNAPSHOT

            ├── module A1

                    ├── version 1.0.0.0-SNAPSHOT

             |── module A2

                      ├── version 1.0.0.0-SNAPSHOT

── B
    ├── pom.xml
           ├── version 2.0.0.0-SNAPSHOT

           ├── module B1

                    ├── dependency to A2:1.0.0.0-SNAPSHOT

I did what you suggested, a parent pom.xml file

── multi

       ├── pom.xml

               ├── version 1.0.0.0-SNAPSHOT

                |── module A

                |── module B

It was properly loaded since the maven view was updated with a multi maven project parent of A and B.

I tested this by changing an an xml file on A2 that I reference via classpath on B1 when I change the xml file B1 loads the older version I need to run mvn clean install so the updated xml can be loaded :-( not sure what else to do and this looks like a normal utilization of the IDE :-(

0

If it doesn't work for you, please report an issue at https://youtrack.jetbrains.com/newIssue?project=IDEA and attach a sample project with the parent pom with the exact steps to reproduce it.

0

I will do thank you for your help

0

Please sign in to leave a comment.