openrewrite / rewrite-gradle-plugin

OpenRewrite's Gradle plugin.
Apache License 2.0
65 stars 41 forks source link

Unable to rewrite a multivalue application.yml file #337

Closed k3vonk closed 1 month ago

k3vonk commented 1 month ago

What version of OpenRewrite are you using?

I am using

How are you running OpenRewrite?

IntelliJ plugin and running the play button on a openRewrite script.

I believe this adds the gradle plugin as part of the run processes.

What is the smallest, simplest way to reproduce the problem?

spring:
  application:
    name: "Test"
  autoconfigure:
    exclude:
      - org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
      - com.test.old.library.Something

What did you expect to see?

spring:
  application:
    name: "Test"
  autoconfigure:
    exclude:
      - org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
      - com.test.new.library.Something

What did you see instead?

spring:
  application:
    name: "Test"
  autoconfigure:
    exclude:
      - org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
      - com.test.old.library.Something

What is the full stack trace of any errors you encountered?

No errors as nothing was detected for rewriting

My recipe:

---
type: specs.openrewrite.org/v1beta/recipe
name: com.test.rewrite
displayName: Change YAML property example
recipeList:
  - org.openrewrite.yaml.ChangePropertyValue:
      propertyKey: spring.autoconfigure.exclude
      oldValue: com.test.old*
      newValue: com.test.new
      regex: true
      filePattern: src/test/resources/*.yml

I've tested this in a non multivalue property and it works but not for a multi value property.

timtebeek commented 1 month ago

The oldValue is matched as a regular expression above; yet your value com.test.old* is a little suspicious; did you mean to use com\.test\.old.* ?

timtebeek commented 1 month ago

A unit test in your own copy of rewrite-recipe-starter might help speed up your testing there.

timtebeek commented 1 month ago

Closing this due to inactivity; assuming misconfiguration. Do let us know if your problems persist beyond the suggestions offered above.