1
- # Example sbt project that compiles using Dotty
1
+ # Example mill project that compiles using Dotty
2
2
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.
4
6
5
7
## Usage
6
8
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.
13
11
14
12
### IDE support
15
13
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
23
16
24
17
## Using Dotty in an existing project
25
18
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:
44
22
45
23
``` scala
46
- scalaVersion : = " 0.13.0-RC1"
24
+ def scalaVersion = " 0.13.0-RC1"
47
25
```
48
26
49
27
#### Nightly builds
50
28
If the latest release of Dotty is missing a bugfix or feature you need, you may
51
29
wish to use a nightly build. Look at the bottom of
52
30
https://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.
55
32
56
33
## Getting your project to compile with Dotty
57
34
58
35
When porting an existing project, it's a good idea to start out with the Scala 2
59
36
compatibility 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 ` :
61
38
62
39
``` 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
+ }
64
46
```
65
47
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
67
49
compiling with Dotty.
68
50
69
51
A 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,
73
55
you may be able to get them to work on Dotty by replacing:
74
56
75
57
``` scala
76
- libraryDependencies += " a " %% " b " % " c"
58
+ ivy " a::b: c"
77
59
```
78
60
79
61
by:
80
62
81
63
``` scala
82
- libraryDependencies += ( " a " %% " b " % " c " ) .withDottyCompat(scalaVersion.value )
64
+ ivy " a::b:c " .withDottyCompat(scalaVersion() )
83
65
```
84
66
85
67
Or you can alternatively use:
0 commit comments