Skip to content

Commit 5c5c1f8

Browse files
committed
Merge branch 'DevfestNantes25'
2 parents 8083e34 + 3844722 commit 5c5c1f8

File tree

8 files changed

+123
-114
lines changed

8 files changed

+123
-114
lines changed

toxic-library-remover/pom.xml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<dependency>
2222
<groupId>org.openrewrite.recipe</groupId>
2323
<artifactId>rewrite-recipe-bom</artifactId>
24-
<version>3.14.1</version>
24+
<version>3.16.0</version>
2525
<type>pom</type>
2626
<scope>import</scope>
2727
</dependency>
@@ -56,6 +56,12 @@
5656
<dependency>
5757
<groupId>org.openrewrite</groupId>
5858
<artifactId>rewrite-java</artifactId>
59+
<exclusions>
60+
<exclusion>
61+
<groupId>org.projectlombok</groupId>
62+
<artifactId>lombok</artifactId>
63+
</exclusion>
64+
</exclusions>
5965
</dependency>
6066
<dependency>
6167
<groupId>org.openrewrite.recipe</groupId>
@@ -76,7 +82,7 @@
7682
<dependency>
7783
<groupId>com.google.errorprone</groupId>
7884
<artifactId>error_prone_core</artifactId>
79-
<version>2.37.0</version>
85+
<version>2.42.0</version>
8086
<scope>provided</scope>
8187
<optional>true</optional>
8288
<exclusions>
@@ -121,7 +127,7 @@
121127
<artifactId>maven-compiler-plugin</artifactId>
122128
<version>3.13.0</version>
123129
<configuration>
124-
<release>21</release>
130+
<release>25</release>
125131
<compilerArgs>
126132
<arg>-parameters</arg>
127133
</compilerArgs>

toxic-library-remover/src/main/java/com/github/jtama/openrewrite/ExtractInterface.java

Lines changed: 89 additions & 93 deletions
Large diffs are not rendered by default.

toxic-library-remover/src/main/java/com/github/jtama/openrewrite/RemoveLogStartInvocations.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ public String getDescription() {
2828
return "Replace any usage of `Timer.logStart()` and `Timer.logEnd()` methods by `@Timed` annotation.";
2929
}
3030

