{"id":14972935,"url":"https://github.com/spring-projects/spring-rewrite-commons","last_synced_at":"2025-10-19T11:30:16.775Z","repository":{"id":212386829,"uuid":"718847144","full_name":"spring-projects/spring-rewrite-commons","owner":"spring-projects","description":null,"archived":false,"fork":false,"pushed_at":"2024-10-03T17:17:22.000Z","size":755,"stargazers_count":11,"open_issues_count":26,"forks_count":11,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-01-29T14:23:04.054Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/spring-projects.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"contributing":"CONTRIBUTING.adoc","funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-14T23:02:37.000Z","updated_at":"2024-11-27T13:58:00.000Z","dependencies_parsed_at":"2024-01-13T13:54:33.393Z","dependency_job_id":"2add8c3b-3c9c-49fc-9877-d75a2bd3aba6","html_url":"https://github.com/spring-projects/spring-rewrite-commons","commit_stats":null,"previous_names":["spring-projects/spring-rewrite-commons"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spring-projects%2Fspring-rewrite-commons","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spring-projects%2Fspring-rewrite-commons/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spring-projects%2Fspring-rewrite-commons/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spring-projects%2Fspring-rewrite-commons/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spring-projects","download_url":"https://codeload.github.com/spring-projects/spring-rewrite-commons/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237116293,"owners_count":19258224,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-09-24T13:47:47.142Z","updated_at":"2025-10-19T11:30:15.948Z","avatar_url":"https://github.com/spring-projects.png","language":"Java","readme":"= Spring Rewrite Commons\n:partials_dir: spring-rewrite-commons-docs/src/main/antora/modules/ROOT/pages/partials\n:project-version: 0.1.0-SNAPSHOT\n:projectVersion: {project-version}\n:docs: https://docs.spring.io/spring-rewrite-commons/docs/current-SNAPSHOT/reference/html/\n\n[quote]\n____\nSpring Rewrite Commons provides a set of components to parse a Java project to https://github.com/openrewrite[OpenRewrite,window=_blank] LST and apply recipes outside a build tool plugin.\n____\n\n\n== Get started\n\n=== Add Dependency\n\n**Maven**\n[source,xml,indent=0,subs=\"verbatim,quotes,attributes\",role=\"primary\"]\n----\n\u003cdependency\u003e\n    \u003cgroupId\u003eorg.springframwork.rewrite\u003c/groupId\u003e\n    \u003cartifactId\u003espring-rewrite-commons-launcher\u003c/artifactId\u003e\n    \u003cversion\u003e{project-version}\u003c/version\u003e\n\u003c/dependency\u003e\n----\n\n**Gradle**\n[source,groovy,indent=0,subs=\"verbatim,quotes,attributes\",role=\"secondary\"s]\n----\ncompile 'org.springframework.rewrite:spring-rewrite-commons-launcher:{projectVersion}'\n----\n\n\n=== Implement a Recipe Launcher\n\n[source,java]\n....\npackage com.acme.example;\n\nimport org.openrewrite.Recipe;\nimport org.openrewrite.SourceFile;\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.rewrite.RewriteProjectParser;\nimport org.springframework.rewrite.parser.RewriteProjectParsingResult;\nimport org.springframework.rewrite.resource.ProjectResourceSet;\nimport org.springframework.rewrite.resource.ProjectResourceSetFactory;\nimport org.springframework.rewrite.resource.ProjectResourceSetSerializer;\nimport org.springframework.rewrite.RewriteRecipeDiscovery;\nimport org.springframework.stereotype.Component;\n\nimport java.nio.file.Path;\n\n@Component\npublic class MyMigrationApplication {\n\n    @Autowired \u003c1\u003e\n    private RewriteProjectParser parser;\n\n    @Autowired\n    private RewriteRecipeDiscovery discovery; \u003c2\u003e\n\n    @Autowired\n    private ProjectResourceSetFactory resourceSetFactory;\n\n    @Autowired\n    private ProjectResourceSetSerializer serializer;\n\n\n    public void migrateToBoot3_1() {\n        Path baseDir = Path.of(\".\"); \u003c2\u003e\n        String recipeName = \"org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_1\";\n        Recipe boot3Upgrade = discovery.getByName(recipeName); \u003c3\u003e\n\n        RewriteProjectParsingResult result = parser.parse(baseDir); \u003c4\u003e\n        List\u003cSourceFile\u003e lst = result.sourceFiles(); \u003c5\u003e\n        ProjectResourceSet resourceSet = resourceSetFactory.create(baseDir, lst); \u003c6\u003e\n        resourceSet.apply(boot3Upgrade); \u003c7\u003e\n        serializer.writeChanges(resourceSet); \u003c8\u003e\n    }\n}\n....\n\u003c1\u003e All components are Spring beans and can be injected as such.\n\u003c2\u003e The path of the project that should be migrated.\n\u003c3\u003e `RewriteRecipeDiscovery` is used to discover an OpenRewrite recipe by name.\n\u003c4\u003e `RewriteProjectParser` parses a given project to OpenRewrite LST.\n\u003c5\u003e The result contains the list of ``SourceFile``s (the LST).\n\u003c6\u003e `ProjectResourceSetFactory` can be used to create a `ProjectResourceSet`.\n\u003c7\u003e The recipe is applied to the `ProjectResourceSet` which wraps the LST.\n\u003c8\u003e `ProjectResourceSetSerializer` is used to serialize the changes to disk.\n\n\n== Reference documentation\n\nFind the reference documentation link:{docs}[here].\n\n== Contributing\n\nhttps://help.github.com/articles/creating-a-pull-request[Pull requests] are welcome. Note, that we expect everyone to follow the https://github.com/spring-projects/.github/blob/main/CODE_OF_CONDUCT.md[code of conduct].\n\n== License\nSpring Rewrite Commons is Open Source software released under the\nhttps://www.apache.org/licenses/LICENSE-2.0.html[Apache 2.0 license].\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspring-projects%2Fspring-rewrite-commons","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspring-projects%2Fspring-rewrite-commons","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspring-projects%2Fspring-rewrite-commons/lists"}