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

Better support for cross compilation #1747

Open
steinybot opened this issue Apr 4, 2023 · 1 comment
Open

Better support for cross compilation #1747

steinybot opened this issue Apr 4, 2023 · 1 comment

Comments

@steinybot
Copy link

It is kind of a pain to use scalafix with an sbt project that is cross compiled for Scala 2 and 3 because scalafix has a hard fail if given a rule that isn't supported for that Scala version. For example:

[error] (web / Compile / scalafix) scalafix.sbt.InvalidArgument: 2 errors
[error] [E0] This rule is specific to Scala 2, because the compiler option `-Ywarn-unused` is not available yet in scala 3 To fix this error, remove RemoveUnused from .scalafix.conf
[error] [E1] This rule is specific to Scala 2, since procedure syntax is not supported in Scala 3. To fix this error, remove ProcedureSyntax from .scalafix.conf

Removing the rule from Scala 2 is unsatisfactory so the only other solution seems to be to have two separate configuration files. I didn't see any include functionality so this would have to be a copy/paste and both files have to be kept in sync.

It would be nice to have better support for having a single configuration that is used for multiple Scala versions.

A few thoughts come to mind:

  • Change it to a warning instead of an error
  • Add an include feature to the config so that common configuration could be shared
  • Make parts of the configuration conditional based on the Scala version
@bjaglin
Copy link
Collaborator

bjaglin commented Apr 15, 2023

Thanks for reaching out!

First of all, it's worth noting that initial support for RemoveUnused is around the corner, in time for Scala 3.3.0, so hopefully this will be a little less needed soon.

Add an include feature to the config so that common configuration could be shared

Actually, scalafix relies on metaconfig, which has precisely support for that through HOCON. So you should be able to create a common configuration file included by scala-specific configuration files, and use them with something like

scalafixConfig := Some(file(s".scalafix-scala${scalaBinaryVersion.value}.conf"))

Would that work for you? If so, we could add a dedicated section to document that in https://github.com/scalacenter/scalafix/blob/main/docs/users/installation.md. PR with a reference to a real example usage would be very much welcome!

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

No branches or pull requests

2 participants