0

How can I make changes to a library that exists as separate intellij project and is included as maven lib?

Project structure:

/IdeaProjects/mycommons/
/IdeaProjects/mycore/

mycore pom.xml:

<dependency>
    <groupId>my.domain</groupId>
    <artifactId>my-commons</artifactId>
    <version>1.0.0</version>
</dependency>

Now, if I have the /mycore project open, and go into a class from mycommons, there are two issues: 1. I only the the decompiled .class file. I would expect to see the real java file. 2. I cannot edit this file. If I want to change anything, I have to open the mycommons project in a different idea window. 3. If I run the mycore after changes in mycommons, those changes are not automatically picked up. I first have to run mvn install on the mycommons, then they are found in the core project.

Coming from eclipse, none of these points have been an issue. Eclipse just recognized that included libraries are themselves eclipse project. So I could edit them all in one window, and run the changes without having to mvn install the libraries on each change explicit.

How can I achieve the same behaviour in Intellij IDEA?

membersound
  • 81,582
  • 193
  • 585
  • 1,120

2 Answers2

0

Have a single IntelliJ project with both modules (mycore and commons). Same as Eclipse would have a single workspace with them.

Meo
  • 12,020
  • 7
  • 45
  • 52
  • I want to share the commons among all future company projects. So I cannot group the commons lib. – membersound Jun 28 '17 at 12:31
  • @membersound I meant IntelliJ project and modules, that is distinct from Maven... – Meo Jun 28 '17 at 12:34
  • Could you be more specific on what you mean? Currently I have two normal intellij projects, which means: different workspaces. If I would now copy the commons lib from one workspace into the other, it would only be available inside this core workspace. But ideally I'd like it being available in *any* workspace/project. – membersound Jun 28 '17 at 12:40
  • You can use the same module in multiple IntelliJ IDEA projects, import the module from the same location via the existing .iml file in another projects, simple as that. – CrazyCoder Jun 28 '17 at 12:44
0

Found the solution here: IntelliJ: Working on multiple projects

In "Maven Projects" tab, just click the green "+" button and add any existing commons projects pom.xml.

They then appear inside the project workspace in intellij.

membersound
  • 81,582
  • 193
  • 585
  • 1,120