Karussell
Karussell

Reputation: 17375

Refactor across two Java projects in IntelliJ

Suppose there is Maven Project A and Maven Project B. Project B has defined a dependency on A in its pom.xml:

<dependency>
    <groupId>com.company</groupId>
    <artifactId>project-a</artifactId>
    <version>0.1-SNAPSHOT</version>
</dependency>

Now open both projects in IntelliJ idea (two separate windows).

What is the best way to refactor a method in project A?

Currently I do the refactoring in A and call "mvn install" for it, then do search&replace in project B and this works okayish. But is there something faster? In NetBeans I just open both projects and the refactoring will be applied to all open projects.

Upvotes: 2

Views: 378

Answers (1)

CrazyCoder
CrazyCoder

Reputation: 402025

The best way is it import the parent Maven pom.xml which defines the dependencies between the modules. This way you will have both modules open in IntelliJ IDEA at the same time and the refactorings will work across the project.

Upvotes: 1

Related Questions