-
Notifications
You must be signed in to change notification settings - Fork 529
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
Use Java release option #2825
Closed
Closed
Use Java release option #2825
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
810535b
Use Java release option
vasilmkd cc0215b
Use Scala release option
vasilmkd 92e9fbe
The Java runtime version is also needed for Scala
vasilmkd e6ea24e
Add target flag on Scala 2 and comments
vasilmkd 8877911
Guard with Java runtime version again
vasilmkd b95665e
Use the proper option syntax for Scala 2.12
vasilmkd 8a4f854
Refactored `releaseSettings` into an autoplugin
djspiewak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import sbt._, Keys._ | ||
import sbtspiewak.SpiewakPlugin, SpiewakPlugin.autoImport._ | ||
|
||
object Java8Target extends AutoPlugin { | ||
|
||
override def requires = SpiewakPlugin | ||
override def trigger = allRequirements | ||
|
||
override def projectSettings = Seq( | ||
scalacOptions ++= { | ||
val version = System.getProperty("java.version") | ||
|
||
// The release flag controls what JVM platform APIs are called. We only want JDK 8 APIs | ||
// in order to maintain compability with JDK 8. | ||
val releaseFlag = | ||
if (version.startsWith("1.8")) | ||
Seq() | ||
else | ||
Seq("-release", "8") | ||
|
||
// The target flag is not implied by `-release` on Scala 2. We need to set it explicitly. | ||
// The target flag controls the JVM bytecode version that is output by scalac. | ||
val targetFlag = | ||
if (isDotty.value || version.startsWith("1.8")) | ||
Seq() | ||
else if (scalaVersion.value.startsWith("2.12")) | ||
Seq("-target:jvm-1.8") | ||
else | ||
Seq("-target:8") | ||
|
||
releaseFlag ++ targetFlag | ||
}, | ||
|
||
javacOptions ++= { | ||
val version = System.getProperty("java.version") | ||
if (version.startsWith("1.8")) | ||
Seq() | ||
else | ||
Seq("--release", "8") | ||
}) | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's factor this out as it is repeated:
val isJdk8: Boolean = System.getProperty("java.version").startsWith("1.8")