Skip to content

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

Open
@svaningelgem

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    • Status

      No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions