diff --git a/.run/InlineMethodCallsRecipeGenerator.run.xml b/.run/InlineMethodCallsRecipeGenerator.run.xml
new file mode 100644
index 00000000..3a0df113
--- /dev/null
+++ b/.run/InlineMethodCallsRecipeGenerator.run.xml
@@ -0,0 +1,10 @@
+
+# Licensed under the Moderne Source Available License (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +#
+# https://docs.moderne.io/licensing/moderne-source-available-license +#
+# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated InlineMe recipes from TypeTable +# + +type: specs.openrewrite.org/v1beta/recipe +name: org.openrewrite.java.logging.log4j.InlineMethods +displayName: Inline methods annotated with `@InlineMe` +description: >- + Automatically generated recipes to inline method calls based on `@InlineMe` annotations + discovered in the type table. +recipeList: + + # From org.apache.logging.log4j:log4j-api:2.25.2 + - org.openrewrite.java.InlineMethodCalls: + methodPattern: 'org.apache.logging.log4j.message.StructuredDataId StructuredDataId(java.lang.String, int, java.lang.String[], java.lang.String[])' + replacement: 'this(name, String.valueOf(enterpriseNumber), required, optional)' + classpathFromResources: + - 'log4j-api-2.25.2' + - org.openrewrite.java.InlineMethodCalls: + methodPattern: 'org.apache.logging.log4j.message.StructuredDataId StructuredDataId(java.lang.String, int, java.lang.String[], java.lang.String[], int)' + replacement: 'this(name, String.valueOf(enterpriseNumber), required, optional, maxLength)' + classpathFromResources: + - 'log4j-api-2.25.2' + - org.openrewrite.java.InlineMethodCalls: + methodPattern: 'org.apache.logging.log4j.message.StructuredDataId makeId(java.lang.String, int)' + replacement: 'this.makeId(defaultId, String.valueOf(anEnterpriseNumber))' + classpathFromResources: + - 'log4j-api-2.25.2' + - org.openrewrite.java.InlineMethodCalls: + methodPattern: 'org.apache.logging.log4j.message.ParameterizedMessage ParameterizedMessage(java.lang.String, java.lang.String[], java.lang.Throwable)' + replacement: 'this(pattern, Arrays.stream(args).toArray(Object[]::new), throwable)' + imports: + - 'java.util.Arrays' + classpathFromResources: + - 'log4j-api-2.25.2' + - org.openrewrite.java.InlineMethodCalls: + methodPattern: 'org.apache.logging.log4j.MarkerManager getMarker(java.lang.String, org.apache.logging.log4j.Marker)' + replacement: 'MarkerManager.getMarker(name).addParents(parent)' + imports: + - 'org.apache.logging.log4j.MarkerManager' + classpathFromResources: + - 'log4j-api-2.25.2' diff --git a/src/main/resources/META-INF/rewrite/log4j.yml b/src/main/resources/META-INF/rewrite/log4j.yml index 281a171f..43e8f87e 100644 --- a/src/main/resources/META-INF/rewrite/log4j.yml +++ b/src/main/resources/META-INF/rewrite/log4j.yml @@ -137,6 +137,7 @@ recipeList: newArtifactId: log4j-slf4j-impl newVersion: 2.x - org.openrewrite.java.logging.log4j.UpgradeLog4J2DependencyVersion + - org.openrewrite.java.logging.log4j.InlineMethods --- type: specs.openrewrite.org/v1beta/recipe diff --git a/src/test/java/org/openrewrite/java/logging/log4j/Log4j1ToLog4j2Test.java b/src/test/java/org/openrewrite/java/logging/log4j/Log4j1ToLog4j2Test.java index c0316b8b..ee606c7a 100644 --- a/src/test/java/org/openrewrite/java/logging/log4j/Log4j1ToLog4j2Test.java +++ b/src/test/java/org/openrewrite/java/logging/log4j/Log4j1ToLog4j2Test.java @@ -34,7 +34,7 @@ class Log4j1ToLog4j2Test implements RewriteTest { @Override public void defaults(RecipeSpec spec) { - spec.recipeFromResource("/META-INF/rewrite/log4j.yml", "org.openrewrite.java.logging.log4j.Log4j1ToLog4j2") + spec.recipeFromResources("org.openrewrite.java.logging.log4j.Log4j1ToLog4j2") .parser(JavaParser.fromJavaVersion().classpathFromResources(new InMemoryExecutionContext(), "log4j-1")); }