Skip to content

#1031: integrate openrewrite - #2299

Open
samuelkos17 wants to merge 29 commits into
devonfw:mainfrom
samuelkos17:feature/1031_integrate_with_openrewrite
Open

#1031: integrate openrewrite#2299
samuelkos17 wants to merge 29 commits into
devonfw:mainfrom
samuelkos17:feature/1031_integrate_with_openrewrite

Conversation

@samuelkos17

@samuelkos17 samuelkos17 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

This PR fixes #1031

Old PR was #1266

Implemented changes:

  • RewriteCommandlet — new commandlet to execute OpenRewrite recipes
  • RecipeManager — manages and loads configurable OpenRewrite recipes
  • RecipeWrapper / RecipeWrapperJsonDeserializer — wrapper and JSON deserializer for recipe configuration
  • RewriteRecipeEnum — enum for predefined rewrite recipes
  • JSON configuration files (refactor/openrewrite.json) for defining recipes
  • Help texts for the rewrite command in English and German
  • Updated CommandletManagerImpl, JsonMapping, and native-image reflect/resource configs to support the new modules
  • Added tests for RewriteCommandlet and RecipeManager

Testing instructions

Please add conscise, understandable instructions on how a reviewer can test/verify the functionality of your contribution here:

  1. Run mvn clean test in the cli module to verify all tests pass
  2. Test the rewrite commandlet manually with the provided openrewrite.json configuration using the local dev build.
  3. Verify help texts are displayed correctly for the rewrite command

Checklist for this PR

Make sure everything is checked before merging this PR. For further info please also see
our DoD.

  • When running mvn clean test locally all tests pass and build is successful
  • PR title is of the form #«issue-id»: «brief summary» (e.g. #921: fixed setup.bat and not feature/921 fixed setup.bat). If no issue ID exists, title only.
  • PR top-level comment summaries what has been done and contains link to addressed issue(s)
  • PR and issue(s) have suitable labels
  • Issue is set to In Progress and assigned to you or there is no issue (might happen for very small PRs)
  • You followed all coding conventions
  • You have added the issue implemented by your PR in CHANGELOG.adoc unless issue is labelled
    with internal
  • You have not changed any dependency in pom.xml files or otherwise if runtime dependencies changed, you have updated our LICENSE.asciidoc
  • You have formulated clear instructions on how to test your contribution under "Testing instructions"

yurii-yu and others added 25 commits February 26, 2025 11:07
…nrewrite' into feature/1031_intergrate_with_openrewrite
…ith_openrewrite

# Conflicts:
#	cli/src/main/java/com/devonfw/tools/ide/commandlet/CommandletManagerImpl.java
#	cli/src/main/resources/nls/Help.properties
#	cli/src/main/resources/nls/Help_de.properties
…ith_openrewrite

# Conflicts:
#	cli/src/main/java/com/devonfw/tools/ide/commandlet/CommandletManagerImpl.java
#	cli/src/main/resources/nls/Help.properties
#	cli/src/main/resources/nls/Help_de.properties
…h_openrewrite

# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
@github-project-automation github-project-automation Bot moved this to 🆕 New in IDEasy board Aug 10, 2026
@samuelkos17 samuelkos17 self-assigned this Aug 10, 2026
@samuelkos17 samuelkos17 moved this from 🆕 New to Team Review in IDEasy board Aug 10, 2026
@samuelkos17 samuelkos17 added the enhancement New feature or request label Aug 10, 2026
@samuelkos17 samuelkos17 added the rewrite command for OpenRewrite label Aug 10, 2026
@samuelkos17 samuelkos17 changed the title Feature/1031 integrate with openrewrite #1031 integrate with openrewrite Aug 10, 2026
@samuelkos17 samuelkos17 changed the title #1031 integrate with openrewrite #1031: integrate openrewrite Aug 10, 2026
@coveralls

coveralls commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 32134237327

Coverage decreased (-0.06%) to 72.865%

