Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to use the Scala 3 compiler (Dotty) from Gradle yet?

I am new to both Gradle and Dotty (and still relatively new to Scala overall). I was able to create a Scala project with Gradle like this:

gradle init --dsl kotlin --type scala-library --package com.stackoverflow.example

and I know that Dotty can be used with SBT. But is there a way to wire up Dotty with Gradle (yet)?

like image 901
Keith Pinson Avatar asked Jul 10 '20 14:07

Keith Pinson


People also ask

How do I run Scala with gradle?

From inside the new project directory, run the init task using the following command in a terminal: gradle init . When prompted, select the 2: application project type and 5: Scala as implementation language. Next you can choose the DSL for writing buildscripts - 1 : Groovy or 2: Kotlin .

Does gradle work with Scala?

Gradle supports version 1.6. 0 of Zinc and above. The Zinc compiler itself needs a compatible version of scala-library that may be different from the version required by your application. Gradle takes care of specifying a compatible version of scala-library for you.

What is plugin in Scala?

Introduction. A compiler plugin is a compiler component that lives in a separate JAR file from the main compiler. The compiler can then load that plugin and gain extra functionality. This tutorial briefly walks you through writing a plugin for the Scala compiler.


1 Answers

There’s dotty examples repository with demonstrations of how to build dotty with various build tools including gradle.

https://github.com/michelou/dotty-examples/blob/master/examples/dotty-example-project/build.gradle

As you can see there’s nothing standard yet, but when there will be, I believe maintainers will update this repo.

In my personal project I did something similar to this with some simplifications:

https://github.com/SimY4/xpath-to-xml/blob/master/xpath-to-xml-scala/build-3.gradle

like image 132
SimY4 Avatar answered Sep 23 '22 20:09

SimY4