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

Shade Scalameta v1 in sbt-scalafmt #1113

Closed
olafurpg opened this issue Feb 22, 2018 · 6 comments
Closed

Shade Scalameta v1 in sbt-scalafmt #1113

olafurpg opened this issue Feb 22, 2018 · 6 comments
Labels

Comments

@olafurpg
Copy link
Member

olafurpg commented Feb 22, 2018

Scalafmt is currently using Scalameta v1 and Scalafix uses v2. See #975 for the ticket on upgrading Scalafmt to v2. However,

  • I don't know when me or someone else will get around to upgrade
  • there is a growing need to be able to use sbt-scalafmt and sbt-scalafix together but by default this will not work due to class incompatibilities between Scalameta v1 and v2.

As a temporary relief, we could publish sbt-scalafmt with the following packages shaded

  • scala.meta
  • metaconfig
  • org.langmeta (maybe not necessary)

Additionally, we may need to exclude scalapb from the scalafmt's transitive dependencies. Scalafmt doesn't use it but it's brought in transitively. This workaround would allow sbt-scalafix and sbt-scalafmt to live happily together on the same classpath without doing classloading hacks in sbt-scalafix.

@olafurpg olafurpg added the build label Feb 22, 2018
@fommil
Copy link

fommil commented Feb 22, 2018

@alexarchambault TL;DR if sbt-scalafmt shaded scala.meta then we'd be able to have a much more efficient sbt-scalafix and avoid classpath nonsense. Do you think it'd be hard to do this?

@alexarchambault
Copy link
Contributor

alexarchambault commented Feb 22, 2018

scala-meta shoudn't rely much on reflection, so I guess that should work… There's an example of how to do that in coursier, see around here and here.

Note that the shadeNamespaces setting is optional. It only aims at speeding things by shading whole namespaces rather than by shading the classes found in it one-by-one. But one has to be sure that all classes from that namespace are indeed in the shaded dependencies.

@pauldraper
Copy link
Contributor

This is one of the cases where separate classloader (e.g. the approach of https://github.com/lucidsoftware/neo-sbt-scalafmt) helps.

@fommil
Copy link

fommil commented Apr 18, 2018

That brings is own problems, the multiple classloaders are unusable on large projects because of memory.

@olafurpg
Copy link
Member Author

olafurpg commented May 7, 2018

I am leaning towards biting the bullet and upgrade to meta v3. I already take the first steps in this direction in #1145. Shading the dependency is not a long term solution

@olafurpg olafurpg closed this as completed May 7, 2018
@fommil
Copy link

fommil commented May 7, 2018

that's awesome news!

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

No branches or pull requests

4 participants