Skip to content

Commit 79ee7f3

Browse files
authored
858 incorporate new parser into core (#868)
* Fix parsing duplicate pom files Added target to default ignorePatterns Refactor method names for test Fix dependency download Fix test by ignoring poms when parsing resources Add logging Replace List with Set to avoid duplicates * Refactoring * Add test proving duplicate parsing of resources * Fix path calculcation to other modules * Back to use shrinkwrap in tests * Replace single-line with multi-line String * Bumped maven-resolver.version * Fix test allow SbmCoreConfig construct ExecutionContext * GH Action * Assert correct classpath * Fix testdata * Cleanup * Disabled test that must be reactivated later * Move JavaSourceUtil to sbm-support-rewrite * Move OpenRewriteTestSupport to test-helper * Back to use shrinkwrap in tests * Add missing test projects * Back to use shrinkwrap in tests * Revamp/move open rewrite test support to test helper (#939) * Revamp/make other modules compile (#943) * Update license header * Add sbm-support-boot module * Add sbm-support-boot module * Module sbm-support-boot compiles * Module sbm-support-jee compiles * Module sbm-support-weblogic compiles * WIP sbm-recipes-jee-to-boot * Make SwapResponseWithResponseEntity compile * Make SwapCacheControl compile * Make SwapStatusForHttpStatus compile * Make fieldsMapping a member * Remove unused member * Make ReplaceMediaType compile Also removes unused member * Make ReplaceResponseEntityBuilder compile * Make sbm-recipes-jee-to-boot compile * Make sbm-recipes-spring-cloud compile * Delete unused classes * Delete unused classes * Make sbm-recipes-boot-upgrade compile * Using shrinkwrap depchain dependency * Replace single line with multi line string * Cleanup properties order
1 parent f48a9eb commit 79ee7f3

File tree

70 files changed

+832
-2260
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+832
-2260
lines changed

components/sbm-core/src/main/java/org/springframework/sbm/java/api/JavaSource.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public interface JavaSource extends ProjectResource {
5959
* <p>
6060
* Be careful if the given {@code Recipe} affects more than the wrapped compilation unit YOU MUST CALL {@link JavaSourceSet.apply(..)}
6161
*/
62-
void apply(Recipe recipe);
62+
void apply(Recipe... recipe);
6363

6464
/**
6565
* Retrieve the {@code Type} declared in this {@code JavaSource}.

components/sbm-core/src/main/java/org/springframework/sbm/java/api/Type.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public interface Type {
5959

6060
Annotation getAnnotation(String fqName);
6161

62-
void apply(Recipe r);
62+
void apply(Recipe... r);
6363

6464
boolean hasMethod(String methodPattern);
6565

components/sbm-core/src/main/java/org/springframework/sbm/java/impl/CompiledType.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ public Annotation getAnnotation(String fqName) {
123123
}
124124

125125
@Override
126-
public void apply(Recipe r) {
127-
126+
public void apply(Recipe... r) {
127+
throw new UnsupportedOperationException();
128128
}
129129

130130
@Override

components/sbm-core/src/main/java/org/springframework/sbm/java/impl/OpenRewriteJavaSource.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ public <T> void replaceLiteral(Class<T> klass, LiteralTransformer<T> t) {
171171
refactoring.refactor(getResource(), new ReplaceLiteralVisitor<>(klass, t));
172172
}
173173

174-
175174
@Override
176175
public String toString() {
177176
return "OpenRewriteJavaSource(" + getAbsolutePath() + ")";
@@ -181,7 +180,7 @@ public String toString() {
181180
* {@inheritDoc}
182181
*/
183182
@Override
184-
public void apply(Recipe recipe) {
183+
public void apply(Recipe... recipe) {
185184
refactoring.refactor(getResource(), recipe);
186185
}
187186

components/sbm-core/src/main/java/org/springframework/sbm/java/impl/OpenRewriteType.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ public String toString() {
295295
}
296296

297297
@Override
298-
public void apply(Recipe r) {
298+
public void apply(Recipe... r) {
299299
refactoring.refactor(rewriteSourceFileHolder, r);
300300
}
301301

components/sbm-openrewrite/src/test/java/org/springframework/sbm/openrewrite/java/RetrieveAnnotationTypeTest.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ public class RetrieveAnnotationTypeTest {
3333
@Test
3434
void retrieveAnnotation() {
3535
String javaSource =
36-
"import javax.ejb.Stateless;\n" +
37-
"@Stateless\n" +
38-
"public class MyClass {" +
39-
"}";
36+
"""
37+
import javax.ejb.Stateless;
38+
@Stateless
39+
public class MyClass { }
40+
""";
4041

4142
// String mavenRepo = System.getProperty("user.home") + "/.m2/repository";
4243
// List<Path> paths = JavaParser.dependenciesFromClasspath("ejb-api");

components/sbm-openrewrite/src/test/java/org/springframework/sbm/support/openrewrite/api/GetImplementsTest.java

+23-20
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,31 @@ public class GetImplementsTest {
2727
@Test
2828
void test() {
2929
String businessInterface =
30-
"package com.example.jee.app.ejb.local;\n" +
31-
"\n" +
32-
"import javax.ejb.Local;\n" +
33-
"\n" +
34-
"@Local\n" +
35-
"public interface ABusinessInterface {\n" +
36-
" String businessMethod();\n" +
37-
"}";
30+
"""
31+
package com.example.jee.app.ejb.local;
32+
33+
import javax.ejb.Local;
34+
35+
@Local
36+
public interface ABusinessInterface {
37+
String businessMethod();
38+
}
39+
""";
3840

3941
String ejb =
40-
"package com.example.jee.app.ejb.local;\n" +
41-
"\n" +
42-
"import javax.ejb.Stateless;\n" +
43-
"\n" +
44-
"@Stateless\n" +
45-
"public class ABean implements ABusinessInterface {\n" +
46-
"\n" +
47-
" @Override\n" +
48-
" public String businessMethod() {\n" +
49-
" return \"A\";\n" +
50-
" }\n" +
51-
"}";
42+
"""
43+
package com.example.jee.app.ejb.local;
44+
45+
import javax.ejb.Stateless;
46+
47+
@Stateless
48+
public class ABean implements ABusinessInterface {
49+
@Override
50+
public String businessMethod() {
51+
return "A";
52+
}
53+
}
54+
""";
5255

5356
List<J.CompilationUnit> compilationUnitsFromStrings = OpenRewriteTestSupport.createCompilationUnitsFromStrings(List.of("javax.ejb:javax.ejb-api:3.2"), businessInterface, ejb);
5457

components/sbm-recipes-boot-upgrade/pom.xml

+3-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
<properties>
3030
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3131
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
32-
<maven.compiler.source>11</maven.compiler.source>
33-
<maven.compiler.target>11</maven.compiler.target>
32+
<maven.compiler.source>17</maven.compiler.source>
33+
<maven.compiler.target>17</maven.compiler.target>
3434
</properties>
3535

3636
<dependencies>
@@ -73,6 +73,7 @@
7373
<dependency>
7474
<groupId>org.springframework.sbm</groupId>
7575
<artifactId>recipe-test-support</artifactId>
76+
<version>${project.version}</version>
7677
<scope>test</scope>
7778
</dependency>
7879
<dependency>

components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/CassandraApplicationPropertiesMove.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public String getDescription() {
3636
}
3737

3838
@Override
39-
protected TreeVisitor<?, ExecutionContext> getVisitor() {
39+
public TreeVisitor<?, ExecutionContext> getVisitor() {
4040

4141
return new PropertiesVisitor<ExecutionContext>() {
4242

components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/CrudRepositoryExtension.java

-110
This file was deleted.

0 commit comments

Comments
 (0)