gradle-crossbuild-scala icon indicating copy to clipboard operation
gradle-crossbuild-scala copied to clipboard

Set `-release` parameter instead of `-target`

Open danslapman opened this issue 1 year ago • 14 comments

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 avatar Feb 22 '24 23:02 danslapman

@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

prokod avatar Feb 23 '24 11:02 prokod

See also this bug (similiar situation happened with official graldle scala plugin): https://github.com/gradle/gradle/issues/23962

danslapman avatar Feb 24 '24 19:02 danslapman

@danslapman next plugin release will adhere to release parameter.

prokod avatar Feb 27 '24 10:02 prokod

@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

prokod avatar Mar 31 '24 13:03 prokod

Hi @prokod! Just cheked - error does not happen on compileScala, only on crossBuildXXXCompileScala

danslapman avatar Mar 31 '24 13:03 danslapman

Tried with scala 2.12.18 & 2.13.12

danslapman avatar Mar 31 '24 13:03 danslapman

@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 ?

prokod avatar Mar 31 '24 17:03 prokod

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

danslapman avatar Mar 31 '24 17:03 danslapman

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)

danslapman avatar Mar 31 '24 17:03 danslapman

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

prokod avatar Mar 31 '24 17:03 prokod

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

danslapman avatar Mar 31 '24 17:03 danslapman

I can try other JVM if you wish

danslapman avatar Mar 31 '24 17:03 danslapman

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)

danslapman avatar Mar 31 '24 18:03 danslapman

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

prokod avatar Mar 31 '24 19:03 prokod

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: @.***>

prokod avatar Jul 30 '24 05:07 prokod