gradle-crossbuild-scala
gradle-crossbuild-scala copied to clipboard
Set `-release` parameter instead of `-target`
Hello! I just updated my template repository for scala and found that now gradle crossBuildAssemble fails with
> Task :libraryA:compileCrossBuildV213Scala FAILED
[Error] : -target is deprecated: Use -release instead to compile against the correct platform API.
one error found
I found that -target is unconditionaly set by tuneCrossBuildScalaCompileTask. Looks like the name of that argument must be aware of concrete version of scalac... Without that plugin is unusable with latest scalac versions
Personally I'd also like to have something like targetCompatibility.strategy = 'none' - from sbt user perspective silently setting scalac arguments looks kinda strange...
@danslapman The current plugin was tested up to certain scalac versions. Without the intervention in the calss mentioned, gradle, up to the version I have tested did not do a good job of picking the correct target flag (refer please to the readme of the plugin to see what the plugin was tested against). Maybe I need to revisit it now that downstream progress was made on scalac and gradle fronts. Let me add some new test cases to be able to get to the bottom of that. I will revisit the opinionated approach while I am at it. Thanks for the valuable feedback
See also this bug (similiar situation happened with official graldle scala plugin): https://github.com/gradle/gradle/issues/23962
@danslapman next plugin release will adhere to release parameter.
@danslapman just created a test able to reproduce the issue. Can you confirm this error happens when running task :compileScala ? If so, this error actually happens on compileScala task that is not manipulated with tuneCrossBuildScalaCompileTask - the default one (as opposed to crossBuildXXXCompileScala).
I will try to also address that in the plugin either in code or documentation
Hi @prokod! Just cheked - error does not happen on compileScala, only on crossBuildXXXCompileScala
Tried with scala 2.12.18 & 2.13.12
@danslapman so i took your template repo and turned it into a test
When running gradle build or gradle crossBuildAssemble
I observe the failure but ...
If I comment out this part in your example
tasks.withType<ScalaCompile>().configureEach {
val plugins = File("\$buildDir/scalac-plugins").listFiles()?.let {
"-Xplugin:" + it.joinToString(",")
}
scalaCompileOptions.additionalParameters =
listOf("-release", "11", "-feature", "-Xfatal-warnings") + listOfNotNull(plugins)
}
No error is thrown while compiling
In this build.gradle block, you force -release=11 which is not compatible with later scala 2.12/2.13
May I ask the reason for this block ?
My bad, I added this setting years ago and missed it during the last update. I just removed -release, but the error still happens for me on gradle crossBuildV213Classes, but not on gradle compileScala
My Java version (for your reference):
java version "21.0.2" 2024-01-16 LTS
Java(TM) SE Runtime Environment Oracle GraalVM 21.0.2+13.1 (build 21.0.2+13-LTS-jvmci-23.1-b30)
Java HotSpot(TM) 64-Bit Server VM Oracle GraalVM 21.0.2+13.1 (build 21.0.2+13-LTS-jvmci-23.1-b30, mixed mode, sharing)
Would you be able to share gradle log from following run gradle crossBuildAssemble ? it might help narrow it down further, In the mean time I will see about testing with java 21
danslapman@danslapman-dev gradle-scala-template % gradle crossBuildAssemble
To honour the JVM settings for this build a single-use Daemon process will be forked. For more on this, please refer to https://docs.gradle.org/8.5/userguide/gradle_daemon.html#sec:disabling_the_daemon in the Gradle documentation.
Daemon will be stopped at the end of the build
> Task :libraryA:compileCrossBuildV213Scala FAILED
[Error] : -target is deprecated: Use -release instead to compile against the correct platform API.
one error found
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':libraryA:compileCrossBuildV213Scala'.
> Compilation failed
* Try:
> Run with --info option to get more log output.
> Run with --scan to get full insights.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.5/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
BUILD FAILED in 10s
3 actionable tasks: 3 executed
I can try other JVM if you wish
Got same results on
java version "17.0.10" 2024-01-16 LTS
Java(TM) SE Runtime Environment Oracle GraalVM 17.0.10+11.1 (build 17.0.10+11-LTS-jvmci-23.0-b27)
Java HotSpot(TM) 64-Bit Server VM Oracle GraalVM 17.0.10+11.1 (build 17.0.10+11-LTS-jvmci-23.0-b27, mixed mode, sharing)
Ok So I have managed to run the test with java 17. Interesting enough I got the same error (given that the compiler is set with -Xfatal-warnings) but for scala 2.12 (The compiler behavior for scala 2.12 changed from 2.12.17 onward and incl.)
The scala 2.13 issue you are facing I have already fixed in the feature branch before hand.
All in all soon to be released 0.17.0 fixes this issue of yours as it seems from my tests
Hi there, the next version will be out in a week or two. The
-Xfatal-warnings is only one aspect, the upcoming release will handle
this and other related compilation incompatabilities better.
Thank you
On Mon, Jul 29, 2024, 05:30 Chen Jian @.***> wrote:
Hi, when can 0.17.0 be released? This bug is blocking app compilation if -Xfatal-warnings is turned on
— Reply to this email directly, view it on GitHub https://github.com/prokod/gradle-crossbuild-scala/issues/140#issuecomment-2254873207, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGWGZQGKQHHSNF47BDTRBLZOWZNFAVCNFSM6AAAAABDV2U36CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENJUHA3TGMRQG4 . You are receiving this because you were mentioned.Message ID: @.***>