Maven refactorings: Introduce Property

Posted on by Irina Petrovskaya

Sometimes 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

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.

Comments below can no longer be edited.

10 Responses to Maven refactorings: Introduce Property

  1. Don Willis says:

    April 20, 2010

    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?

  2. Tomer Gabel says:

    April 21, 2010

    Just one thing: global string search&replace should be optional, same as the code refactoring dialogs.

  3. Simon says:

    April 21, 2010

    I’m assuming it will be in the next EAP, as it doesn’t work in current EAP v95.54!

  4. Irina Petrovskaya says:

    April 22, 2010

    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.

  5. Taras Tielkes says:

    May 3, 2010

    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

  6. vinodh says:

    May 11, 2010

    Is this refactorings work in all the child poms as well (poms which inherits the changed one)? Is this available in 9.0.2?

  7. Irina Petrovskaya says:

    May 21, 2010

    yes, refactoring processes the child poms.
    As for IDEA version, this feature is available in IDEA 10 only…

  8. Ryan Gardner says:

    June 16, 2010

    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 🙁

  9. Chris says:

    July 28, 2010

    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.

  10. Murat says:

    August 6, 2010

    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.

Subscribe

Subscribe for updates