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

Add javaOutputVersion to ScalacOptions for scala >= 3.1.2 #122

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ object ScalaVersion {
val V2_13_9 = ScalaVersion(2, 13, 9)
val V3_0_0 = ScalaVersion(3, 0, 0)
val V3_1_0 = ScalaVersion(3, 1, 0)
val V3_1_2 = ScalaVersion(3, 1, 2)
val V3_3_0 = ScalaVersion(3, 3, 0)
val V3_3_1 = ScalaVersion(3, 3, 1)
val V3_3_3 = ScalaVersion(3, 3, 3)
Expand Down
14 changes: 14 additions & 0 deletions lib/src/main/scala/org/typelevel/scalacoptions/ScalacOptions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,25 @@ private[scalacoptions] trait ScalacOptions {
val feature =
ScalacOption("-feature", _ => true)

/** Compile for a specific version of the Java platform. Supported targets: 8, 9, ..., 17, 18.
*
* The java-output-version flag is supported only on JDK 9 and above, since it relies on the
* functionality provided in
* [[http://openjdk.java.net/jeps/247 JEP-247: Compile for Older Platform Versions]].
*/
def javaOutputVersion(version: String) =
ScalacOption(
"-java-output-version",
List(version),
version => JavaMajorVersion.javaMajorVersion >= 9 && version >= V3_1_2
)

/** Compile for a specific version of the Java platform. Supported targets: 8, 9, ..., 17, 18.
*
* The release flag is supported only on JDK 9 and above, since it relies on the functionality
* provided in [[http://openjdk.java.net/jeps/247 JEP-247: Compile for Older Platform Versions]].
*/
@deprecated("Use javaOutputVersion instead", "3.1.2")
Copy link
Contributor

Choose a reason for hiding this comment

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

This need to be removed and instead the line below:

version => JavaMajorVersion.javaMajorVersion >= 9 && version >= V2_12_5

needs to be changed to:

version => JavaMajorVersion.javaMajorVersion >= 9 && version >= V2_12_5 && version < V3_1_2

Copy link
Contributor

Choose a reason for hiding this comment

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

Or maybe not since there is an alias for backcompat?

Copy link
Author

Choose a reason for hiding this comment

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

Thank you, I've made those changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

@satorg No rush but maybe we could look into this before cutting a release?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry it should be:

version => JavaMajorVersion.javaMajorVersion >= 9 && version.between(V2_12_5, V3_1_2)

But again not sure if we should disable it yet because that flag is still working. Any opinion @TonioGela @satorg @armanbilge?

Copy link
Author

Choose a reason for hiding this comment

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

ok fixed, but I take your point about disabling or not.

Copy link
Member

Choose a reason for hiding this comment

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

I think if We disable this for scala > 3.1.2, it may cause some suprise for users as it takes no effect. So, I think We should not disable it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, let's keep it then. People will get the warning if there is one and we can remove it once the compiler removes it.

def release(version: String) =
ScalacOption(
"-release",
Expand Down