IntelliJ: Working on multiple projects

前端 未结 19 1944
抹茶落季
抹茶落季 2020-11-27 09:18

We build in maven multiple projects (let\'s name them A,B,C). Project A uses .jar of project B which uses .jar of project C.

I am modifying codes of all A/B/C projec

相关标签:
19条回答
  • 2020-11-27 09:24

    Step 1: Open "Maven Projects"

    Step 2: Select the project you want to import:

    0 讨论(0)
  • 2020-11-27 09:26

    Prequisite

    Having all the related projects in the same root directory.

    Steps

    1) First you create a new Empty project


    2) Then you select the root directory of all you projects.

    This will create a empty project, with a .idea directory that will simply remember the module organisation we are about to do in the next step


    3) Then, in the next window, you import the different projects as modules


    4) In the next window, to import each project, simply double click on the build.gradle, or pom.xml

    The project will be imported as a new module.


    5) Done, you now have all your projects as modules, opened on the same IntelliJ project

    0 讨论(0)
  • 2020-11-27 09:29

    I think this has improved with recent versions of IntelliJ. In my current version (12.0.2), you can add any number of separate Maven projects to the same "workspace".

    The simplest way I've found to do this is to click the little + icon in the "Maven Projects" window (View > Tool Windows > Maven Projects) and then select the additional pom file you want to import.

    0 讨论(0)
  • 2020-11-27 09:30

    you can use import module option which will open it just like eclipse in the same navigator.

    0 讨论(0)
  • 2020-11-27 09:31

    To expand @Neo answer: after choosing your directory. select import module from external model and choose your model (maven in this case).

    Then check keep project files option from next dialog. It will keep all files in original directory.

    Your final project structure would be something like this.

    Now you can add your module as dependency to other module's pom.xml and if you change the source code of your dependencies, Intellij takes care of updating your project (there is no need to run mvn build manually for dependencies)

    0 讨论(0)
  • 2020-11-27 09:32

    In IntelliJ 14.1.2, I did it like following:

    Select File->Project Structure->Modules.

    Select + and Import Module and select the directory of your project(or directory where pom exists) and click OK.

    Follow through the next flow of screens and after you click Finish, you should see the project alongside your existing one.

    enter image description here

    0 讨论(0)
提交回复
热议问题