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

Add validation to ChangeDependency, so it checks that either group or artifact is different from the old. #55

Open
timtebeek opened this issue Jan 5, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@timtebeek
Copy link
Contributor

What problem are you trying to solve?

the Change*Dependency… recipes are specifically for changing to a different dependency (as the name implies, doh!). The fact that it has a newVersion parameter tripped me up. I see UpgradeDependencyVersion does what I expected.
A reference from Change… to Upgrade may be helpful. In fact I see Change… being used supposedly to perform an upgrade (judging from the recipe docs) when perhaps an Upgrade… was intended. If the old and the new G+A are identical and newVersion is specified, then it's not a move/change and likely should be an Upgrade.

Describe the solution you'd like

Add validation to ChangeDependency, so it checks that either group or artifact is different from the old. This would apply to both the rewrite-java-dependency recipe, as well as the two rewrite-maven recipes.

Have you considered any alternatives or workarounds?

use a yaml rewrite recipe to change existing recipies (like the ones above) to use Upgrade if the new and old G+A are the same. use a yaml rewrite recipe to change existing recipies (like the ones above) to use Upgrade if the new and old G+A are the same.

Additional context

As suggested on OSS Slack by @tobli

@timtebeek timtebeek added the enhancement New feature or request label Jan 5, 2024
tobli added a commit to tobli/rewrite that referenced this issue Jan 5, 2024
ChangeDependencyGroupIdAndArtifactId and ChangeManagedDependencyGroupIdAndArtifactId are intended to be set up to *change* maven coordinates. If the pre- and post-coordinates are the same, it's likely that the UpgradeDependencyVersion recipe was intended. This change adds validation of the newGroupId/newArtifactId options.

See openrewrite/rewrite-java-dependencies#55
@timtebeek timtebeek moved this to Ready to Review in OpenRewrite Jan 5, 2024
timtebeek added a commit to openrewrite/rewrite-okhttp that referenced this issue Jan 5, 2024
timtebeek added a commit to openrewrite/rewrite-micrometer that referenced this issue Jan 5, 2024
@timtebeek timtebeek self-assigned this Jan 5, 2024
sambsnyd pushed a commit to openrewrite/rewrite that referenced this issue Jan 13, 2024
…AV (#3889)

ChangeDependencyGroupIdAndArtifactId and ChangeManagedDependencyGroupIdAndArtifactId are intended to be set up to *change* maven coordinates. If the pre- and post-coordinates are the same, it's likely that the UpgradeDependencyVersion recipe was intended. This change adds validation of the newGroupId/newArtifactId options.

See openrewrite/rewrite-java-dependencies#55
@timtebeek timtebeek moved this from Ready to Review to In Progress in OpenRewrite Mar 12, 2024
@timtebeek timtebeek added the good first issue Good for newcomers label Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
Status: Backlog
Development

No branches or pull requests

1 participant