Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ like 'Extract Property' to extract maven artifact versions to properties in eclipse

IntelliJ provides Extract Property refactoring which can be used to extract maven artifact versions to properties in pom.xml.

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: ${}

https://www.jetbrains.com/help/idea/2016.2/extract-property.html

Does eclipse have something similar?

like image 476
Chacko Mathew Avatar asked Sep 23 '16 07:09

Chacko Mathew


1 Answers

It seems that Eclipse didn't have such feature.
So I extracted the version by myself with a Java Helper class:
https://github.com/brabenetz/secured-properties/blob/master/src/test/java/net/brabenetz/lib/securedproperties/tools/ExtractPomVersions.java

Feel free to copy, past and modify the code.

Background: I personally do not like the versions as property, because for defining the right versions there are dependency-management and plugin-management sections in Maven.
But it seems that the version-maven-plugin only works at best if it can update versions in properties:
http://www.mojohaus.org/versions-maven-plugin/update-properties-mojo.html

like image 146
Harald Brabenetz Avatar answered Oct 21 '22 08:10

Harald Brabenetz