From da4362111aa931b9189cf7ab092756c839b49fda Mon Sep 17 00:00:00 2001 From: paulvas Date: Mon, 12 Jan 2026 12:58:59 -0500 Subject: [PATCH] Fix: Enforce compiler warnings in oauth2-core To prevent future compiler warnings from being introduced, this change applies the `compile-warnings-error` plugin to the `spring-security-oauth2-core` module. This ensures that any new warnings will fail the build, maintaining code quality and preventing warning accumulation. Fixes: gh-18434 Signed-off-by: Pavel Vassiliev Signed-off-by: paulvas --- buildSrc/build.gradle | 4 ++++ .../src/main/groovy/compile-warnings-error.groovy | 15 +++++++++++++++ .../spring-security-oauth2-core.gradle | 4 ++++ 3 files changed, 23 insertions(+) create mode 100644 buildSrc/src/main/groovy/compile-warnings-error.groovy diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index da60b4197b..aff57d3a1e 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -52,6 +52,10 @@ gradlePlugin { id = "org.springframework.security.check-expected-branch-version" implementationClass = "org.springframework.security.CheckExpectedBranchVersionPlugin" } + compileWarningsError { + id = "compile-warnings-error" + implementationClass = "CompileWarningsErrorPlugin" + } } } diff --git a/buildSrc/src/main/groovy/compile-warnings-error.groovy b/buildSrc/src/main/groovy/compile-warnings-error.groovy new file mode 100644 index 0000000000..f2d073de3c --- /dev/null +++ b/buildSrc/src/main/groovy/compile-warnings-error.groovy @@ -0,0 +1,15 @@ +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.tasks.compile.JavaCompile +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +class CompileWarningsErrorPlugin implements Plugin { + void apply(Project project) { + project.tasks.withType(JavaCompile) { + options.compilerArgs += "-Werror" + } + project.tasks.withType(KotlinCompile) { + kotlinOptions.allWarningsAsErrors = true + } + } +} \ No newline at end of file diff --git a/oauth2/oauth2-core/spring-security-oauth2-core.gradle b/oauth2/oauth2-core/spring-security-oauth2-core.gradle index c163adfcca..a3c3a2f4e9 100644 --- a/oauth2/oauth2-core/spring-security-oauth2-core.gradle +++ b/oauth2/oauth2-core/spring-security-oauth2-core.gradle @@ -1,3 +1,7 @@ +plugins { + id 'compile-warnings-error' +} + apply plugin: 'io.spring.convention.spring-module' dependencies {