As an experiment from asking openrewrite/rewrite#834 I made this little script which is 97% same as the code found in https://github.com/openrewrite/rewrite-maven-plugin.
It lets you run openrewrite on any kind of project.
How to run:
-
Install jbang (https://jbang.dev/download)
-
You can list recipes using:
jbang rewrite@maxandersen/rewrite-jbang discover
-
Try run it with a few recipes:
jbang rewrite@maxandersen/rewrite-jbang --recipes org.openrewrite.java.cleanup.Cleanup,org.openrewrite.java.format.AutoFormat
You can also install the script using: jbang app install https://github.com/maxandersen/rewrite-jbang/blob/master/rewrite.java
and just use rewrite
directly, i.e.:
rewrite --recipes org.openrewrite.java.cleanup.Cleanup,org.openrewrite.java.format.AutoFormat --dry-run
Limitations:
-
does not (yet) offer to refer to dependencies
-
totally just slammed together code a slow sunday morning!