Maven refactorings: Introduce Property
April 20th, 2010 by Irina PetrovskayaSometimes while editing pom.xml one needs to define a property and replace the occurrences of some value - artifact version, for example, - with this property. Now you can use the new IDEA Introduce Property refactoring for these purposes.
To invoke refactoring, select the string that should be replaced and press Ctrl-Alt-V (alternatively, you can use Maven/IntroduceProperty action in the editor context menu). In dialog enter the property name and select the pom to create the property in:

Introduce Property dialog
Refactoring finds all the occurrences of the selected string in the poms hierarchy and replaces them.
More refactorings will be added soon.
Any comments are appreciated.
Tags: ideaX, Maven, Refactoring

April 20th, 2010 at 3:58 pm
Great news. I’m pretty sure I’ve assumed this would work in the past and been disappointed. Looking forward to this and future maven refactorings. When you say “now”, is that 9.0.2?
April 21st, 2010 at 11:13 am
Just one thing: global string search&replace should be optional, same as the code refactoring dialogs.
April 21st, 2010 at 12:52 pm
I’m assuming it will be in the next EAP, as it doesn’t work in current EAP v95.54!
April 22nd, 2010 at 3:32 am
This feature is not available in 9.0.2, it is in IDEA 10 branch only.
Tomer: when search&replace is performed, you can observe the occurrences and process or skip them.
Also, if you select the current pom as a project, refactoring looks for occurrences in the current file only.
May 3rd, 2010 at 9:00 am
Here are two simple requests for improvement of this feature:
When extracting dependency versions into properties, be more smart about suggesting property names:
http://youtrack.jetbrains.net/issue/IDEA-54412
Automatically pick a smart selection, if the user did not make one:
http://youtrack.jetbrains.net/issue/IDEA-54411
May 11th, 2010 at 4:09 am
Is this refactorings work in all the child poms as well (poms which inherits the changed one)? Is this available in 9.0.2?
May 21st, 2010 at 5:48 am
yes, refactoring processes the child poms.
As for IDEA version, this feature is available in IDEA 10 only…
June 16th, 2010 at 4:26 pm
Is there an EAP for 10 out yet?
If not, you guys are just being teases by showing off features like this that we can’t even use
I saw this here a while ago, and remembered it since I thought “cool, I’ll use that a lot.” I just spent three or four minutes trying to get this to work in my latest 9 EAP and I was scratching my head…
I don’t see a version 10 EAP yet though
July 28th, 2010 at 9:25 pm
I really appreciate what the IntelliJ team is doing - by letting us know of what is to come.
This feature is indeed a nice addition. But, please always keep an eye on performance issues.
I’d rather speed along coding without this feature than having to wait for 3 to 5 minutes at a time when I refactor the poms.
August 6th, 2010 at 9:30 pm
This is a great start. May I suggest another maven refactoring feature?
Something similar to “Pull members up”, where you can pull up anything (starting with
dependencies) from a child pom to a parent pom would be very helpful.