Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow producing JDK8 bytecode on newer JDK's #101

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions gradle-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ gradlePlugin {
}
}

tasks.withType(JavaCompile) {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

publishing {
publications.withType(MavenPublication) {
pom {
Expand Down
4 changes: 4 additions & 0 deletions maven-plugin/src/main/maven/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
<groupId>org.apache.pekko</groupId>
<artifactId>pekko-grpc-maven-plugin</artifactId>
<goalPrefix>pekko-grpc</goalPrefix>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
<mojos>
<mojo>
<goal>generate</goal>
Expand Down
16 changes: 16 additions & 0 deletions project/Common.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// javadoc and -target is not valid there.
// javadoc and --release 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",
Expand Down Expand Up @@ -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)
}
Loading