Reputation: 1377
I fail to find a straightforward way to duplicate a package in Intellij under a new name.
I have a package some.package.v2
and I want to duplicate the package to some.package.v3
with all internal references to v2
translated to v3
.
IntelliJ does a good job of translating the references. But I cannot go straight from some.package.v2
to some.package.v3
. When I select the package v2
in the Project view and I do ⌘C ⌘V, it asks where to copy the selected item. If I select .../some/package/v3
, it creates the copy as some.package.v3.v2
because it copies the selected v2
into some.package.v3
. So I have to rename the package some.package.v3.v2
to some.package.v3
.
This two-step process is a bit clumsy and I wonder whether there is a direct way.
Upvotes: 1
Views: 1061
Reputation: 1377
I found a way, so I will just provide it as an answer, if you have a better one please post.
To duplicate and rename the package, you should not select the package itself, i.e. v2
, but select all the classes and subpackages the package contains. Then press ⌘C,⌘V or F5 as before. Intellij will ask you the destination directory which will be the destination package. Just make sure to copy everything in one go, or you might end up with some references left on the old packages.
Upvotes: 4