{"id":37756960,"url":"https://github.com/snowdrop/rewrite-client","last_synced_at":"2026-06-16T07:00:59.449Z","repository":{"id":328193324,"uuid":"1114559519","full_name":"snowdrop/rewrite-client","owner":"snowdrop","description":"Quarkus Openrewrite client and library","archived":false,"fork":false,"pushed_at":"2026-06-01T04:59:49.000Z","size":791,"stargazers_count":3,"open_issues_count":13,"forks_count":2,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-01T06:29:56.586Z","etag":null,"topics":["client","code-search","java","library","migration","openrewrite","openrewrite-recipes","quarkus"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/snowdrop.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-11T14:48:18.000Z","updated_at":"2026-04-15T15:16:46.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/snowdrop/rewrite-client","commit_stats":null,"previous_names":["ch007m/rewrite-standalone-cli","snowdrop/rewrite-client"],"tags_count":56,"template":false,"template_full_name":null,"purl":"pkg:github/snowdrop/rewrite-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snowdrop%2Frewrite-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snowdrop%2Frewrite-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snowdrop%2Frewrite-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snowdrop%2Frewrite-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/snowdrop","download_url":"https://codeload.github.com/snowdrop/rewrite-client/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snowdrop%2Frewrite-client/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34393305,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-16T02:00:06.860Z","response_time":126,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["client","code-search","java","library","migration","openrewrite","openrewrite-recipes","quarkus"],"created_at":"2026-01-16T14:31:06.806Z","updated_at":"2026-06-16T07:00:59.378Z","avatar_url":"https://github.com/snowdrop.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenRewrite Client and library\n\n[![GitHub Actions Status](https://img.shields.io/github/actions/workflow/status/snowdrop/rewrite-client/build-test.yml?branch=main\u0026logo=GitHub\u0026style=for-the-badge)](https://github.com/snowdrop/rewrite-client/actions/workflows/build-test.yml)\n[![License](https://img.shields.io/github/license/snowdrop/rewrite-client?style=for-the-badge\u0026logo=apache)](https://www.apache.org/licenses/LICENSE-2.0)\n[![Version](https://img.shields.io/maven-central/v/dev.snowdrop.openrewrite/rewrite-client?logo=apache-maven\u0026style=for-the-badge)](https://search.maven.org/artifact/dev.snowdrop.openrewrite/rewrite-client)\n\nA Java library and CLI tool for executing OpenRewrite recipes programmatically, without requiring Maven plugin execution.\n\n## Overview\n\nRewrite is a powerful framework for automated code refactoring.\nTraditionally, it's used via Maven goals (`mvn rewrite:run` or `mvn rewrite:dryRun`), but this project provides an alternative approach that allows you to:\n\n- **Execute recipes programmatically** from your Java code\n- **Run recipes via CLI** without Maven\n- **Process results directly** without parsing console logs or csv files generated.\n- **Integrate easily** into custom migration tools and workflows\n\n## Quick Start\n\n### As a Library\n\nAdd the dependency to your project:\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003edev.snowdrop.openrewrite\u003c/groupId\u003e\n    \u003cartifactId\u003eservice\u003c/artifactId\u003e\n    \u003cclassifier\u003eshaded\u003c/classifier\u003e\n    \u003cversion\u003e0.3.5-SNAPSHOT\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nUse the `RewriteService` to process a Java project:\n\n```java\nimport dev.snowdrop.rewrite.service.RewriteService;\nimport dev.snowdrop.rewrite.config.RewriteConfig;\nimport dev.snowdrop.rewrite.ResultsContainer;\n\nRewriteConfig cfg = new RewriteConfig();\ncfg.setAppPath(Paths.get(\"/path/to/your/project\"));\ncfg.setFqNameRecipe(\"org.openrewrite.java.format.AutoFormat\");\n\nRewriteService scanner = new RewriteService(cfg);\nscanner.init();\nResultsContainer results = scanner.runScanner();\n\n// Access results\nRecipeRun run = results.getRecipeRuns().get(\"org.openrewrite.java.format.AutoFormat\");\n// Process datatables, changesets, etc.\n```\n\n### As a CLI Tool\n\nInstall using [jbang](https://www.jbang.dev/):\n\n```bash\njbang app install rewrite@snowdrop/rewrite-client\n```\n\u003e [!NOTE]\n\u003e To install a released version, append to the reference of the version\n```shell\njbang app install rewrite@snowdrop/rewrite-client/0.3.5-SNAPSHOT\n```\n\nRun a recipe:\n\n```bash\nrewrite /path/to/project -r org.openrewrite.java.format.AutoFormat\n```\n\nRun a recipe without the `dryrun` mode:\n\n```bash\nrewrite /path/to/project -r org.openrewrite.java.format.AutoFormat -d false\n```\n\n\n## Usage\nImportant Considerations:\n\nWhen using the rewrite-client, keep these key points in mind:\n\n- **Recipe Resolution**: Recipes are specified by their fully qualified class name (e.g., org.openrewrite.java.format.AutoFormat).\n  The tool loads recipe classes from the runtime classpath, so ensure the recipe's JAR is available.\n\n- **Parameter Configuration**: Recipe fields can be configured using comma-separated key-value pairs.\n  Values are automatically type-converted to match the recipe's field types (String, boolean, int, etc.).\n\n- **External Recipe JARs**: If your recipe is packaged in a separate JAR file, you can load it dynamically using either a local file path or Maven GAV coordinates.\n  The tool will resolve and add it to the classpath before execution.\n\n- **YAML Configuration Files**: For complex recipe configurations or multiple recipes, YAML files provide a cleaner alternative.\n  They support the OpenRewrite YAML specification format and allow you to define recipe chains with parameters.\n\n\n### Basic Recipe Execution\n\nExecute a recipe by its fully qualified class name:\n\n```bash\nrewrite /path/to/project -r org.openrewrite.java.format.AutoFormat\n```\n\n**In code:**\n\n\u003e [!NOTE]\n\u003e Note that the first lines of the following snippet code are [JBang](https://www.jbang.dev/) headers. They declare the required dependencies (//DEPS) and runtime options (//RUNTIME_OPTIONS) so that JBang can resolve and run the script correctly. //NOINTEGRATIONS prevents JBang from automatically activating any framework integrations that could interfere with the execution.\n\n```java\n///usr/bin/env jbang \"$0\" \"$@\" ; exit $?\n//DEPS org.slf4j:slf4j-api:2.0.17\n//DEPS org.jboss.slf4j:slf4j-jboss-logmanager:2.1.0.Final\n//DEPS dev.snowdrop.openrewrite:service:0.3.5-SNAPSHOT:shaded\n//NOINTEGRATIONS\n//RUNTIME_OPTIONS -Djava.util.logging.manager=org.jboss.logmanager.LogManager\n\npackage dev.snowdrop;\n\nimport dev.snowdrop.rewrite.service.RewriteService;\nimport dev.snowdrop.rewrite.config.RewriteConfig;\nimport dev.snowdrop.rewrite.ResultsContainer;\nimport org.openrewrite.DataTable;\nimport org.openrewrite.RecipeRun;\n\nimport java.nio.file.Paths;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Optional;\n\npublic class RewriteApp {\n    public static void main(String[] args) throws Exception {\n        RewriteConfig cfg = new RewriteConfig();\n        cfg.setAppPath(Paths.get(\"/path/to/your/project\"));\n        cfg.setFqNameRecipe(\"org.openrewrite.java.format.AutoFormat\");\n\n        RewriteService scanner = new RewriteService(cfg);\n        scanner.init();\n        ResultsContainer results = scanner.runScanner();\n        ...\n    }\n}\n```\n\n### Recipe with Parameters\n\nMany recipes accept configuration parameters. Pass them using the `-o` option:\n\n```bash\nrewrite /path/to/project \\\n  -r org.openrewrite.java.search.FindAnnotations \\\n  -o annotationPattern=@org.springframework.boot.autoconfigure.SpringBootApplication,matchMetaAnnotations=false\n```\n\n**In code:**\n\n```java\ncfg.setRecipeOptions(Set.of(\n    \"annotationPattern=@org.springframework.boot.autoconfigure.SpringBootApplication\",\n    \"matchMetaAnnotations=false\"\n));\n```\n\n**Multiple parameters** are separated by commas in the format `key=value,key2=value2`.\n\n### Using a YAML Configuration File\n\nDefine recipes in a YAML file:\n\n```yaml\n# rewrite.yml\ntype: specs.openrewrite.org/v1beta/recipe\nname: com.example.MyRecipe\ndisplayName: My Custom Recipe\nrecipeList:\n  - org.openrewrite.java.format.AutoFormat\n  - org.openrewrite.java.search.FindAnnotations:\n      annotationPattern: '@SpringBootApplication'\n```\n\nExecute with:\n\n```bash\nrewrite /path/to/project -c rewrite.yml\n```\n\n**In code:**\n\n```java\ncfg.setYamlRecipesPath(Paths.get(\"rewrite.yml\"));\n```\n\n### Loading External Recipe JARs\n\nLoad recipes from external JAR files using Maven GAV coordinates:\n\n```bash\nrewrite --jar org.openrewrite.recipe:rewrite-java-dependencies:1.51.1 \\\n  /path/to/project \\\n  -r dev.snowdrop.custom.MyRecipe\n```\n\nOr use a local JAR path:\n\n```bash\nrewrite --jar /path/to/recipes.jar /path/to/project -r com.example.MyRecipe\n```\n\n## Processing Results\n\nThe `ResultsContainer` provides access to recipe execution results:\n\n```java\nResultsContainer results = scanner.runScanner();\n\n// Get results for a specific recipe\nRecipeRun run = results.getRecipeRuns().get(\"org.openrewrite.java.search.FindAnnotations\");\n\n// Fetch the DataTable matching the recipe executed for SearchResults\nList\u003cSearchResults.Row\u003e rows = findDataTableRows(run, \"SearchResults\", SearchResults.Row.class);\nSearchResults.Row record = rows.getFirst();\nSystem.out.println(\"Found in: \" + record.getSourcePath());\nSystem.out.println(\"Match: \" + record.getResult());\n\n// Access changesets (code modifications)\n// run.getChangeset()...\n```\n\n## Reuse resources already scanned\n\nWhen you use the method `init()` of the `RewriteService`, then the library will create the following OpenRewrite class during the call to the method:\n\n- `Environment` holding the resource loaders able to find Recipe classes from jar, classes loaded or Yaml\n- `ExecutionContext` able to collect from the execution of the different Recipe the messages containing the Map of the DataTable, etc\n- `LargeSourceSet` using different parsers able to read: Java, Maven, Properties, XML, JSON, etc files\n\nIt is nevertheless possible, to scan the resources one time and apply different recipes. In this case, we recommend you to create a singleton of the `RewriteService` and next to call separately the following methods:\n\n```java\n// Create a singleton instance of the RewriteService to allow to load only one time all the resources of a project to scan\nRewriteService svc = createRewriteServiceInstance(cfg);\n\nif (svc.isSourceSetInitialized()) {\n\tsvc.createExecutionContext();\n\tsvc.updateConfig(cfg);\n} else {\n\tsvc.init();\n}\n\n// Execute now a recipe\nResultsContainer run = svc.runScanner();\n```\n\n## Development\n\n### Prerequisites\n\n- JDK 21\n- Apache Maven 3.9+\n\n### Building from Source\n\n```bash\ngit clone https://github.com/snowdrop/rewrite-client.git\ncd rewrite-client\nmvn clean install\n```\n\n### Running in Development Mode\n\n```bash\nmvn quarkus:dev -Dquarkus.args=\"test-project/simple -r org.openrewrite.java.format.AutoFormat\"\n```\n\n### Debugging\n\nConfigure the Java agent for debugging:\n\n```bash\njava -jar -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=\"*:5005\" \\\n  target/quarkus-app/quarkus-run.jar \\\n  test-project/simple -r org.openrewrite.java.format.AutoFormat\n```\n\nThen attach your debugger to port 5005.\n\n## Examples\n\nCheck the [`sample`](sample) directory for different examples demonstrating the library usage. \nThe folder includes a basic Java `demo` application \n\n### Find Spring Boot Annotations\n\n```bash\nrewrite test-project/spring-boot-todo-app \\\n  -r org.openrewrite.java.search.FindAnnotations \\\n  -o annotationPattern=@org.springframework.boot.autoconfigure.SpringBootApplication\n```\n\n### Find Maven Dependencies\n\n```bash\nrewrite test-project/spring-boot-todo-app \\\n  -r org.openrewrite.maven.search.FindDependency \\\n  -o groupId=org.springframework.boot,artifactId=spring-boot-starter-data-jpa,version=3.5.3\n```\n\n### Auto-format Code\n\n```bash\nrewrite test-project/simple -r org.openrewrite.java.format.AutoFormat\n```\n\n## Use Cases\n\nThis library is particularly useful for:\n\n- **Migration Tools**: Integrate OpenRewrite scanning into custom migration frameworks\n- **CI/CD Pipelines**: Run recipe checks without full Maven builds\n- **Custom Tooling**: Build specialized refactoring or analysis tools\n- **Batch Processing**: Execute recipes across multiple projects programmatically\n\n## License\n\nThis project is licensed under the [Apache License 2.0](LICENSE).\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnowdrop%2Frewrite-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsnowdrop%2Frewrite-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnowdrop%2Frewrite-client/lists"}