This repository collects my custom recipes, primarily ones that add lombok annotations to projects that started without it.
This repository is still young and may e.g. be rebased, the releases on maven central however are immutable.
In order to run any of these recipes on your project you need to use either maven or gradle as a build tool. The OpenRewrite Docs are a great start.
- META-INF/rewrite/stringutils.yml - A declarative YAML recipe that replaces usages of
org.springframework.util.StringUtils
withorg.apache.commons.lang3.StringUtils
.- UseApacheStringUtilsTest - A test class for the
io.github.timo-a.UseApacheStringUtils
recipe.
- UseApacheStringUtilsTest - A test class for the
- NoGuavaListsNewArrayList.java - An imperative Java recipe that replaces usages of
com.google.common.collect.Lists
withnew ArrayList<>()
.- NoGuavaListsNewArrayListTest.java - A test class for the
NoGuavaListsNewArrayList
recipe.
- NoGuavaListsNewArrayListTest.java - A test class for the
- SimplifyTernary - An Refaster style recipe that simplifies ternary expressions.
- SimplifyTernaryTest - A test class for the
SimplifyTernary
recipe.
- SimplifyTernaryTest - A test class for the
- AssertEqualsToAssertThat - An imperative Java recipe that replaces JUnit's
assertEquals
with AssertJ'sassertThat
, to show how to handle classpath dependencies.- AssertEqualsToAssertThatTest - A test class for the
AssertEqualsToAssertThat
recipe.
- AssertEqualsToAssertThatTest - A test class for the
- AppendToReleaseNotes - A ScanningRecipe that appends a message to the release notes of a project.
- AppendToReleaseNotesTest - A test class for the
AppendToReleaseNotes
recipe.
- AppendToReleaseNotesTest - A test class for the
- ClassHierarchy - A recipe that demonstrates how to produce a data table on the class hierarchy of a project.
- ClassHierarchyTest - A test class for the
ClassHierarchy
recipe.
- ClassHierarchyTest - A test class for the
- UpdateConcoursePipeline - A recipe that demonstrates how to update a Concourse pipeline, as an example of operating on Yaml files.
- UpdateConcoursePipelineTest - A test class for the
UpdateConcoursePipeline
recipe.
- UpdateConcoursePipelineTest - A test class for the
Before you publish your recipe module to an artifact repository, you may want to try it out locally.
To do this on the command line, using gradle
, run:
./gradlew publishToMavenLocal
# or ./gradlew pTML
# or mvn install
To publish using maven, run:
./mvnw install
This will publish to your local maven repository, typically under ~/.m2/repository
.
Replace the groupId, artifactId, recipe name, and version in the below snippets with the ones that correspond to your recipe.
In the pom.xml of a different project you wish to test your recipe out in, make your recipe module a plugin dependency of rewrite-maven-plugin:
Copy what you need from here:
<project>
<build>
<plugins>
<plugin>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
<version>RELEASE</version>
<configuration>
<activeRecipes>
<recipe>io.github.timoa.lombok.ConvertNoArgsConstructor</recipe>
</activeRecipes>
</configuration>
<dependencies>
<dependency>
<groupId>io.github.timo-a</groupId>
<artifactId>rewrite-misc-recipes</artifactId>
<version>0.0.6</version><!-- see above for the latest version -->
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
Todo: clean up the following parts of the original Readme.
This project is configured to publish to Moderne's open artifact repository (via the publishing
task at the bottom of
the build.gradle.kts
file). If you want to publish elsewhere, you'll want to update that task.
app.moderne.io can draw recipes from the provided repository, as well as from Maven Central.
Note: Running the publish task will not update app.moderne.io, as only Moderne employees can add new recipes. If you want to add your recipe to app.moderne.io, please ask the team in Slack or in Discord.
These other docs might also be useful for you depending on where you want to publish the recipe:
- Sonatype's instructions for publishing to Maven Central
- Gradle's instructions on the Gradle Publishing Plugin.
The .github
directory contains a Github action that will push a snapshot on every successful build.
Run the release action to publish a release version of a recipe.
To build a snapshot, run ./gradlew snapshot publish
to build a snapshot and publish it to Moderne's open artifact repository for inclusion at app.moderne.io.
To build a release, run ./gradlew final publish
to tag a release and publish it to Moderne's open artifact repository for inclusion at app.moderne.io.
We maintain a collection of best practices for writing OpenRewrite recipes. You can apply these recommendations to your recipes by running the following command:
./gradlew rewriteRun -Drewrite.activeRecipe=org.openrewrite.recipes.OpenRewriteBestPractices
or
./mvnw -U org.openrewrite.maven:rewrite-maven-plugin:run -Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-recommendations:RELEASE -Drewrite.activeRecipes=org.openrewrite.recipes.OpenRewriteBestPractices