diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9ee9ac3..0e846f8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,27 +16,17 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout current branch (full) - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 - name: Setup Java - uses: actions/setup-java@v2 + uses: actions/setup-java@v3 with: distribution: temurin java-version: ${{ matrix.java-version }} - - name: Cache sbt - uses: actions/cache@v2 - with: - path: | - ~/.sbt - ~/.ivy2/cache - ~/.coursier/cache/v1 - ~/.cache/coursier/v1 - ~/AppData/Local/Coursier/Cache/v1 - ~/Library/Caches/Coursier/v1 - key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} + - uses: coursier/cache-action@v6 - name: Run project - run: ./mill root.run + run: ./mill examples.run diff --git a/.mill-version b/.mill-version new file mode 100644 index 0000000..9028ec6 --- /dev/null +++ b/.mill-version @@ -0,0 +1 @@ +0.10.5 diff --git a/README.md b/README.md index b23c5cb..d7e39c0 100644 --- a/README.md +++ b/README.md @@ -1,66 +1,29 @@ # Example mill project that compiles using Scala 3 -**NOTE**: Scala 3 support in mill is experimental. For now, sbt remains the -preferred option. See https://github.com/scala/scala3-example-project for an -example sbt project. - ## Usage -This is a normal mill project. You can compile code with `mill root.compile` and run it -with `mill root.run`, `mill -i root.console` will start a Scala 3 REPL. +This is a normal mill project. You can compile code with `mill examples.compile` and run it +with `mill examples.run`, `mill -i examples.console` will start a Scala 3 REPL. ### IDE support -Scala 3 comes built-in with IDE support, unfortunately this support is only -available using sbt and not mill for now, see http://dotty.epfl.ch/docs/usage/ide-support.html +It's recommended to either use [Metals](https://scalameta.org/metals/) with the +editor of your choice or [the Scala Plugin for +IntelliJ](https://blog.jetbrains.com/scala/). ## Using Scala 3 in an existing project ### build.sc -Any version number that starts with `3.` is automatically recognized as Scala 3; -you don't need to set up anything: ```scala def scalaVersion = "3.1.3" ``` -#### Nightly builds - -If the latest release of Scala 3 is missing a bugfix or feature you need, you may -wish to use a nightly build. Look at the bottom of the list of -[releases](https://repo1.maven.org/maven2/org/scala-lang/scala3-compiler_3/) -to find the version number for the latest nightly build. - -## Getting your project to compile with Scala 3 - -When porting an existing project, it's a good idea to start out with the Scala 2 -compatibility mode (note that this mode affects typechecking and thus may -prevent some valid Scala 3 code from compiling) by adding to your `build.sc`: - -```scala -def scalacOptions = T { - if (Dep.isDotty(scalaVersion())) - Seq("-language:Scala2") - else - Seq() -} -``` - -Using the `Dep.isDotty` method ensures that this option will only be set when -compiling with Scala 3. - -A tool to port code from Scala 2.x to Scala 3 is available; see -https://scalacenter.github.io/scala-3-migration-guide/docs/tooling/scala-3-migrate-plugin.html +### Getting your project to compile with Scala 3 -If your build contains dependencies that have only been published for Scala 2.x, -you may be able to get them to work on Scala 3 by replacing: +For help with porting an existing Scala 2 project to Scala 3, see the +[Scala 3 migration guide](https://docs.scala-lang.org/scala3/guides/migration/compatibility-intro.html). -```scala -ivy"a::b:c" -``` +## Need help? -by: - -```scala -ivy"a::b:c".withDottyCompat(scalaVersion()) -``` +https://www.scala-lang.org/community/ has links. diff --git a/build.sbt b/build.sbt deleted file mode 100644 index e69de29..0000000 diff --git a/build.sc b/build.sc index 27705dc..2675123 100644 --- a/build.sc +++ b/build.sc @@ -1,7 +1,5 @@ import mill._, scalalib._ -object root extends SbtModule { - def millSourcePath = ammonite.ops.pwd +object examples extends ScalaModule { def scalaVersion = "3.1.3" - def publishVersion = "0.1.0" } diff --git a/src/main/scala/AutoParamTupling.scala b/examples/src/AutoParamTupling.scala similarity index 100% rename from src/main/scala/AutoParamTupling.scala rename to examples/src/AutoParamTupling.scala diff --git a/src/main/scala/ContextQueries.scala b/examples/src/ContextQueries.scala similarity index 100% rename from src/main/scala/ContextQueries.scala rename to examples/src/ContextQueries.scala diff --git a/src/main/scala/Conversion.scala b/examples/src/Conversion.scala similarity index 100% rename from src/main/scala/Conversion.scala rename to examples/src/Conversion.scala diff --git a/src/main/scala/EnumTypes.scala b/examples/src/EnumTypes.scala similarity index 100% rename from src/main/scala/EnumTypes.scala rename to examples/src/EnumTypes.scala diff --git a/src/main/scala/ImpliedInstances.scala b/examples/src/ImpliedInstances.scala similarity index 100% rename from src/main/scala/ImpliedInstances.scala rename to examples/src/ImpliedInstances.scala diff --git a/src/main/scala/IntersectionTypes.scala b/examples/src/IntersectionTypes.scala similarity index 100% rename from src/main/scala/IntersectionTypes.scala rename to examples/src/IntersectionTypes.scala diff --git a/src/main/scala/Main.scala b/examples/src/Main.scala similarity index 100% rename from src/main/scala/Main.scala rename to examples/src/Main.scala diff --git a/src/main/scala/MultiversalEquality.scala b/examples/src/MultiversalEquality.scala similarity index 100% rename from src/main/scala/MultiversalEquality.scala rename to examples/src/MultiversalEquality.scala diff --git a/src/main/scala/PatternMatching.scala b/examples/src/PatternMatching.scala similarity index 100% rename from src/main/scala/PatternMatching.scala rename to examples/src/PatternMatching.scala diff --git a/src/main/scala/StructuralTypes.scala b/examples/src/StructuralTypes.scala similarity index 100% rename from src/main/scala/StructuralTypes.scala rename to examples/src/StructuralTypes.scala diff --git a/src/main/scala/TraitParams.scala b/examples/src/TraitParams.scala similarity index 100% rename from src/main/scala/TraitParams.scala rename to examples/src/TraitParams.scala diff --git a/src/main/scala/TypeLambdas.scala b/examples/src/TypeLambdas.scala similarity index 100% rename from src/main/scala/TypeLambdas.scala rename to examples/src/TypeLambdas.scala diff --git a/src/main/scala/UnionTypes.scala b/examples/src/UnionTypes.scala similarity index 100% rename from src/main/scala/UnionTypes.scala rename to examples/src/UnionTypes.scala diff --git a/mill b/mill index d66be9e..e616548 100755 --- a/mill +++ b/mill @@ -3,27 +3,39 @@ # This is a wrapper script, that automatically download mill from GitHub release pages # You can give the required mill version with MILL_VERSION env variable # If no version is given, it falls back to the value of DEFAULT_MILL_VERSION -DEFAULT_MILL_VERSION=0.9.7 +DEFAULT_MILL_VERSION=0.10.5 set -e if [ -z "$MILL_VERSION" ] ; then if [ -f ".mill-version" ] ; then MILL_VERSION="$(head -n 1 .mill-version 2> /dev/null)" - elif [ -f "mill" ] && [ "$BASH_SOURCE" != "mill" ] ; then + elif [ -f "mill" ] && [ "$0" != "mill" ] ; then MILL_VERSION=$(grep -F "DEFAULT_MILL_VERSION=" "mill" | head -n 1 | cut -d= -f2) else MILL_VERSION=$DEFAULT_MILL_VERSION fi fi -MILL_DOWNLOAD_PATH="$HOME/.mill/download" -MILL_EXEC_PATH="${MILL_DOWNLOAD_PATH}/$MILL_VERSION" +if [ "x${XDG_CACHE_HOME}" != "x" ] ; then + MILL_DOWNLOAD_PATH="${XDG_CACHE_HOME}/mill/download" +else + MILL_DOWNLOAD_PATH="${HOME}/.cache/mill/download" +fi +MILL_EXEC_PATH="${MILL_DOWNLOAD_PATH}/${MILL_VERSION}" + +version_remainder="$MILL_VERSION" +MILL_MAJOR_VERSION="${version_remainder%%.*}"; version_remainder="${version_remainder#*.}" +MILL_MINOR_VERSION="${version_remainder%%.*}"; version_remainder="${version_remainder#*.}" -if [ ! -x "$MILL_EXEC_PATH" ] ; then - mkdir -p $MILL_DOWNLOAD_PATH +if [ ! -s "$MILL_EXEC_PATH" ] ; then + mkdir -p "$MILL_DOWNLOAD_PATH" + if [ "$MILL_MAJOR_VERSION" -gt 0 ] || [ "$MILL_MINOR_VERSION" -ge 5 ] ; then + ASSEMBLY="-assembly" + fi DOWNLOAD_FILE=$MILL_EXEC_PATH-tmp-download - MILL_DOWNLOAD_URL="https://github.com/lihaoyi/mill/releases/download/${MILL_VERSION%%-*}/$MILL_VERSION-assembly" + MILL_VERSION_TAG=$(echo $MILL_VERSION | sed -E 's/([^-]+)(-M[0-9]+)?(-.*)?/\1\2/') + MILL_DOWNLOAD_URL="https://github.com/lihaoyi/mill/releases/download/${MILL_VERSION_TAG}/$MILL_VERSION${ASSEMBLY}" curl --fail -L -o "$DOWNLOAD_FILE" "$MILL_DOWNLOAD_URL" chmod +x "$DOWNLOAD_FILE" mv "$DOWNLOAD_FILE" "$MILL_EXEC_PATH" diff --git a/project/build.properties b/project/build.properties deleted file mode 100644 index e69de29..0000000 diff --git a/project/plugins.sbt b/project/plugins.sbt deleted file mode 100644 index e69de29..0000000