How to add a project to build path in IntelliJ Idea

52,813

If you want to depend on another module without it being jar, you need to import that as a module into the same project. It doesn't look like DataProvider is imported since it doesn't appear in the module list.

Share:
52,813
arabian_albert
Author by

arabian_albert

Updated on July 27, 2022

Comments

  • arabian_albert
    arabian_albert almost 2 years

    I've recently converted over to IntelliJ Idea 13, previously in eclipse I was able to add a project to another project's build path. I'm not able to accomplish this in IntelliJ.

    How can I add project1 to project2's build path so that I can use it as a dependency. I don't want to make that project a JAR because I'm still developing it.

    Following this similar previous question: Intellij - Add project dependency like in Eclipse

    I was not able to successfully achieve my goal.

    In File > Project Structure > Modules

    I see the project I'd like to add to my build path (DataProvider) but it's highlighted red, and the bottom warning text states "Invalid item 'DataProvider' in dependencies list'

    enter image description here

    Any help or assistance would be much appreciated.

    Edit:

    Solution (Thanks @leeor)

    Import project as a module

    File > Import Module > (Select Project to be imported)

    This will add that project to the project view pane on the left side of the screen.

    Then go to your current project

    File > Project Structure > Module > (Select your current project)

    Under Dependencies

    Check mark your project (now a module) you want to import and then click apply and then OK.

    Done!

    Using IntelliJ Idea 13.1.6 on Mac

  • vikramvi
    vikramvi almost 7 years
    @leeor does this work for you with current version of IDEA ? I'm struggling to get it working from last 1 day but no success yet.