Skip to content

Commit

Permalink
Load spring-security-web dependency from resources (#519)
Browse files Browse the repository at this point in the history
* Load `spring-security-web` dependency from resources

* Expand use of .classpathWithResources

* Also refresh spring-security-web classpath resources

* Drop unused Spring Batch 4 classpath resource

* Restore spring-batch for tests

---------

Co-authored-by: Tim te Beek <[email protected]>
  • Loading branch information
knutwannheden and timtebeek authored May 19, 2024
1 parent a5911e3 commit e9e3340
Show file tree
Hide file tree
Showing 15 changed files with 9 additions and 8 deletions.
5 changes: 3 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ recipeDependencies {
parserClasspath("org.springframework:spring-web:5.+")
parserClasspath("org.springframework:spring-web:6.+")

parserClasspath("org.springframework:spring-webflux:5.+")
parserClasspath("org.springframework:spring-webmvc:5.+")

parserClasspath("org.springframework.data:spring-data-commons:2.+")
Expand All @@ -87,8 +88,6 @@ recipeDependencies {

parserClasspath("org.springframework.batch:spring-batch-core:4.+")
parserClasspath("org.springframework.batch:spring-batch-core:5.+")

parserClasspath("org.springframework.batch:spring-batch-infrastructure:4.+")
parserClasspath("org.springframework.batch:spring-batch-infrastructure:5.+")

parserClasspath("org.springframework.security:spring-security-config:5.8.+")
Expand Down Expand Up @@ -212,7 +211,9 @@ dependencies {
"testWithSpringBoot_3_0RuntimeOnly"("org.springframework.boot:spring-boot-starter-test:3.0.+")
"testWithSpringBoot_3_0RuntimeOnly"("org.springframework:spring-context:6.0.+")
"testWithSpringBoot_3_0RuntimeOnly"("org.springframework:spring-web:6.0.+")
"testWithSpringBoot_3_0RuntimeOnly"("org.springframework.batch:spring-batch-core:4.+")
"testWithSpringBoot_3_0RuntimeOnly"("org.springframework.batch:spring-batch-core:5.+")
"testWithSpringBoot_3_0RuntimeOnly"("org.springframework.batch:spring-batch-infrastructure:4.+")
"testWithSpringBoot_3_0RuntimeOnly"("org.springframework.batch:spring-batch-infrastructure:5.+")
"testWithSpringBoot_3_0RuntimeOnly"("org.springframework.security:spring-security-core:6.0.+")
"testWithSpringBoot_3_0RuntimeOnly"("org.springframework.security:spring-security-config:6.0.+")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDecl,
cd = JavaTemplate
.builder(JavaType.ShallowClass.build(fullyQualifiedInterfaceName).getClassName())
.imports(fullyQualifiedInterfaceName)
.javaParser(JavaParser.fromJavaVersion().classpath("spring-batch"))
.javaParser(JavaParser.fromJavaVersion().classpathFromResources(ctx, "spring-batch-core-5", "spring-batch-infrastructure-5"))
.build()
.apply(
getCursor(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDecl, Ex
".setUseTrailingSlashMatch(true); }")
.contextSensitive()
.javaParser(JavaParser.fromJavaVersion()
.classpath("spring-webmvc", "spring-context", "spring-web"))
.classpathFromResources(ctx, "spring-webmvc-5", "spring-context-5", "spring-web-5"))
.imports(WEB_MVC_PATH_MATCH_CONFIGURER,
"org.springframework.web.servlet.config.annotation.WebMvcConfigurer",
"org.springframework.context.annotation.Configuration")
Expand All @@ -122,7 +122,7 @@ public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDecl, Ex
".setUseTrailingSlashMatch(true); }")
.contextSensitive()
.javaParser(JavaParser.fromJavaVersion()
.classpath("spring-webflux", "spring-context", "spring-web"))
.classpathFromResources(ctx, "spring-webflux-5", "spring-context-5", "spring-web-5"))
.imports(WEB_FLUX_PATH_MATCH_CONFIGURER,
"org.springframework.web.reactive.config.WebFluxConfigurer",
"org.springframework.context.annotation.Configuration")
Expand Down Expand Up @@ -152,7 +152,7 @@ public J.MethodDeclaration visitMethodDeclaration(J.MethodDeclaration method,
JavaTemplate webMvcTemplate = JavaTemplate.builder("#{any()}.setUseTrailingSlashMatch(true);")
.contextSensitive()
.javaParser(JavaParser.fromJavaVersion()
.classpath("spring-webmvc", "spring-context", "spring-web"))
.classpathFromResources(ctx, "spring-webmvc-5", "spring-context-5", "spring-web-5"))
.imports(WEB_MVC_PATH_MATCH_CONFIGURER,
"org.springframework.web.servlet.config.annotation.WebMvcConfigurer",
"org.springframework.context.annotation.Configuration")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public J.Block visitBlock(J.Block block, ExecutionContext ctx) {
statement = JavaTemplate.builder("#{any()}.setMatchingRequestParameterName(\"continue\");")
.contextSensitive()
.javaParser(JavaParser.fromJavaVersion()
.classpath("spring-security-web"))
.classpathFromResources(ctx, "spring-security-web-6"))
.imports(
"org.springframework.security.web.savedrequest.HttpSessionRequestCache")
.build()
Expand All @@ -100,7 +100,7 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method,
if (isNewHttpSessionRequestCacheExpression(arg)) {
JavaTemplate template = JavaTemplate.builder("new NullRequestCache()")
.javaParser(JavaParser.fromJavaVersion()
.classpath("spring-security-web"))
.classpathFromResources(ctx, "spring-security-web-6"))
.imports(
"org.springframework.security.web.savedrequest.NullRequestCache")
.build();
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit e9e3340

Please sign in to comment.