diff --git a/pom.xml b/pom.xml
index b95f72f8a5c69..1b719883eefd0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2974,7 +2974,7 @@
-deprecation
-feature
-explaintypes
- -target:17
+ -release:17
-Wconf:cat=deprecation:wv,any:e
-Wunused:imports
-Wconf:cat=scaladoc:wv
@@ -3016,7 +3016,7 @@
-source
${java.version}
- -target
+ -release
${java.version}
-Xlint:all,-serial,-path,-try
diff --git a/project/SparkBuild.scala b/project/SparkBuild.scala
index bcfac15ffdde6..c733b86d92b63 100644
--- a/project/SparkBuild.scala
+++ b/project/SparkBuild.scala
@@ -326,7 +326,7 @@ object SparkBuild extends PomBuild {
),
(Compile / scalacOptions) ++= Seq(
- s"-target:${javaVersion.value}",
+ s"-release:${javaVersion.value}",
"-sourcepath", (ThisBuild / baseDirectory).value.getAbsolutePath // Required for relative source links in scaladoc
),