Search code examples
javaintellij-ideajarautomated-refactoring

Refactoring/moving java package between intellij projects


I was wondering whether there was a common best-practice for moving a java package between intellij projects.

All of our projects use maven. I have a jar-level package that I tried using intellij refactor->move from one project to another. At its new location, the relocated package no longer had the little light blue box at it's root node it had in its original project, and in the old project, it did not actually delete the package, but rather just moved it above the base project root package in the Project Explorer.

It is easier/better to just manually move to new location and fix everything rather than using the refactoring option from intellij? Also, what is the significance of the blue box disappearing?

Thanks for any insights!


Solution

  • Seems that you are describing module (package with little blue box), when you move it (Refactor -> Move) to another project with several modules under Maven, new module dependency is not added to parent pom.xml file. In case you add it to pom.xml like this:

    <modules>
        <module>mod1</module>
        <module>mod2</module>
        <module>newAddedModule</module>
    </modules>
    

    blue box will appear again. Please confirm if it works in your case