Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interaction between ChangeTagValue & RemoveXmlTag leads to not executed recipe #4842

Open
svaningelgem opened this issue Jan 3, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@svaningelgem
Copy link
Contributor

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.

@svaningelgem svaningelgem added the bug Something isn't working label Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: No status
Development

No branches or pull requests

1 participant