In Maven projects, while editing
one needs to define a property and replace the occurrences of some value - artifact version, for example, - with this property.
Extract Property refactoring creates a new property definition in the specified
pom.xml file, finds all the occurrences of the selected string in
the hierarchy of
pom.xml files, and replaces them with the above property in the format:
To extract a property in a pom.XML file
- Open the desired
pom.xmlfile for editing, and place the caret somewhere inside the value you want to replace.
- Press Ctrl+Alt+V, or choose on the context menu, or on the main menu. Note that selection will be automatically expanded up to the enclosing tags.
- In the Extract Property dialog box, do the following:
- In the Name field, specify the name you want to assign to the new property. IntelliJ IDEA suggests a number of suitable names. You can select one from the drop-down list, or type the desired name manually.
- In the Project drop-down list, select the project where the new property will be declared.
- The subsequent workflow depends on the specific
pom.xmlfile the refactoring has been invoked from.
- The occurrence, for which the refactoring has been invoked, will be replaced silently. If the string occurs several times, the replace usage dialog will be displayed for these occurrences. You have to specify whether you want to replace each occurrence.
pom.xmlis a parent file and the new property will be declared in it, IntelliJ IDEA replaces the values in the parent file silently, and displays the other occurrences in the Find tool window. You have to specify whether you want to replace each occurrence.
pom.xmlis inherited from a parent file, IntelliJ IDEA replaces the occurrence in the child file silently. This change is not propagated to the parent
In each case, IntelliJ IDEA adds new property declaration to the specified