openrewrite / openrewrite/rewrite
Interaction between ChangeTagValue & RemoveXmlTag leads to not executed recipe
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 3.7k
- Forks
- 570
- Avg merge
- 13h 12m
- Merged PRs (30d)
- 261
Description
What version of OpenRewrite are you using?
I am using
- OpenRewrite master branch
How are you running OpenRewrite?
I am using the Maven plugin, and my project is a multi module project.
- org.openrewrite.xml.ChangeTagValue:
elementName: //groupId
oldValue: "^com\\.example\\.ws.$"
newValue: "\\$\\{some.variable}"
regex: true
- org.openrewrite.xml.RemoveXmlTag:
xPath: /project/dependencies/dependency[groupId='com.example.ws4']/version
- org.openrewrite.xml.RemoveXmlTag:
xPath: /project/dependencies/dependency[groupId='com.example.ws5']/version
- org.openrewrite.xml.RemoveXmlTag:
xPath: /project/dependencies/dependency[groupId='${some.variable}']/version
- org.openrewrite.xml.RemoveXmlTag:
xPath: /project/properties/*[local-name()='some.variable']
What did you expect to see?
I have this in my war-pom file:
<dependency>
<groupId>com.example.ws4</groupId>
<artifactId>eb-proxima-connector</artifactId>
<version>80.0.0</version>
</dependency>
And expected to see:
<dependency>
<groupId>${some.variable}</groupId>
<artifactId>eb-proxima-connector</artifactId>
</dependency>
What did you see instead?
<dependency>
<groupId>${some.variable}</groupId>
<artifactId>eb-proxima-connector</artifactId>
<version>80.0.0</version>
</dependency>
What is the full stack trace of any errors you encountered?
No stacktrace, just incorrect output
The thing is that both rules ChangeTagValue & RemoveXmlTag work fine by themselves. So I I keep the latter, it'll remove the version just fine. Well, and the former will always change the groupId.
However, combining them into the same recipe makes the latter not work anymore.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the YAML recipe with the Maven plugin against the multi-module project described, comparing ChangeTagValue and RemoveXmlTag when run together versus separately. Start by tracing the ChangeTagValue and RemoveXmlTag recipe entry points; done means the version element is removed after the groupId changes to ${some.variable}, while the existing removals still behave as expected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100