diff --git a/gradle-plugin/build.gradle b/gradle-plugin/build.gradle index 4946cfed..2ee21ed5 100644 --- a/gradle-plugin/build.gradle +++ b/gradle-plugin/build.gradle @@ -44,6 +44,11 @@ gradlePlugin { } } +tasks.withType(JavaCompile) { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} + publishing { publications.withType(MavenPublication) { pom { diff --git a/maven-plugin/src/main/maven/plugin.xml b/maven-plugin/src/main/maven/plugin.xml index 00f9767f..c0b98a3b 100644 --- a/maven-plugin/src/main/maven/plugin.xml +++ b/maven-plugin/src/main/maven/plugin.xml @@ -6,6 +6,10 @@ org.apache.pekko pekko-grpc-maven-plugin pekko-grpc + + 1.8 + 1.8 + generate diff --git a/project/Common.scala b/project/Common.scala index ea80c511..02071be7 100644 --- a/project/Common.scala +++ b/project/Common.scala @@ -79,6 +79,13 @@ object Common extends AutoPlugin { "-Wconf:msg=unused import:silent", "-Wconf:cat=feature:silent")), Compile / console / scalacOptions ~= (_.filterNot(consoleDisabledOptions.contains)), + // restrict to 'compile' scope because otherwise it is also passed to + // javadoc and -target is not valid there. + // https://github.com/sbt/sbt/issues/1785 + Compile / compile / javacOptions ++= + onlyAfterJdk8("--release", "8"), + Compile / compile / scalacOptions ++= + onlyAfterJdk8("-release", "8"), javacOptions ++= List("-Xlint:unchecked", "-Xlint:deprecation"), Compile / doc / scalacOptions := scalacOptions.value ++ Seq( "-doc-title", @@ -110,6 +117,15 @@ object Common extends AutoPlugin { crossScalaVersions := Seq(scala212, scala213, scala3), mimaReportSignatureProblems := true) + val specificationVersion: String = sys.props("java.specification.version") + + def isJdk8: Boolean = + VersionNumber(specificationVersion).matchesSemVer(SemanticSelector(s"=1.8")) + + def onlyOnJdk8[T](values: T*): Seq[T] = if (isJdk8) values else Seq.empty[T] + + def onlyAfterJdk8[T](values: T*): Seq[T] = if (isJdk8) Seq.empty[T] else values + override lazy val buildSettings = Seq( dynverSonatypeSnapshots := true) }