diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6dd6bfc..9a0c8e8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,29 +14,15 @@ jobs: build: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v2 - - name: Mill cache - uses: actions/cache@v2 + - uses: actions/checkout@v3 with: - path: ~/.mill - key: mill-${{ hashFiles('.mill-version') }} - - name: Ivy cache - uses: actions/cache@v2 + fetch-depth: 0 + - uses: coursier/cache-action@v6 + - uses: actions/setup-java@v3 with: - path: ~/.cache/coursier - key: ivy-${{ hashFiles('build.sc') }} - restore-keys: | - ivy-${{ hashFiles('build.sc') }} - ivy - - name: Compilation cache - uses: actions/cache@v2 - with: - path: ./out - key: out - - uses: actions/setup-java@v1 - with: - java-version: '8' - architecture: x64 + java-version: "8" + architecture: "x64" + distribution: "temurin" - name: Check formatting run: ./mill --no-server --disable-ticker mill.scalalib.scalafmt.ScalafmtModule/checkFormatAll __.sources @@ -65,29 +51,15 @@ jobs: LC_MESSAGES: "en_US.UTF-8" LC_ALL: "en_US.UTF-8" steps: - - uses: actions/checkout@v2 - - name: Mill cache - uses: actions/cache@v2 - with: - path: ~/.mill - key: mill-${{ hashFiles('.mill-version') }} - - name: Ivy cache - uses: actions/cache@v2 - with: - path: ~/.cache/coursier - key: ivy-${{ hashFiles('build.sc') }} - restore-keys: | - ivy-${{ hashFiles('build.sc') }} - ivy - - name: Compilation cache - uses: actions/cache@v2 + - uses: actions/checkout@v3 with: - path: ./out - key: out - - uses: actions/setup-java@v1 + fetch-depth: 0 + - uses: coursier/cache-action@v6 + - uses: actions/setup-java@v3 with: - java-version: '8' - architecture: x64 + java-version: "8" + architecture: "x64" + distribution: "temurin" - name: Publish to Maven Central run: | if [[ $(git tag --points-at HEAD) != '' ]]; then diff --git a/README.md b/README.md index a28b696..2f0e88f 100644 --- a/README.md +++ b/README.md @@ -8,18 +8,18 @@ Here you can see a basic example using mill-crossplatform ```scala import mill._, mill.scalalib._, mill.scalajslib._, mill.scalanativelib._ -import $ivy.`com.github.lolgab::mill-crossplatform::0.2.3` +import $ivy.`com.github.lolgab::mill-crossplatform::0.2.4` import com.github.lolgab.mill.crossplatform._ trait Common extends ScalaModule { - def scalaVersion = "2.13.11" + def scalaVersion = "2.13.12" } trait CommonNative extends ScalaNativeModule { - def scalaNativeVersion = "0.4.14" + def scalaNativeVersion = "0.4.15" } trait CommonJS extends ScalaJSModule { - def scalaJSVersion = "1.13.1" + def scalaJSVersion = "1.14.0" } object core extends CrossPlatform { @@ -81,17 +81,17 @@ to cross-compile for multiple Scala versions. ```scala import mill._, mill.scalalib._, mill.scalajslib._, mill.scalanativelib._ -import $ivy.`com.github.lolgab::mill-crossplatform::0.2.3` +import $ivy.`com.github.lolgab::mill-crossplatform::0.2.4` import com.github.lolgab.mill.crossplatform._ trait CommonNative extends ScalaNativeModule { - def scalaNativeVersion = "0.4.14" + def scalaNativeVersion = "0.4.15" } trait CommonJS extends ScalaJSModule { - def scalaJSVersion = "1.13.1" + def scalaJSVersion = "1.14.0" } -val scalaVersions = Seq("2.13.11", "3.3.0") +val scalaVersions = Seq("2.13.12", "3.3.1") object core extends Cross[CoreModule](scalaVersions) trait CoreModule extends CrossPlatform { @@ -120,13 +120,13 @@ import $ivy.`com.github.lolgab::mill-crossplatform::0.2.2` import com.github.lolgab.mill.crossplatform._ trait CommonNative extends ScalaNativeModule { - def scalaNativeVersion = "0.4.14" + def scalaNativeVersion = "0.4.15" } trait CommonJS extends ScalaJSModule { - def scalaJSVersion = "1.13.1" + def scalaJSVersion = "1.14.0" } -val scalaVersions = Seq("2.13.11", "3.3.0") +val scalaVersions = Seq("2.13.12", "3.3.1") object core extends Cross[CoreModule](scalaVersions: _*) class CoreModule(val crossScalaVersion: String) extends CrossPlatform { @@ -157,11 +157,11 @@ Root `moduleDeps` and `compileModuleDeps` work as expected ```scala import mill._, mill.scalalib._, mill.scalajslib._, mill.scalanativelib._ -import $ivy.`com.github.lolgab::mill-crossplatform::0.2.3` +import $ivy.`com.github.lolgab::mill-crossplatform::0.2.4` import com.github.lolgab.mill.crossplatform._ -val scalaVersions = Seq("2.13.11", "3.3.0") -val scalaJSVersions = Seq("1.13.1") +val scalaVersions = Seq("2.13.12", "3.3.1") +val scalaJSVersions = Seq("1.14.0") object core extends Cross[CoreModule](scalaVersions) trait CoreModule extends CrossPlatform { @@ -179,8 +179,8 @@ import mill._, mill.scalalib._, mill.scalajslib._, mill.scalanativelib._ import $ivy.`com.github.lolgab::mill-crossplatform::0.2.2` import com.github.lolgab.mill.crossplatform._ -val scalaVersions = Seq("2.13.11", "3.3.0") -val scalaJSVersions = Seq("1.13.1") +val scalaVersions = Seq("2.13.12", "3.3.1") +val scalaJSVersions = Seq("1.14.0") object core extends Cross[CoreModule](scalaVersions: _*) class CoreModule(val crossScalaVersion: String) extends CrossPlatform { @@ -205,7 +205,7 @@ import mill._, mill.scalalib._, mill.scalajslib._, mill.scalanativelib._ import $ivy.`com.github.lolgab::mill-crossplatform::0.2.2` import com.github.lolgab.mill.crossplatform._ -val scalaVersions = Seq("2.13.11", "3.3.0") +val scalaVersions = Seq("2.13.12", "3.3.1") object core extends Cross[CoreModule](scalaVersions) trait CoreModule extends CrossPlatform { @@ -216,7 +216,7 @@ trait CoreModule extends CrossPlatform { object jvm extends Shared object js extends Shared with ScalaJSModule { - def scalaJSVersion = "1.13.1" + def scalaJSVersion = "1.14.0" } object native extends Shared with ScalaNativeModule { def scalaNativeVersion = "0.4.12" @@ -231,7 +231,7 @@ import mill._, mill.scalalib._, mill.scalajslib._, mill.scalanativelib._ import $ivy.`com.github.lolgab::mill-crossplatform::0.2.2` import com.github.lolgab.mill.crossplatform._ -val scalaVersions = Seq("2.13.11", "3.3.0") +val scalaVersions = Seq("2.13.12", "3.3.1") object core extends Cross[CoreModule](scalaVersions: _*) class CoreModule(crossScalaVersion: String) extends CrossPlatform { @@ -242,10 +242,58 @@ class CoreModule(crossScalaVersion: String) extends CrossPlatform { object jvm extends Shared object js extends Shared with ScalaJSModule { - def scalaJSVersion = "1.13.1" + def scalaJSVersion = "1.14.0" } object native extends Shared with ScalaNativeModule { def scalaNativeVersion = "0.4.12" } } ``` + +### Test modules + +For tests, you need to have platform specific test modules + +#### With Mill 0.11 + +```scala +import mill._, mill.scalalib._, mill.scalajslib._, mill.scalanativelib._ +import $ivy.`com.github.lolgab::mill-crossplatform::0.2.4` +import com.github.lolgab.mill.crossplatform._ + +trait Common extends ScalaModule { + def scalaVersion = "3.3.1" +} +trait CommonNative extends ScalaNativeModule { + def scalaNativeVersion = "0.4.15" +} +trait CommonJS extends ScalaJSModule { + def scalaJSVersion = "1.14.0" +} +trait CommonTests extends TestModule.Munit { + def ivyDeps = super.ivyDeps() ++ Agg( + ivy"org.scalameta::munit::1.0.0-M10" + ) +} + +object core extends CrossPlatform { + trait Shared extends CrossPlatformScalaModule with Common { + // common `core` settings here + trait SharedTests extends CommonTests { + // common `core` test settings here + } + } + object jvm extends Shared { + // jvm specific settings here + object test extends ScalaTests with SharedTests + } + object js extends Shared with CommonJS { + // js specific settings here + object test extends ScalaJSTests with SharedTests + } + object native extends Shared with CommonNative { + // native specific settings here + object test extends ScalaNativeTests with SharedTests + } +} +``` diff --git a/itest/src/disable-platform/build.sc b/itest/src/disable-platform/build.sc index ed288f5..93124e8 100644 --- a/itest/src/disable-platform/build.sc +++ b/itest/src/disable-platform/build.sc @@ -11,7 +11,7 @@ import mill.scalanativelib._ import com.github.lolgab.mill.crossplatform._ trait CommonJVM extends ScalaModule { - def scalaVersion = "2.13.11" + def scalaVersion = "2.13.12" } trait CommonJS extends CommonJVM with ScalaJSModule { def scalaJSVersion = "1.12.0" @@ -70,7 +70,7 @@ def verify(ev: Evaluator) = T.command { .get ._2 .str - assert(result == "2.13.11", s"Wrong result: $result") + assert(result == "2.13.12", s"Wrong result: $result") } locally { diff --git a/itest/src/simple/build.sc b/itest/src/simple/build.sc index d8431b2..9961842 100644 --- a/itest/src/simple/build.sc +++ b/itest/src/simple/build.sc @@ -9,7 +9,7 @@ import mill.scalajslib._ import mill.scalanativelib._ import com.github.lolgab.mill.crossplatform._ -val scalaVersions = Seq("2.13.11", "3.3.0") +val scalaVersions = Seq("2.13.12", "3.3.1") trait CommonJVM extends ScalaModule trait CommonJS extends ScalaJSModule { @@ -21,7 +21,7 @@ trait CommonNative extends ScalaNativeModule { object normal extends CrossPlatform { object jvm extends CrossPlatformScalaModule { - def scalaVersion = "3.3.0" + def scalaVersion = "3.3.1" } } @@ -55,14 +55,14 @@ trait CrossScalaJSNative extends CrossPlatform { def moduleDeps = Seq(core()) trait Shared extends CrossPlatformCrossScalaModule object jvm extends Shared with CommonJVM - object js extends Cross[JS]("1.13.1") + object js extends Cross[JS]("1.14.0") trait JS extends Shared with CrossScalaJSModule - object native extends Cross[Native]("0.4.14") + object native extends Cross[Native]("0.4.15") trait Native extends Shared with CrossScalaNativeModule } def verify(ev: Evaluator) = T.command { - `no-native`("3.3.0").jvm.compile() + `no-native`("3.3.1").jvm.compile() locally { val result = ev.evalOrThrow()(normal.jvm.artifactName) @@ -73,7 +73,7 @@ def verify(ev: Evaluator) = T.command { } locally { - val result = ev.evalOrThrow()(core("3.3.0").jvm.artifactName) + val result = ev.evalOrThrow()(core("3.3.1").jvm.artifactName) assert( result == "core", s"Wrong artifactName: $result" @@ -82,7 +82,7 @@ def verify(ev: Evaluator) = T.command { locally { val result = ev.evalOrThrow()( - crossScalaJSNative("3.3.0").native("0.4.14").artifactName + crossScalaJSNative("3.3.1").native("0.4.15").artifactName ) assert( result == "crossScalaJSNative", @@ -92,7 +92,7 @@ def verify(ev: Evaluator) = T.command { locally { val result = - ev.evalOrThrow()(crossScalaJSNative("3.3.0").js("1.13.1").artifactName) + ev.evalOrThrow()(crossScalaJSNative("3.3.1").js("1.14.0").artifactName) assert( result == "crossScalaJSNative", s"Wrong artifactName: $result" @@ -101,9 +101,9 @@ def verify(ev: Evaluator) = T.command { locally { val result = - ev.evalOrThrow()(crossScalaJSNative("3.3.0").js("1.13.1").scalaVersion) + ev.evalOrThrow()(crossScalaJSNative("3.3.1").js("1.14.0").scalaVersion) assert( - result == "3.3.0", + result == "3.3.1", s"Wrong artifactName: $result" ) } @@ -117,7 +117,7 @@ def verify(ev: Evaluator) = T.command { } locally { - val path = ev.evalOrThrow()(core("3.3.0").jvm.sources).head.path / os.up + val path = ev.evalOrThrow()(core("3.3.1").jvm.sources).head.path / os.up assert( path.last == "core", s"Wrong millSourcePath: $path" diff --git a/itest/src/with-tests/build.sc b/itest/src/with-tests/build.sc new file mode 100644 index 0000000..78d2bdd --- /dev/null +++ b/itest/src/with-tests/build.sc @@ -0,0 +1,48 @@ +import $file.plugins + +import mill._ +import mill.api.Result +import mill.eval._ +import mill.main.MainModule +import mill.scalalib._ +import mill.scalajslib._ +import mill.scalanativelib._ +import com.github.lolgab.mill.crossplatform._ + +trait Common extends ScalaModule { + def scalaVersion = "3.3.1" +} +trait CommonJVM extends Common +trait CommonJS extends Common with ScalaJSModule { + def scalaJSVersion = "1.14.0" +} +trait CommonNative extends Common with ScalaNativeModule { + def scalaNativeVersion = "0.4.16" +} +trait CommonTests extends TestModule.Munit { + def ivyDeps = super.ivyDeps() ++ Agg( + ivy"org.scalameta::munit::1.0.0-M10" + ) +} +object core extends CrossPlatform { + trait Shared extends CrossPlatformScalaModule { + trait SharedTests extends CommonTests + } + object jvm extends Shared with CommonJVM { + object test extends ScalaTests with SharedTests + } + object js extends Shared with CommonJS { + object test extends ScalaJSTests with SharedTests + } + object native extends Shared with CommonNative { + object test extends ScalaNativeTests with SharedTests + } +} + +def verify(ev: Evaluator) = T.command { + ev.evalOrThrow()(core.jvm.test.test()) + ev.evalOrThrow()(core.js.test.test()) + ev.evalOrThrow()(core.native.test.test()) + + () +} diff --git a/itest/src/with-tests/core/test/src/ExampleTest.scala b/itest/src/with-tests/core/test/src/ExampleTest.scala new file mode 100644 index 0000000..56be14a --- /dev/null +++ b/itest/src/with-tests/core/test/src/ExampleTest.scala @@ -0,0 +1,7 @@ +package example + +class ExampleTest extends munit.FunSuite { + test("passing test") { + assertEquals(1, 1) + } +}