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

Scala 3 support #143

Closed
carlosedp opened this issue Jan 16, 2024 · 11 comments
Closed

Scala 3 support #143

carlosedp opened this issue Jan 16, 2024 · 11 comments

Comments

@carlosedp
Copy link

Are there plans to support Scala 3?

I tried with:

      <plugin>
        <groupId>io.github.evis</groupId>
        <artifactId>scalafix-maven-plugin_2.13</artifactId>
        <version>0.1.8_0.11.0</version>
        <configuration>
          <commandLineArgs>--scala-version=${scala.version}</commandLineArgs>
        </configuration>
      </plugin>

But still got syntax errors from running on a Scala 3 project using the new syntax like:

[INFO] --- scalafix:0.1.8_0.11.0:scalafix (default-cli) @ scala3-quarkus-quickstart ---
[INFO] Processing[main]: /Users/cdepaula/repos/scala/scala3-quarkus-quickstart/src/main/scala
[INFO] Processing[test]: /Users/cdepaula/repos/scala/scala3-quarkus-quickstart/src/test/scala
info: Processing ( 0/13) /Users/cdepaula/repos/scala/scala3-quarkus-quickstart/src/main/scala/org/acme/GreetingResource.scala
/Users/cdepaula/repos/scala/scala3-quarkus-quickstart/src/main/scala/org/acme/GreetingResource.scala:7:23: error: ; expected but : found
class GreetingResource:
                      ^
info: Processing ( 1/13) /Users/cdepaula/repos/scala/scala3-quarkus-quickstart/src/main/scala/org/acme/kafka/ArticleModels.scala
/Users/cdepaula/repos/scala/scala3-quarkus-quickstart/src/main/scala/org/acme/kafka/ArticleModels.scala:9:4: error: ; expected but : found
  ):
@carlosedp
Copy link
Author

Hi @evis .... any tips on how I can override the Scala version used by Scalafix?

Running with debug, I see that it picks the cmdline flag but doesn't use it (on the arguments):

[DEBUG] Loading mojo io.github.evis:scalafix-maven-plugin_2.13:0.1.8_0.11.0:scalafix from plugin realm ClassRealm[plugin>io.github.evis:scalafix-maven-plugin_2.13:0.1.8_0.11.0, parent: java.net.URLClassLoader@255316f2]
[DEBUG] Configuring mojo execution 'io.github.evis:scalafix-maven-plugin_2.13:0.1.8_0.11.0:scalafix:default-cli' with basic configurator -->
[DEBUG]   (f) commandLineArgs = [--scala-version=3.3.3]
[DEBUG]   (f) mainSourceDirectories = []
[DEBUG]   (f) mode = IN_PLACE
[DEBUG]   (f) project = MavenProject: org.acme:scala3-quarkus-quickstart:1.0.0-SNAPSHOT @ /Users/cdepaula/repos/scala/scala3-quarkus-quickstart/pom.xml
[DEBUG]   (f) skip = false
[DEBUG]   (f) skipMain = false
[DEBUG]   (f) skipTest = false
[DEBUG]   (f) testSourceDirectories = []
[DEBUG] -- end configuration --
[INFO] Processing[main]: /Users/cdepaula/repos/scala/scala3-quarkus-quickstart/src/main/scala
[INFO] Processing[test]: /Users/cdepaula/repos/scala/scala3-quarkus-quickstart/src/test/scala
[DEBUG] arguments = Right(ScalafixArgumentsImpl({"rules": [], "files": ["/Users/cdepaula/repos/scala/scala3-quarkus-quickstart/src/main/scala", "/Users/cdepaula/repos/scala/scala3-quarkus-quickstart/src/test/scala"], "config": null, "check": false, "stdout": false, "diff": false, "diffBase": null, "syntactic": false, "triggered": false, "verbose": false, "help": false, "version": false, "classpath": "<classpath>", "sourceroot": null, "semanticdbTargetroots": [], "autoClasspath": false, "autoClasspathRoots": [], "scalacOptions": ["-Wunused:all", "-feature", "-deprecation", "-Ysemanticdb"], "scalaVersion": "2.13.13", "bash": false, "zsh": false, "exclude": [], "toolClasspath": "<classloader>", "charset": "UTF-8", "noSysExit": false, "noStaleSemanticdb": false, "settings": {}, "outFrom": null, "outTo": null, "autoSuppressLinterErrors": false, "cwd": "/Users/cdepaula/repos/scala/scala3-quarkus-quickstart", "nonInteractive": false, "out": "<stdout>", "ls": "find", "callback": "scalafix.internal.interfaces.MainCallbackImpl$$anon$1@7db47323"}))
...

@evis
Copy link
Owner

evis commented Apr 2, 2024

@carlosedp could you give me an example of Scala 3 project built with Maven? I wasn't able to quickly create compiling project from scratch.

Sorry for such a long delay in responding :(

@carlosedp
Copy link
Author

Hi Evgeny, thanks for your time! I've set a sample project with Scalafix and Scalafmt using Scala 3 at https://github.com/carlosedp/scala3-maven.

A couple of things I've noticed:

  • I tried overriding the command line arguments as you can see in the pom.xml but it didn't do anything (tried with -Dscalafix.command.line.args=... as well but got the same results.
  • When I try to run the scalafix:scalafix goal, I get error: SemanticDB not found: src/main/scala/org/acme/Hello.scala... I have to do a ./mvnw clean compile test-compile before running that goal (since I have -Ysemanticdb in my scala plugin args). It would be nice if scalafix could override this in some way and compile it with semanticDB before.

@bjaglin
Copy link
Contributor

bjaglin commented Apr 2, 2024

I haven't run anything as I don't know/use maven, but it looks like

(which is likely 2.13 since Scala 3 doesn't have its own standard library) takes precedence over your custom CLI args, given

@evis
Copy link
Owner

evis commented Apr 6, 2024

I'm sick, I'll deal with this issue when I'm healthy.

@carlosedp
Copy link
Author

Sure, hope tou get better soon!
Best wishes!

@evis
Copy link
Owner

evis commented May 5, 2024

@bjaglin thanks for the tip! It helped to fix it :)

@carlosedp I've initiated release 0.1.9_0.12.1 with the fix, it will become available in Maven Central soon. Thanks for your report!

@evis evis closed this as completed May 5, 2024
@evis
Copy link
Owner

evis commented May 5, 2024

Though, semanticdb rules don't work yet... I guess, I should build it for Scala 3 too, gonna work on it.

@evis evis reopened this May 5, 2024
@evis
Copy link
Owner

evis commented May 5, 2024

Oh, I forgot to compile sources before running scalafix. semanticdb rules work too, nevermind, closing it again

@evis evis closed this as completed May 5, 2024
@bjaglin
Copy link
Contributor

bjaglin commented May 5, 2024

Besides the fix, I would still recommend withParsedArguments() to be invoked last, to allow users to override what the plugin infers if/when needed. That's what sbt-scalafix does.

@carlosedp
Copy link
Author

Thanks a lot! Just added it to my project and worked perfectly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants