jenkinsci / plugin-modernizer-tool

MIT License
2 stars 5 forks source link

Dealing with recipes that requires configuration parameters #58

Open sridamul opened 5 days ago

sridamul commented 5 days ago

What feature do you want to see added?

Some recipes like Replacelibrarieswithapiplugin, UpgradeJavaVersion etc. requires configuration parameters to execute the recipe.

Idea: We can parse the rewrite.yml file (path can be passed as argument, a new option required) to extract the name (added to activeRecipes) and recipeList (to add the respective recipeArtifactCoordinates)

For Eg: In below rewrite.xml, we can obtain com.yourorg.IsJenkinsPluginExample to activeRecipes and io.jenkins.plugin-modernizer:plugin-modernizer-core:${project.version} as an artifact coordinate for org.openrewrite.jenkins.IsJenkinsPlugin recipe

type: specs.openrewrite.org/v1beta/recipe
name: com.yourorg.IsJenkinsPluginExample
displayName: Is the project a Jenkins plugin? example
recipeList:
  - org.openrewrite.jenkins.IsJenkinsPlugin:
      version: '[1,)'

Testing: I created a rewrite.yml file inside plugin dir and added the name to activeRecipes. This works fine and the recipe is applied to the plugin successfully.

Need to improvise the idea and also open to any other approaches or suggestions.

Upstream changes

No response

Are you interested in contributing this feature?

No response

jonesbusy commented 5 days ago

What about packaging our own rewrite.yml on META-INF/rewrite/*.yml recipes ?

And perhaps we should only use OpenRewrite YAML format for declarative recipe and not use our own recipe_data.yaml ?

https://docs.openrewrite.org/reference/yaml-format-reference

This contains also description we can use for the "--list-recipes"