Maven refactorings: Introduce Property

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.

This entry was posted in New Features and tagged , , . Bookmark the permalink.

10 Responses to Maven refactorings: Introduce Property

  1. Don Willis says:

    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:

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

  3. Simon says:

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

  4. Irina Petrovskaya says:

    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:

    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:

    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:

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

  8. Ryan Gardner says:

    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 :P

    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:

    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:

    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.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>