Skip to content

Commit 0c8c57f

Browse files
Merge pull request #15 from ckipp01/fix
fix: ensure everything works and instructions updated
2 parents be89c1f + a6a011b commit 0c8c57f

21 files changed

+35
-71
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,17 @@ jobs:
1616
runs-on: ubuntu-latest
1717
steps:
1818
- name: Checkout current branch (full)
19-
uses: actions/checkout@v2
19+
uses: actions/checkout@v3
2020
with:
2121
fetch-depth: 0
2222

2323
- name: Setup Java
24-
uses: actions/setup-java@v2
24+
uses: actions/setup-java@v3
2525
with:
2626
distribution: temurin
2727
java-version: ${{ matrix.java-version }}
2828

29-
- name: Cache sbt
30-
uses: actions/cache@v2
31-
with:
32-
path: |
33-
~/.sbt
34-
~/.ivy2/cache
35-
~/.coursier/cache/v1
36-
~/.cache/coursier/v1
37-
~/AppData/Local/Coursier/Cache/v1
38-
~/Library/Caches/Coursier/v1
39-
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
29+
- uses: coursier/cache-action@v6
4030

4131
- name: Run project
42-
run: ./mill root.run
32+
run: ./mill examples.run

.mill-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.10.5

README.md

Lines changed: 10 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,29 @@
11
# Example mill project that compiles using Scala 3
22

3-
**NOTE**: Scala 3 support in mill is experimental. For now, sbt remains the
4-
preferred option. See https://github.com/scala/scala3-example-project for an
5-
example sbt project.
6-
73
## Usage
84

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 Scala 3 REPL.
5+
This is a normal mill project. You can compile code with `mill examples.compile` and run it
6+
with `mill examples.run`, `mill -i examples.console` will start a Scala 3 REPL.
117

128
### IDE support
139

