bazelbuild / rules_scala

Scala rules for Bazel
Apache License 2.0
364 stars 275 forks source link

Scala 3 Support #1269

Open marcesquerra opened 3 years ago

marcesquerra commented 3 years ago

Now that scala 3 is officially live, how difficult would it be to add support for it in bazel?

If it's just a matter of adding a custom toolchain, a bit of documentation would help (I tried to do it in a sample project but couldn't manage)

UPDATE: I initially said I could give a shot on trying to move this forward, but I have to back down. Both the scope of this and the demands of real life ended up being bigger than I thought. But still, support for Scala 3 would still be great!

liucijus commented 3 years ago

It may not be trivial, but any help is appreciated!

What I would do:

  1. Create a small (simple Hello World app is ok) Scala 3 project with rules_scala to learn what are the gaps. Such project will force you to learn how to configure scala toolchain with deps providers for Scala 3 libs (you can use Rules JVM External to manage deps.
  2. Make rules_scala compatible with Scala 3. Keep in mind that we still have 2.11 users, so we need to stay compatible with old versions. This part is the most complex, it includes such complicated parts like dependency analyzer.
  3. Add third party deps to repositories configs. This step can be a blocker for some parts of Rules Scala if there are no Scala 3 support yet for some of the dep.
  4. Add version tests, CI config

Let me know if you get stuck or need help on any of the steps.

cocreature commented 3 years ago

I started looking into this and I got it to the point where I can at least compile & run a hello world https://github.com/cocreature/rules_scala/tree/scala-3. The next big missing piece is probably the dependency analyzer. I’m also largely ignoring backwards compatibility for now since I first want to get it to work before I worry about that too much. The compiler API is completely different so some parts will just consist of duplicating the code. Happy to share the work, the time I can spend on this atm is relatively limited.

liucijus commented 2 years ago

@cocreature would you be still interested contributing your work? I experimented on your changes, you can see how to make them Scala 2.x compatible: https://github.com/liucijus/rules_scala/tree/scala3-in-progress

cocreature commented 2 years ago

Unfortunately I got stuck trying to port the custom scala code for the unused deps & similar to Scala 3 so while it worked for a hello world, I couldn’t actually get it to work on our full project. I don’t expect keeping compatbiility with Scala 2 at the end will be the challenging part.

I don’t have the time at the moment to debug this further so if someone else wants to pick it up, by all means go for it. If not, I expect I’ll eventually get back to it but no idea about timelines.

liucijus commented 2 years ago

@cocreature I'm planning to work on Scala 3 support, and got it working to some extent based on your changes though I had to do some modifications to select code based on Scala version. I thought it would be great to get you attributed for your initial development (ScalaWorker, Scala 3 deps, etc). Of course I can just start from scratch and open PR myself as I did in my fork. But it's up to you to decide. The only requirement is to make the Scala 2 compatible, Scala 3 code can be untested, I will take over from there. Let me know what you think.

cocreature commented 2 years ago

Appreciate it but I’m perfectly happy to not be acknowledged here so just go ahead and open a PR yourself.

liucijus commented 2 years ago

Reopening as it was closed unintentionally

meisam commented 2 years ago

I'd be glad to help with this issue. I just opened #1408 for an issue I was facing with Scala3.