Examples
| Before | After |
|---|---|
| In this example, artifact version is replaced with a property, which is declared in the same pom.xml file: | |
<artifactId>submodule<artifactId>
|
<artifactId>${submodule}</artifactId>
<properties>
<submodule>submodule</submodule>
</properties>
|
| In this example, artifact version in a pom.xml file is replaced with a property, which is declared in its parent pom.xml file: | |
<parent>
<artifactId>HelloWorld</artifactId>
<version>1.0</version>
</parent>
<artifactId>submodule<artifactId>
|
Parent: <artifactId>HelloWorld</artifactId> ... <modules> <module>${submodule}</module> </modules> ... <properties> <submodule>submodule</submodule> </properties> Child: <parent> <artifactId>HelloWorld</artifactId> <version>1.0</version> </parent> <artifactId>${submodule}</artifactId> |
- Open the desired pom.xml file for editing, and place the caret somewhere
inside the value you want to replace.
Tip
You can also select a certain substring; in this case the refactoring will apply to the selection.
- Press Ctrl+Alt+VCommand 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 Introduce 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.xml file 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.
- If the pom.xml is 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.
- If the pom.xml is inherited from a parent file, IntelliJ IDEA replaces the occurrence in the child file silently. This change is not propagated to the parent pom.xml.
In each case, IntelliJ IDEA adds new property declaration to the specified pom.xml file.