14-
Scala 3 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
10+
It's recommended to either use [Metals](https://scalameta.org/metals/) with the
11+
editor of your choice or [the Scala Plugin for
12+
IntelliJ](https://blog.jetbrains.com/scala/).
1613

1714
## Using Scala 3 in an existing project
1815

1916
### build.sc
20-
Any version number that starts with `3.` is automatically recognized as Scala 3;
21-
you don't need to set up anything:
2217

2318
```scala
2419
def scalaVersion = "3.1.3"
2520
```
2621

27-
#### Nightly builds
28-
29-
If the latest release of Scala 3 is missing a bugfix or feature you need, you may
30-
wish to use a nightly build. Look at the bottom of the list of
31-
[releases](https://repo1.maven.org/maven2/org/scala-lang/scala3-compiler_3/)
32-
to find the version number for the latest nightly build.
33-
34-
## Getting your project to compile with Scala 3
35-
36-
When porting an existing project, it's a good idea to start out with the Scala 2
37-
compatibility mode (note that this mode affects typechecking and thus may
38-
prevent some valid Scala 3 code from compiling) by adding to your `build.sc`:
39-
40-
```scala
41-
def scalacOptions = T {
42-
if (Dep.isDotty(scalaVersion()))
43-
Seq("-language:Scala2")
44-
else
45-
Seq()
46-
}
47-
```
48-
49-
Using the `Dep.isDotty` method ensures that this option will only be set when
50-
compiling with Scala 3.
51-
52-
A tool to port code from Scala 2.x to Scala 3 is available; see
53-
https://scalacenter.github.io/scala-3-migration-guide/docs/tooling/scala-3-migrate-plugin.html
22+
### Getting your project to compile with Scala 3
5423

55-
If your build contains dependencies that have only been published for Scala 2.x,
56-
you may be able to get them to work on Scala 3 by replacing:
24+
For help with porting an existing Scala 2 project to Scala 3, see the
25+
[Scala 3 migration guide](https://docs.scala-lang.org/scala3/guides/migration/compatibility-intro.html).
5726

58-
```scala
59-
ivy"a::b:c"
60-
```
27+
## Need help?
6128

62-
by:
63-
64-
```scala
65-
ivy"a::b:c".withDottyCompat(scalaVersion())
66-
```
29+
https://www.scala-lang.org/community/ has links.

build.sbt

Whitespace-only changes.

build.sc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import mill._, scalalib._
22

3-
object root extends SbtModule {
4-
def millSourcePath = ammonite.ops.pwd
3+
object examples extends ScalaModule {
54
def scalaVersion = "3.1.3"
6-
def publishVersion = "0.1.0"
75
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

mill

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,39 @@
33
# This is a wrapper script, that automatically download mill from GitHub release pages
44
# You can give the required mill version with MILL_VERSION env variable
55
# If no version is given, it falls back to the value of DEFAULT_MILL_VERSION
6-
DEFAULT_MILL_VERSION=0.9.7
6+
DEFAULT_MILL_VERSION=0.10.5
77

88
set -e
99

1010
if [ -z "$MILL_VERSION" ] ; then
1111
if [ -f ".mill-version" ] ; then
1212
MILL_VERSION="$(head -n 1 .mill-version 2> /dev/null)"
13-
elif [ -f "mill" ] && [ "$BASH_SOURCE" != "mill" ] ; then
13+
elif [ -f "mill" ] && [ "$0" != "mill" ] ; then
1414
MILL_VERSION=$(grep -F "DEFAULT_MILL_VERSION=" "mill" | head -n 1 | cut -d= -f2)
1515
else
1616
MILL_VERSION=$DEFAULT_MILL_VERSION
1717
fi
1818
fi
1919

20-
MILL_DOWNLOAD_PATH="$HOME/.mill/download"
21-
MILL_EXEC_PATH="${MILL_DOWNLOAD_PATH}/$MILL_VERSION"
20+
if [ "x${XDG_CACHE_HOME}" != "x" ] ; then
21+
MILL_DOWNLOAD_PATH="${XDG_CACHE_HOME}/mill/download"
22+
else
23+
MILL_DOWNLOAD_PATH="${HOME}/.cache/mill/download"
24+
fi
25+
MILL_EXEC_PATH="${MILL_DOWNLOAD_PATH}/${MILL_VERSION}"
26+
27+
version_remainder="$MILL_VERSION"
28+
MILL_MAJOR_VERSION="${version_remainder%%.*}"; version_remainder="${version_remainder#*.}"
29+
MILL_MINOR_VERSION="${version_remainder%%.*}"; version_remainder="${version_remainder#*.}"
2230

23-
if [ ! -x "$MILL_EXEC_PATH" ] ; then
24-
mkdir -p $MILL_DOWNLOAD_PATH
31+
if [ ! -s "$MILL_EXEC_PATH" ] ; then
32+
mkdir -p "$MILL_DOWNLOAD_PATH"
33+
if [ "$MILL_MAJOR_VERSION" -gt 0 ] || [ "$MILL_MINOR_VERSION" -ge 5 ] ; then
34+
ASSEMBLY="-assembly"
35+
fi
2536
DOWNLOAD_FILE=$MILL_EXEC_PATH-tmp-download
26-
MILL_DOWNLOAD_URL="https://github.com/lihaoyi/mill/releases/download/${MILL_VERSION%%-*}/$MILL_VERSION-assembly"
37+
MILL_VERSION_TAG=$(echo $MILL_VERSION | sed -E 's/([^-]+)(-M[0-9]+)?(-.*)?/\1\2/')
38+
MILL_DOWNLOAD_URL="https://github.com/lihaoyi/mill/releases/download/${MILL_VERSION_TAG}/$MILL_VERSION${ASSEMBLY}"
2739
curl --fail -L -o "$DOWNLOAD_FILE" "$MILL_DOWNLOAD_URL"
2840
chmod +x "$DOWNLOAD_FILE"
2941
mv "$DOWNLOAD_FILE" "$MILL_EXEC_PATH"

project/build.properties

Whitespace-only changes.

project/plugins.sbt

Whitespace-only changes.

0 commit comments

Comments
 (0)