Convert setter methods to annotations
io.github.timoa.lombok.ConvertSetter
Convert trivial setter methods to @Setter
annotations on their respective fields.
Limitations:
-
Does not add a dependency to Lombok, users need to do that manually
-
Ignores fields that are declared on the same line as others, e.g. `private int foo, bar;Users who have such fields are advised to separate them beforehand with org.openrewrite.staticanalysis.MultipleVariableDeclaration.
-
Does not offer any of the configuration keys listed in https://projectlombok.org/features/GetterSetter.
Usage
-
Maven POM
-
Maven Command Line
-
Gradle
-
Gradle init script
-
Add the following to your pom.xml file:
pom.xml<project> <build> <plugins> <plugin> <groupId>org.openrewrite.maven</groupId> <artifactId>rewrite-maven-plugin</artifactId> <version>5.42.2</version> <configuration> <activeRecipes> <recipe>io.github.timoa.lombok.ConvertSetter</recipe> </activeRecipes> </configuration> <dependencies> <dependency> <groupId>io.github.timo-a</groupId> <artifactId>rewrite-recipe-starter</artifactId> <version>0.4.2</version> </dependency> </dependencies> </plugin> </plugins> </build> </project>
-
Run
mvn rewrite:run
to run the recipe.
You will need to have Maven installed on your machine before you can run the following command.
mvn -U org.openrewrite.maven:rewrite-maven-plugin:run -Drewrite.recipeArtifactCoordinates=io.github.timo-a:rewrite-recipe-starter:RELEASE -Drewrite.activeRecipes=io.github.timoa.lombok.ConvertSetter
-
Add the following to your
build.gradle
file:build.gradleplugins { id("org.openrewrite.rewrite") version("6.25.1") } rewrite { activeRecipe("io.github.timoa.lombok.ConvertSetter") } repositories { mavenCentral() } dependencies { rewrite("io.github.timo-a:rewrite-recipe-starter:0.4.2") }
-
Run
gradle rewriteRun
to run the recipe.
-
Create a file named
init.gradle
in the root of your project.init.gradleinitscript { repositories { maven { url "https://plugins.gradle.org/m2" } } dependencies { classpath("org.openrewrite:plugin:6.25.1") } } rootProject { plugins.apply(org.openrewrite.gradle.RewritePlugin) dependencies { rewrite("io.github.timo-a:rewrite-recipe-starter:0.4.2") } rewrite { activeRecipe("io.github.timoa.lombok.ConvertSetter") } afterEvaluate { if (repositories.isEmpty()) { repositories { mavenCentral() } } } }
-
Run
gradle --init-script init.gradle rewriteRun
to run the recipe.