Closed gianluca-nitti closed 11 months ago
@gianluca-nitti support for Scala 3 in Gradle is relatively recent and this plugin doesn't support that yet 😞 . I don't think there is any workaround you could use atm... The main problem which affects both syntactic and semantic rules is this logic to figure out the version of Scala used in your project, which doesn't correctly work for Scala 3.
Thanks for bringing this up though. This is something that would be great to add.
Just one note from the Scalafix docs:
Scala 3.x: Scala 3 support is experimental and many built-in rules are not supported.
I understand, thanks for the information.
[Error] : bad option: -P:semanticdb:sourceroot:/home/gianluca/MYPROJECT/app
The Scala 3 equivalent flag is called -sourceroot
and -semanticdb-targetroot
for -P:semanticdb:targetroot
. One good source of inspiration is the built-in SemanticDB support in sbt https://github.com/sbt/sbt/blob/6c537848266e93674b1de4673c084e8b3f2039df/main/src/main/scala/sbt/plugins/SemanticdbPlugin.scala#L91
I seem to get past the SemanticDB problem but I get parsing errors in files which use certain Scala 3 features such as extension methods.
@marcelocenerine The Scala 3 dialect should be picked up automatically through the --scala-version
setting, which seems to be passed correctly here https://github.com/cosmicsilence/gradle-scalafix/blob/master/src/main/groovy/io/github/cosmicsilence/scalafix/ScalafixTask.groovy#L81 cc/ @mlachkar can maybe confirm. Alternatively, it could be that things are working correctly but you're using Scala 3 syntax that's not yet supported by the Scalameta parser (cc/ @tgodzik)
I think the reason could be that it's using a scalafix artifact for Scala 2.13:
Scalafix supports Scala 3 even if Scalafix itself it still compiled with 2.13. There's on Scala 3 artifact for Scalafix yet.
In fact Scalafix support scala 3, the only thing we don't have yet is ExcplicitResultType
working for scala 3.
@bjaglin can you please confirm ? Thanks
If you need any help, don't hesitate, I would be happy to help!
Thank you for your prompt response and for sharing all this info, @olafurpg & @mlachkar. I hope get started on this soon 👍
Recent scalafix versions support Scala 3. I'm trying to use this plugin in my project which uses Scala 3 and Gradle. Is this possible?
Using release
0.1.13
of the plugin, I get the following behavior:tasks.withType(ScalaCompile) { scalaCompileOptions.additionalParameters = ['-Xsemanticdb'] // for scalafix }
FAILURE: Build failed with an exception.
scalafix.conf
, I seem to get past the SemanticDB problem but I get parsing errors in files which use certain Scala 3 features such as extension methods. After inspecting the output ofgradle check --debug
, I think the reason could be that it's using a scalafix artifact for Scala 2.13: