Use lomboks log annotation instead of defining the field yourself
io.github.timoa.lombok.log.ConvertAnyLog
Applies all recipes that replace logger declarations with class level annotations. If you know which logger framework is in use you can simply use the specific recipe. If, for some reason you need to cover all frameworks you can use this recipe.
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.log.ConvertAnyLog</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.
Shell
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.log.ConvertAnyLog
-
Add the following to your
build.gradle
file:build.gradleplugins { id("org.openrewrite.rewrite") version("6.25.1") } rewrite { activeRecipe("io.github.timoa.lombok.log.ConvertAnyLog") } 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.log.ConvertAnyLog") } afterEvaluate { if (repositories.isEmpty()) { repositories { mavenCentral() } } } }
-
Run
gradle --init-script init.gradle rewriteRun
to run the recipe.
Definition
-
Recipe List
-
Yaml Recipe List
---
type: specs.openrewrite.org/v1beta/recipe
name: io.github.timoa.lombok.log.ConvertAnyLog
displayName: Use lomboks log annotation instead of defining the field yourself
description: >-
Applies all recipes that replace logger declarations with class level annotations.
If you know which logger framework is in use you can simply use the specific recipe.
If, for some reason you need to cover all frameworks you can use this recipe.
recipeList:
- io.github.timoa.lombok.log.ConvertSlf4j
- io.github.timoa.lombok.log.ConvertCommons
- io.github.timoa.lombok.log.ConvertLog4j2
- io.github.timoa.lombok.log.ConvertJBoss
- io.github.timoa.lombok.log.ConvertUtilLog