This is an automated email from the ASF dual-hosted git repository.

huaxingao pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg.git


The following commit(s) were added to refs/heads/main by this push:
     new b2ede556d9 Build: Add unused imports check for scala code (#14344)
b2ede556d9 is described below

commit b2ede556d91ab593830e76cbffe7b54b51b2eca9
Author: jackylee <[email protected]>
AuthorDate: Tue Oct 21 09:36:34 2025 +0800

    Build: Add unused imports check for scala code (#14344)
---
 baseline.gradle | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/baseline.gradle b/baseline.gradle
index c07d0bda18..151fa40a1a 100644
--- a/baseline.gradle
+++ b/baseline.gradle
@@ -165,4 +165,22 @@ subprojects {
       quiet = false
     }
   }
+
+  pluginManager.withPlugin('scala') {
+    String scalaVersion = System.getProperty("scalaVersion") != null ? 
System.getProperty("scalaVersion") : System.getProperty("defaultScalaVersion")
+    tasks.withType(ScalaCompile).configureEach { scalaCompile ->
+      if (scalaVersion?.startsWith("2.12")) {
+        scalaCompile.scalaCompileOptions.additionalParameters = [
+                // Scala 2.12 does not support treating unused imports as 
errors individually,
+                // so we only enable warnings for unused imports when using 
Scala 2.12.
+                "-Ywarn-unused:imports",
+        ]
+      } else if (scalaVersion?.startsWith("2.13")) {
+        scalaCompile.scalaCompileOptions.additionalParameters = [
+                "-Wconf:cat=unused:error",
+                "-Wunused:imports"
+        ]
+      }
+    }
+  }
 }

Reply via email to