1- # Example sbt project that compiles using Dotty
1+ # Example mill project that compiles using Dotty
22
3- [ ![ Build Status] ( https://travis-ci.org/lampepfl/dotty-example-project.svg?branch=master )] ( https://travis-ci.org/lampepfl/dotty-example-project )
3+ ** NOTE** : Dotty support in mill is experimental. For now, sbt remains the
4+ preferred option, see http://github.com/lampepfl/dotty-example-project for an
5+ example sbt project.
46
57## Usage
68
7- This is a normal sbt project, you can compile code with ` sbt compile ` and run it
8- with ` sbt run ` , ` sbt console ` will start a Dotty REPL.
9-
10- If compiling this example project fails, you probably have a global sbt plugin
11- that does not work with dotty, try to disable all plugins in
12- ` ~/.sbt/1.0/plugins ` and ` ~/.sbt/1.0 ` .
9+ This is a normal mill project, you can compile code with ` mill root.compile ` and run it
10+ with ` mill root.run ` , ` mill -i root.console ` will start a Dotty REPL.
1311
1412### IDE support
1513
16- Dotty comes built-in with IDE support, to try it out see
17- http://dotty.epfl.ch/docs/usage/ide-support.html
18-
19- ## Making a new Dotty project
20- The fastest way to start a new Dotty project is to use one of the following templates:
21- * [ Simple Dotty project] ( https://github.com/lampepfl/dotty.g8 )
22- * [ Dotty project that cross-compiles with Scala 2] ( https://github.com/lampepfl/dotty-cross.g8 )
14+ Dotty comes built-in with IDE support, unfortunately this support is only
15+ available using sbt and not mill for now, see http://dotty.epfl.ch/docs/usage/ide-support.html
2316
2417## Using Dotty in an existing project
2518
26- You will need to make the following adjustments to your build:
27-
28- ### project/plugins.sbt
29- ``` scala
30- addSbtPlugin(" ch.epfl.lamp" % " sbt-dotty" % " 0.3.0" )
31- ```
32-
33- ### project/build.properties
34- ``` scala
35- sbt.version= 1.2.7
36- ```
37-
38- Older versions of sbt are not supported.
39-
40-
41- ### build.sbt
42- Any version number that starts with ` 0. ` is automatically recognized as Dotty by
43- the ` sbt-dotty ` plugin, you don't need to set up anything:
19+ ### build.sc
20+ Any version number that starts with ` 0. ` is automatically recognized as Dotty,
21+ you don't need to set up anything:
4422
4523``` scala
46- scalaVersion : = " 0.13.0-RC1"
24+ def scalaVersion = " 0.13.0-RC1"
4725```
4826
4927#### Nightly builds
5028If the latest release of Dotty is missing a bugfix or feature you need, you may
5129wish to use a nightly build. Look at the bottom of
5230https://repo1.maven.org/maven2/ch/epfl/lamp/dotty_0.14/ to find the version
53- number for the latest nightly build. Alternatively, you can set `scalaVersion :=
54- dottyLatestNightlyBuild.get` to always use the latest nightly build of dotty.
31+ number for the latest nightly build.
5532
5633## Getting your project to compile with Dotty
5734
5835When porting an existing project, it's a good idea to start out with the Scala 2
5936compatibility mode (note that this mode affects typechecking and thus may
60- prevent some valid Dotty code from compiling) by adding to your ` build.sbt ` :
37+ prevent some valid Dotty code from compiling) by adding to your ` build.sc ` :
6138
6239``` scala
63- scalacOptions ++= { if (isDotty.value) Seq (" -language:Scala2" ) else Nil }
40+ def scalacOptions = T {
41+ if (Dep .isDotty(scalaVersion()))
42+ Seq (" -language:Scala2" )
43+ else
44+ Seq ()
45+ }
6446```
6547
66- Using the ` isDotty ` setting ensures that this option will only be set when
48+ Using the ` Dep. isDotty` method ensures that this option will only be set when
6749compiling with Dotty.
6850
6951A tool to port code from Scala 2.x to Dotty is currently in development at
@@ -73,13 +55,13 @@ If your build contains dependencies that have only been published for Scala 2.x,
7355you may be able to get them to work on Dotty by replacing:
7456
7557``` scala
76- libraryDependencies += " a " %% " b " % " c"
58+ ivy " a::b: c"
7759```
7860
7961by:
8062
8163``` scala
82- libraryDependencies += ( " a " %% " b " % " c " ) .withDottyCompat(scalaVersion.value )
64+ ivy " a::b:c " .withDottyCompat(scalaVersion() )
8365```
8466
8567Or you can alternatively use:
0 commit comments