Skip to content

Commit ead663e

Browse files
Laurens-Wtimtebeek
andauthored
Add lombok-mapstruct-binding during Java 17 migration when both lombok and mapstruct are used (#610)
* Add recipe for adding lombok-mapstruct-binding annotation processor when both mapstruct and lombok are used * Apply suggestions from code review * Fix failing test by rewriting adjusting the MethodType --------- Co-authored-by: Tim te Beek <[email protected]>
1 parent 46abd43 commit ead663e

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

src/main/java/org/openrewrite/java/migrate/lang/MigrateSecurityManagerMulticast.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Execu
5353
J.MethodInvocation m = super.visitMethodInvocation(method, ctx);
5454

5555
if (MULTICAST_METHOD.matches(m) && m.getArguments().size() == 2) {
56-
return m.withArguments(Collections.singletonList(m.getArguments().get(0)));
56+
return m.withArguments(Collections.singletonList(m.getArguments().get(0)))
57+
.withMethodType(m.getMethodType()
58+
.withParameterNames(m.getMethodType().getParameterNames().subList(0, 1))
59+
.withParameterTypes(m.getMethodType().getParameterTypes().subList(0, 1))
60+
);
5761
}
5862
return m;
5963
}

src/main/resources/META-INF/rewrite/java-version-17.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ recipeList:
5151
groupId: com.google.inject
5252
artifactId: guice
5353
newVersion: 5.x
54+
- org.openrewrite.java.migrate.AddLombokMapstructBinding
5455

5556
---
5657
type: specs.openrewrite.org/v1beta/recipe
@@ -285,3 +286,24 @@ recipeList:
285286
methodPattern: 'java.lang.Runtime traceInstructions(boolean)'
286287
- org.openrewrite.java.RemoveMethodInvocations:
287288
methodPattern: 'java.lang.Runtime traceMethodCalls(boolean)'
289+
---
290+
type: specs.openrewrite.org/v1beta/recipe
291+
name: org.openrewrite.java.migrate.AddLombokMapstructBinding
292+
displayName: Add `lombok-mapstruct-binding` when both MapStruct and Lombok are used
293+
description: Add the `lombok-mapstruct-binding` annotation processor as needed when both MapStruct and Lombok are used.
294+
tags:
295+
- java17
296+
preconditions:
297+
- org.openrewrite.java.dependencies.DependencyInsight:
298+
groupIdPattern: org.projectlombok
299+
artifactIdPattern: lombok
300+
- org.openrewrite.java.dependencies.DependencyInsight:
301+
groupIdPattern: org.mapstruct
302+
artifactIdPattern: mapstruct
303+
recipeList:
304+
- org.openrewrite.gradle.AddDependency:
305+
groupId: org.projectlombok
306+
artifactId: lombok-mapstruct-binding
307+
version: 0.2.0
308+
configuration: annotationProcessor
309+
acceptTransitive: false

0 commit comments

Comments
 (0)