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

Added new recipe ChangeDependencyVersionValue #4366

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

marcel-gepardec
Copy link
Contributor

Recipe ChangeDependencyVersionValue

What's changed?

As discussed in another PR #4330 , I have now moved the change version part to a new recipe.

Nothing really changed from last PR, except the new recipe can also be called directly with new options.
The first new one is versionLocation:

  • Changes dependency version right where you want it. The default is set to change it everywhere. But you can also specifically target DEPENDENCY, MANAGED_DEPENDENCY or PLUGIN_DEPENDENCY. It also doesn't matter if they are in a profile or not.

The second new option is newPropertyVersionValue:

  • If it is set than the property variable name is changed to it.

Example

new Recipe ChangeDependencyVersionValue:

---
type: specs.openrewrite.org/v1beta/recipe
name: com.example.openrewrite.migrate.NewJakartaPersistenceVersion
displayName: Change Maven managed dependency version with property example
recipeList:
  - org.openrewrite.maven.ChangeDependencyVersionValue:
      groupId: jakarta.persistence
      artifactId: jakarta.persistence-api
      newVersion: latest.release
      changePropertyVersionName: true
      newPropertyVersionName: test
      versionLocation: MANAGED_DEPENDENCY

Before:

                  ...
                  <properties>
                          <jakarta.persistence-api.version>1.2.0</jakarta.persistence-api.version>
                  </properties>
                  <dependencyManagement>
                      <dependencies>
                          <dependency>
                              <groupId>jakarta.persistence</groupId>
                              <artifactId>jakarta.persistence-api</artifactId>
                              <version>${jakarta.persistence-api.version}</version>
                          </dependency>
                      </dependencies>
                  </dependencyManagement>
                  <dependencies>
                      <dependency>
                           <groupId>jakarta.persistence</groupId>
                           <artifactId>jakarta.persistence-api</artifactId>
                           <version>1.2.0</version>
                      </dependency>
                  </dependencies>
                  ...

After:

                  ...
                  <properties>
                          <test>3.2.0</test>
                  </properties>
                  <dependencyManagement>
                      <dependencies>
                          <dependency>
                              <groupId>jakarta.persistence</groupId>
                              <artifactId>jakarta.persistence-api</artifactId>
                              <version>${test}</version>
                          </dependency>
                      </dependencies>
                  </dependencyManagement>
                  <dependencies>
                      <dependency>
                           <groupId>jakarta.persistence</groupId>
                           <artifactId>jakarta.persistence-api</artifactId>
                           <version>1.2.0</version>
                      </dependency>
                  </dependencies>
                  ...

timtebeek and others added 2 commits July 31, 2024 22:26
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@timtebeek
Copy link
Contributor

Thanks for splitting off these changes! I do see some overlap in the files changed and in

Since we squash merge; would it be possible to minimize the changes here such that we can only review what's related to the new recipe? Or did I misunderstand the change set seen here?

@timtebeek timtebeek added the recipe Requested Recipe label Jul 31, 2024
@marcel-gepardec
Copy link
Contributor Author

Thanks for the feedback.

I only changed the code related to the new implementation of this recipe. I simplified the other recipes so there is no code duplication and I just moved the version change part to this recipe. I did not change anything else regarding this topic.
So should I revert the changes I made to the other recipes?

That being said, in case we are not on the same page, every change set from the last PR #4330 is also included in this one, so you could just close the other PR #4330.

@timtebeek
Copy link
Contributor

That being said, in case we are not on the same page, every change set from the last PR #4330 is also included in this one, so you could just close the other PR #4330.

Ah that explains it then; I would have thought both PRs would separately be reviewed and merged, but we can also close #4330 then indeed.

@marcel-gepardec
Copy link
Contributor Author

Yes, that would probably be the best.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
recipe Requested Recipe
Projects
Status: Ready to Review
Development

Successfully merging this pull request may close these issues.

2 participants