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

bad option '-target:16' was ignored when compiling scala code with Scala3 library #20180

Closed
Kotori316 opened this issue Mar 15, 2022 · 2 comments

Comments

@Kotori316
Copy link

'16' means Java 16.
The option passed to scala3 compiler contains invalid argument, '-target'

Expected Behavior

'-target:16' should be '-Xtarget:16', as described in here

Current Behavior

'-target:16' is passed to scala compiler and causes warning

Context

In scala 2.13.x, '-target:' option is valid. In scala3, the option is replaced to '-Xtarget:'(https://docs.scala-lang.org/scala3/guides/migration/options-lookup.html).

The option which will be passed to scala compiler is created in these codes.

CompileOptions compileOptions = CompileOptions.create()
.withSources(Iterables.toArray(spec.getSourceFiles(), File.class))
.withClasspath(classpath)
.withScalacOptions(scalacOptions.toArray(new String[0]))
.withClassesDirectory(spec.getDestinationDir())
.withJavacOptions(javacOptions.toArray(new String[0]));

(#19864 seems to change code in ZincScalaCompiler but this issue may not be solved.)

The last withJavacOptions seems to add '-target:16' because it should be passed to javac, but '-target:16' is no longer valid option in scala3.

If you set other parameters such as -Wconf:cat=deprecation:w,any:e, the warning changes to an error and the compilation fails.

Steps to Reproduce

  1. Add Scala 3 to dependency. implementation(group: 'org.scala-lang', name: 'scala3-library_3', version: '3.1.2-RC2')
  2. Set Java version with java.toolchain.languageVersion = JavaLanguageVersion.of(16). In my code, I use Java 16 but the version does not matter.
    1. This issue also reproduced with sourceCompatibility = targetCompatibility = JavaVersion.VERSION_16

repo: https://github.com/Kotori316/gradle-issue-scala-option

Your Environment

  • Gradle: 7.4.1
  • Scala 3.1.2-RC2
  • Java 16
  • Windows 10
@vlushn
Copy link

vlushn commented Oct 3, 2022

Scala 2.13.9 also deprecates the -target option (the correct one is -release now): scala/scala#9982

Workaround for the warning is to silence it by passing "-Wconf:msg=-target is deprecated:silent"

@ljacomet
Copy link
Member

This has been fixed in Gradle 8.0

@ljacomet ljacomet added this to the 8.0 RC1 milestone Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants