Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .run/InlineMethodCallsRecipeGenerator.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="InlineMethodCallsRecipeGenerator" type="Application" factoryName="Application">
<option name="MAIN_CLASS_NAME" value="org.openrewrite.java.internal.parser.InlineMethodCallsRecipeGenerator" />
<module name="rewrite-logging-frameworks.main" />
<option name="PROGRAM_PARAMETERS" value="src/main/resources/META-INF/rewrite/classpath.tsv.gz src/main/resources/META-INF/rewrite/inline-logging-methods.yml org.openrewrite.java.logging.log4j.InlineMethods" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
Binary file modified src/main/resources/META-INF/rewrite/classpath.tsv.gz
Binary file not shown.
55 changes: 55 additions & 0 deletions src/main/resources/META-INF/rewrite/inline-logging-methods.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Copyright 2025 the original author or authors.
# <p>
# 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
# <p>
# https://docs.moderne.io/licensing/moderne-source-available-license
# <p>
# 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'
1 change: 1 addition & 0 deletions src/main/resources/META-INF/rewrite/log4j.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}

Expand Down