Details

  • Coverage decreased (-0.06%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • 8 coverage regressions across 2 files.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

8 previously-covered lines in 2 files lost coverage.

File Lines Losing Coverage Coverage
com/devonfw/tools/ide/commandlet/CommandletManagerImpl.java 7 92.02%
com/devonfw/tools/ide/json/JsonMapping.java 1 96.43%

Coverage Stats

Coverage Status
Relevant Lines: 17663
Covered Lines: 13420
Line Coverage: 75.98%
Relevant Branches: 7791
Covered Branches: 5127
Branch Coverage: 65.81%
Branches in Coverage %: Yes
Coverage Strength: 3.23 hits per line

💛 - Coveralls

@Ali-Shariati-Najafabadi Ali-Shariati-Najafabadi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice first step on the OpenRewrite integration. A few things before this can merge:

Missing CHANGELOG.adoc entry for #1031.
Left a few inline notes: an exception path that can leak a raw NPE, a redundant try/catch, some stale help text, and a bit of dead code.
Scope-wise, the original issue talked about AssertJ/Hamcrest/JUnit recipes plus a generic --artifact= option ,this PR only covers two formatting recipes. Might be fine as a first cut, but worth checking with a maintainer whether that's okay to merge as-is.

Comment thread cli/src/main/java/com/devonfw/tools/ide/commandlet/RewriteCommandlet.java Outdated
Comment thread cli/src/main/java/com/devonfw/tools/ide/tool/openrewrite/RecipeManager.java Outdated
Comment thread cli/src/main/java/com/devonfw/tools/ide/tool/openrewrite/RecipeManager.java Outdated
Comment thread cli/src/main/java/com/devonfw/tools/ide/tool/openrewrite/RecipeWrapper.java Outdated
Comment thread cli/src/main/resources/nls/Help.properties Outdated
Comment thread cli/src/main/resources/nls/Help.properties Outdated
Comment thread cli/src/main/resources/nls/Help_de.properties Outdated
Comment thread cli/src/main/resources/nls/Help_de.properties Outdated
Comment thread cli/src/test/java/com/devonfw/tools/ide/commandlet/RewriteCommandletTest.java Outdated
Comment thread cli/src/test/java/com/devonfw/tools/ide/commandlet/RewriteCommandletTest.java Outdated
@samuelkos17

Copy link
Copy Markdown
Contributor Author

@Ali-Shariati-Najafabadi thanks for all the Review suggestions! I agree with you on all of them and added them all.

@Ali-Shariati-Najafabadi Ali-Shariati-Najafabadi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified, all the review points look properly addressed.

@Ali-Shariati-Najafabadi Ali-Shariati-Najafabadi moved this from Team Review to 👀 In review in IDEasy board Aug 19, 2026
@samuelkos17 samuelkos17 added this to the release:2026.08.002 milestone Aug 20, 2026

@hohwille hohwille left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samuelkos17 thanks for taking over this PR. 👍
It has been a long time since I wrote the initial story for this.
Before this is ready to merge I see some issues:

  • You create a new commandlet but removed the DoD checklist for new commandlets.
  • This way you missed to add OpenRewirte to our license
  • Shouldn't RewriteCommandlet be a LocalToolCommandlet? I see that technically nothing needs to be installed here since we are just triggering mvn that you are properly invoking as commandlet so it will ensure installing mvn and java if needed and also supports mnvw, etc. So maybe we want to keep it as is but just logically I would consider this as a local tool that should also have tags.
  • You implemented what I wrote in the story. However, during the review I get the impression that it would make much more sense to have openrewrite.json in ide-settings so recipe shortcuts are not hard-coded but can be added by projects without changing the code of IDEasy. We can still create a follow up story for this and first merge this and later improve with a new PR. However, just reading the current code does not seem to make much sense. If we include the JSON into our release we can also hard-code its content in Java and would need no JSON parser. This is why I read the story again since I expected that I have suggested the JSON so that it can be configured outside of the IDEasy product dynamically but somehow I did not write this correctly in the story description. But great that you implemented the JSON mapping already so if we (later) support to read the JSON from outside this is already there.
  • I would not add the recipe options to the help texts - they will quickly outdate if something changes. For this we have auto-completion that always reflects the truth and needs no update if JSON/enum changes.

Comment on lines +62 to +74
{
"name": "com.devonfw.tools.ide.tool.openrewrite.RecipeWrapper",
"allDeclaredConstructors": true,
"allPublicConstructors": true,
"allDeclaredFields": true,
"allDeclaredMethods": true
},
{
"name": "com.devonfw.tools.ide.tool.openrewrite.RewriteRecipeEnum",
"allDeclaredConstructors": true,
"allPublicConstructors": true,
"allDeclaredFields": true,
"allDeclaredMethods": true

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really needed? We have a dedicated deserializer to read the JSON.

cmd.repository.val.repository=Der Name der Properties-Datei des vorkonfigurierten Git Repositories zum Einrichten. Falls nicht angegeben, werden alle aktiven Projekte eingerichtet.
cmd.rewrite=Refaktorieren Sie die vorhandene Codebasis mit spezifischen Rezepten von OpenRewrite
cmd.rewrite.detail=OpenRewrite ist ein beliebtes Tool für Refactoring (Metaprogrammierung). Eine ausführliche Dokumentation finden Sie unter https://docs.openrewrite.org/
cmd.rewrite.val.recipe_name=Rezeptnamen umgestalten (FORMAT_JAVA_CODE|REMOVE_BLANK_LINES)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cmd.rewrite.val.recipe_name=Rezeptnamen umgestalten (FORMAT_JAVA_CODE|REMOVE_BLANK_LINES)
cmd.rewrite.val.recipe_name=OpenRewrite Rezeptnamen (FORMAT_JAVA_CODE|REMOVE_BLANK_LINES)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request rewrite command for OpenRewrite

Projects

Status: 👀 In review

Development

Successfully merging this pull request may close these issues.

Integration of OpenRewrite

7 participants