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

Set -release parameter instead of -target #140

Open
danslapman opened this issue Feb 22, 2024 · 14 comments · May be fixed by #146
Open

Set -release parameter instead of -target #140

danslapman opened this issue Feb 22, 2024 · 14 comments · May be fixed by #146
Labels
Milestone

Comments

@danslapman
Copy link

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...

@prokod
Copy link
Owner

prokod commented Feb 23, 2024

@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

@danslapman
Copy link
Author

See also this bug (similiar situation happened with official graldle scala plugin): gradle/gradle#23962

@prokod prokod added the bug label Feb 27, 2024
@prokod prokod added this to the v0.17.0 milestone Feb 27, 2024
@prokod
Copy link
Owner

prokod commented Feb 27, 2024

@danslapman next plugin release will adhere to release parameter.

@prokod
Copy link
Owner

prokod commented Mar 31, 2024

@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

@danslapman
Copy link
Author

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

@danslapman
Copy link
Author

Tried with scala 2.12.18 & 2.13.12

@prokod
Copy link
Owner

prokod commented Mar 31, 2024

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

@danslapman
Copy link
Author

danslapman commented Mar 31, 2024

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
Copy link
Author

danslapman commented Mar 31, 2024

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)

@prokod
Copy link
Owner

prokod commented Mar 31, 2024

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
Copy link
Author

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
Copy link
Author

I can try other JVM if you wish

@danslapman
Copy link
Author

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)

@prokod
Copy link
Owner

prokod commented Mar 31, 2024

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 prokod linked a pull request Apr 1, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants