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

org.openrewrite.properties.ChangePropertyValue not available? #3897

Closed
Evodam opened this issue Jan 9, 2024 · 4 comments
Closed

org.openrewrite.properties.ChangePropertyValue not available? #3897

Evodam opened this issue Jan 9, 2024 · 4 comments
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@Evodam
Copy link

Evodam commented Jan 9, 2024

I tried to change a property's value according to https://docs.openrewrite.org/recipes/properties/changepropertyvalue

I created a rewrite.yml that contained this:

type: specs.openrewrite.org/v1beta/recipe
name: com.yourorg.ChangeOracleJdbc
displayName: Swap old groupId of com.oracle.jdbc with newer com.oracle.database.jdbc
recipeList:
  - org.openrewrite.properties.ChangePropertyValue:
      propertyKey: oracle.connector.version
      newValue: 21.6.0.0.1
  - org.openrewrite.maven.ChangeManagedDependencyGroupIdAndArtifactId:
      oldGroupId: com.oracle.jdbc
      oldArtifactId: ojdbc8
      newGroupId: com.oracle.database.jdbc
      newArtifactId: ojdbc11
  - org.openrewrite.maven.ChangeDependencyGroupIdAndArtifactId:
      oldGroupId: com.oracle.jdbc
      oldArtifactId: ojdbc8
      newGroupId: com.oracle.database.jdbc
      newArtifactId: ojdbc11

I ran it using mvn org.openrewrite.maven:rewrite-maven-plugin:run -Drewrite.activeRecipes=com.yourorg.ChangeOracleJdbc

In console this recipe is not executed:
grafik

When changing the recipe to "org.openrewrite.maven.ChangePropertyValue" it works:
grafik

Am I using it wrong?

@Evodam Evodam added the bug Something isn't working label Jan 9, 2024
@timtebeek timtebeek added the question Further information is requested label Jan 9, 2024
@timtebeek
Copy link
Contributor

Hi @Evodam ; it's not immediately clear what type of property you're trying to replace.

org.openrewrite.properties.ChangePropertyValue is meant to replace properties in application.properties files, or other files ending in .properties.

@Override
public boolean accept(Path path) {
return path.toString().endsWith(".properties");
}

org.openrewrite.maven.ChangePropertyValue is meant to replace properties in Maven pom.xml and .pom files.

@Override
public boolean accept(Path path) {
return "pom.xml".equals(path.toString()) || path.toString().endsWith(".pom");
}

From your screenshots it seems you're expecting to replace properties in a pom.xml file; correct? Then you'd want to use the Maven ChangePropertyValue recipe.

If I misunderstood please let me know!

@Evodam
Copy link
Author

Evodam commented Jan 9, 2024

🤦
Yes, I want to change properties of a pom file. Thanks for clarification. Maybe add a note or something in the documentation?

@timtebeek
Copy link
Contributor

Good to have that cleared up! The hint was in the package names. Open to suggestions what kind of note would have helped here. :)

@timtebeek timtebeek self-assigned this Jan 9, 2024
@Evodam
Copy link
Author

Evodam commented Jan 9, 2024

@timtebeek

I think something like your comment would have helped.

"This recipe is meant to replace properties in application.properties files, or other files ending in .properties. For changing maven or gradle properties check $link"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
Archived in project
Development

No branches or pull requests

2 participants