31+
@Override
32+
public boolean causesAnotherCycle() {
33+
return true;
34+
}
35+
3136
@Override
3237
public TreeVisitor<?, ExecutionContext> getVisitor() {
3338
return new Preconditions.Check(new UsesType<>("com.github.jtama.toxic.Timer", true),
@@ -38,7 +43,7 @@ private static class ReplaceCompareVisitor extends JavaIsoVisitor<ExecutionConte
3843

3944
private final MethodMatcher logStartInvocaMatcher = new MethodMatcher("com.github.jtama.toxic.Timer logStart()");
4045
private final MethodMatcher logEndInvocaMatcher = new MethodMatcher("com.github.jtama.toxic.Timer logEnd()");
41-
private final AnnotationMatcher logStartMatcher = new AnnotationMatcher("@io.micrometer.core.annotation.Timed");
46+
private final AnnotationMatcher timedMatcher = new AnnotationMatcher("@io.micrometer.core.annotation.Timed");
4247
private final JavaTemplate annotationTemplate = JavaTemplate.builder("@Timed")
4348
.imports("io.micrometer.core.annotation.Timed")
4449
.javaParser(JavaParser.fromJavaVersion().classpath(JavaParser.runtimeClasspath()))
@@ -54,7 +59,7 @@ public J.MethodDeclaration visitMethodDeclaration(J.MethodDeclaration method, Ex
5459
Cursor cursor = getCursor();
5560
if (cursor.getMessage("appendAnnotation", false)) {
5661
if (md.getLeadingAnnotations().stream()
57-
.noneMatch(logStartMatcher::matches)) {
62+
.noneMatch(timedMatcher::matches)) {
5863
maybeAddImport("io.micrometer.core.annotation.Timed");
5964
md = annotationTemplate.apply(cursor, method.getCoordinates().addAnnotation(Comparator.comparing(J.Annotation::getSimpleName)));
6065
}

toxic-library-remover/src/main/resources/META-INF/rewrite/rewrite.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ recipeList:
2222
- org.openrewrite.maven.RemoveProperty:
2323
propertyName: toxic.version
2424
- com.github.jtama.openrewrite.ExtractInterface:
25-
sourceModule: .
26-
targetModule: .
25+
targetAnnotation: com.github.jtama.toxic.LearnToFly
2726
---
2827
type: specs.openrewrite.org/v1beta/recipe
2928
name: com.github.jtama.openrewrite.VousAllezVoirCeQueVousAllezVoir

toxic-library-remover/src/test/java/com/github/jtama/openrewrite/ExtractInterfaceTest.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class ExtractInterfaceTest implements RewriteTest {
1212

1313
@Override
1414
public void defaults(RecipeSpec spec) {
15-
spec.recipe(new ExtractInterface("bar", "fighter"))
15+
spec.recipe(new ExtractInterface("com.github.jtama.toxic.LearnToFly"))
1616
.parser(JavaParser.fromJavaVersion()
1717
.logCompilationWarningsAndErrors(true)
1818
.classpath("toxic-library"))
@@ -88,8 +88,7 @@ public int compareTo(Integer o) {
8888
return 0;
8989
}
9090
}
91-
""",
92-
spec -> spec.path("foo/bar/src/main/java/tutu/ManualGearCar.java")),
91+
"""),
9392
//language=java
9493
java(null, """
9594
package tutu;
@@ -105,8 +104,7 @@ public interface IManualGearCar extends Comparable<Integer> {
105104
106105
@Override int compareTo(Integer o);
107106
}
108-
""",
109-
spec -> spec.path("foo/fighter/src/main/java/tutu/IManualGearCar.java")
107+
"""
110108
)
111109
);
112110
}
@@ -165,8 +163,7 @@ public void doSomething(String param) {
165163
// To something
166164
}
167165
}
168-
""",
169-
spec -> spec.path("foo/bar/src/main/java/tutu/ManualGearCar.java")),
166+
"""),
170167
//language=java
171168
java(null, """
172169
package tutu;
@@ -180,8 +177,7 @@ public interface IManualGearCar {
180177
181178
void doSomething(String param);
182179
}
183-
""",
184-
spec -> spec.path("foo/fighter/src/main/java/tutu/IManualGearCar.java")
180+
"""
185181
)
186182
);
187183
}

toxic-library-user/README.adoc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
[source%linenums, bash]
1+
[source%linenums, console]
2+
----
3+
mvn -U org.openrewrite.maven:rewrite-maven-plugin:run \
4+
-Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-testing-frameworks:RELEASE \
5+
-Drewrite.activeRecipes=org.openrewrite.java.testing.junit5.JUnit4to5Migration
6+
----
7+
8+
[source%linenums, console]
29
----
310
mvn -U org.openrewrite.maven:rewrite-maven-plugin:run \
411
-Drewrite.recipeArtifactCoordinates=com.github.jtama:toxic-library-remover:1.0.1-SNAPSHOT \

toxic-library-user/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
<version>1.0.1-SNAPSHOT</version>
1010

1111
<properties>
12-
<maven.compiler.source>17</maven.compiler.source>
13-
<maven.compiler.target>17</maven.compiler.target>
12+
<maven.compiler.source>25</maven.compiler.source>
13+
<maven.compiler.target>25</maven.compiler.target>
1414
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1515
<compiler-plugin.version>3.8.1</compiler-plugin.version>
1616
<quarkus.version>3.17.3</quarkus.version>

toxic-library/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
<version>19.666.45-RC18-FINAL</version>
1010

1111
<properties>
12-
<maven.compiler.source>21</maven.compiler.source>
13-
<maven.compiler.target>21</maven.compiler.target>
12+
<maven.compiler.source>25</maven.compiler.source>
13+
<maven.compiler.target>25</maven.compiler.target>
1414
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1515
</properties>
1616

0 commit comments

Comments
 (0)