Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lombok-mapstruct-binding during Java 17 migration when both lombok and mapstruct are used #610

Merged
merged 4 commits into from
Nov 21, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Execu
J.MethodInvocation m = super.visitMethodInvocation(method, ctx);

if (MULTICAST_METHOD.matches(m) && m.getArguments().size() == 2) {
return m.withArguments(Collections.singletonList(m.getArguments().get(0)));
return m.withArguments(Collections.singletonList(m.getArguments().get(0)))
.withMethodType(m.getMethodType()
.withParameterNames(m.getMethodType().getParameterNames().subList(0, 1))
.withParameterTypes(m.getMethodType().getParameterTypes().subList(0, 1))
);
}
return m;
}
Expand Down
22 changes: 22 additions & 0 deletions src/main/resources/META-INF/rewrite/java-version-17.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ recipeList:
groupId: com.google.inject
artifactId: guice
newVersion: 5.x
- org.openrewrite.java.migrate.AddLombokMapstructBinding

---
type: specs.openrewrite.org/v1beta/recipe
Expand Down Expand Up @@ -285,3 +286,24 @@ recipeList:
methodPattern: 'java.lang.Runtime traceInstructions(boolean)'
- org.openrewrite.java.RemoveMethodInvocations:
methodPattern: 'java.lang.Runtime traceMethodCalls(boolean)'
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.migrate.AddLombokMapstructBinding
displayName: Add `lombok-mapstruct-binding` when both MapStruct and Lombok are used
description: Add the `lombok-mapstruct-binding` annotation processor as needed when both MapStruct and Lombok are used.
tags:
- java17
preconditions:
- org.openrewrite.java.dependencies.DependencyInsight:
groupIdPattern: org.projectlombok
artifactIdPattern: lombok
- org.openrewrite.java.dependencies.DependencyInsight:
groupIdPattern: org.mapstruct
artifactIdPattern: mapstruct
recipeList:
- org.openrewrite.gradle.AddDependency:
groupId: org.projectlombok
artifactId: lombok-mapstruct-binding
version: 0.2.0
configuration: annotationProcessor
acceptTransitive: false