You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a pom.xml, remove a duplicate jacoco-maven-plugin build plugin definition with org.openrewrite.xml.RemoveXmlTag.
Describe the solution you'd like
Use an XPath expression like /project/build/plugins/plugin[artifactId='jacoco-maven-plugin'][2] or /project/build/plugins/plugin[artifactId='jacoco-maven-plugin'][last()].
/project/build/plugins/plugin[artifactId='jacoco-maven-plugin'] works and matches both definitions. I want to match just one of them.
Have you considered any alternatives or workarounds?
Thanks for the suggestion @alvarosanchez ! We had indeed only implemented a subset of functionality for our XPathMatcher, mostly since we're quite a bit performance sensitive there. While these matcher features would be nice, I do wonder if we'll use them often enough in isolation to be worth the added complexity.
For the specific case it's hard to say whether you always can or should remove the second case. I'd expect a visitor that matches both plugins, evaluates their configuration, potentially merges them, and only then removes one of the other. That means a more specific XPath match might not help a lot just yet. What are your thoughts there?
What problem are you trying to solve?
In a pom.xml, remove a duplicate
jacoco-maven-plugin
build plugin definition withorg.openrewrite.xml.RemoveXmlTag
.Describe the solution you'd like
Use an XPath expression like
/project/build/plugins/plugin[artifactId='jacoco-maven-plugin'][2]
or/project/build/plugins/plugin[artifactId='jacoco-maven-plugin'][last()]
./project/build/plugins/plugin[artifactId='jacoco-maven-plugin']
works and matches both definitions. I want to match just one of them.Have you considered any alternatives or workarounds?
There aren't, to the best of my knowledge
Are you interested in contributing this feature to OpenRewrite?
XPathMatcher
has some pretty complicated logic, but if pointed to the appropriate place, I can try.The text was updated successfully, but these errors were encountered: