Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build scala-cli with jvm 11 #212

Merged
merged 5 commits into from
Nov 26, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- uses: coursier/cache-action@v6.3
- uses: coursier/setup-action@v1.1.2
with:
jvm: 8
jvm: 11
- name: Copy launcher
run: ./mill -i copyJvmLauncher artifacts/
if: runner.os == 'Linux'
Expand Down Expand Up @@ -63,7 +63,7 @@ jobs:
- uses: coursier/cache-action@v6.3
- uses: coursier/setup-action@v1.1.2
with:
jvm: 8
jvm: 11
- name: Generate native launcher
run: ./mill -i show defaultNativeImage
- name: Build OS packages
Expand Down Expand Up @@ -93,7 +93,7 @@ jobs:
- uses: coursier/cache-action@v6.3
- uses: coursier/setup-action@v1.1.2
with:
jvm: 8
jvm: 11
- name: Generate native launcher
run: ./mill -i show cli.nativeImageMostlyStatic
- name: Build docker image
Expand Down Expand Up @@ -131,7 +131,7 @@ jobs:
- uses: coursier/cache-action@v6.3
- uses: coursier/setup-action@v1.1.2
with:
jvm: 8
jvm: 11
- name: Generate native launcher
run: ./mill -i show cli.nativeImageStatic
- name: Copy artifacts
Expand All @@ -156,12 +156,12 @@ jobs:
- uses: coursier/cache-action@v6.3
- uses: coursier/setup-action@v1.1.2
with:
jvm: 8
jvm: 11
- name: Test documentation
run: .github/scripts/check_docs.sh

- name: Test gifs
run: gifs/generate_gifs.sh $(ls gifs/scenarios/)
run: gifs/generate_gifs.sh $(ls gifs/scenarios/)

checks:
timeout-minutes: 15
Expand All @@ -174,7 +174,7 @@ jobs:
- uses: coursier/cache-action@v6.3
- uses: coursier/setup-action@v1.1.2
with:
jvm: 8
jvm: 11
- name: Check native-image config format
run: ./mill -i __.checkNativeImageConfFormat
- name: Check Ammonite availability
Expand All @@ -198,7 +198,7 @@ jobs:
- uses: coursier/cache-action@v6.3
- uses: coursier/setup-action@v1.1.2
with:
jvm: 8
jvm: 11
apps: scalafmt:3.0.0
- run: scalafmt --check

Expand All @@ -213,7 +213,7 @@ jobs:
- uses: coursier/cache-action@v6.3
- uses: coursier/setup-action@v1.1.2
with:
jvm: 8
jvm: 11
- name: Check that reference doc is up-to-date
run: |
./mill -i generate-reference-doc.run --check || (
Expand All @@ -235,7 +235,7 @@ jobs:
- uses: coursier/cache-action@v6.3
- uses: coursier/setup-action@v1.1.2
with:
jvm: 8
jvm: 11
- run: ./mill -i ci.copyVcRedist
- uses: actions/upload-artifact@v2.2.4
with:
Expand All @@ -256,7 +256,7 @@ jobs:
- uses: coursier/cache-action@v6.3
- uses: coursier/setup-action@v1.1.2
with:
jvm: 8
jvm: 11
- name: GPG setup
run: .github/scripts/gpg-setup.sh
env:
Expand All @@ -282,7 +282,7 @@ jobs:
- uses: coursier/cache-action@v6.3
- uses: coursier/setup-action@v1.1.2
with:
jvm: 8
jvm: 11
- run: ./mill -i ci.setShouldPublish
- uses: actions/download-artifact@v2
if: env.SHOULD_PUBLISH == 'true'
Expand All @@ -307,7 +307,7 @@ jobs:
- uses: coursier/cache-action@v6.3
- uses: coursier/setup-action@v1.1.2
with:
jvm: 8
jvm: 11
- uses: actions/download-artifact@v2
with:
name: launchers
Expand Down Expand Up @@ -353,7 +353,7 @@ jobs:
- uses: coursier/cache-action@v6.3
- uses: coursier/setup-action@v1.1.2
with:
jvm: 8
jvm: 11
- run: ./mill -i ci.setShouldPublish
- uses: actions/setup-node@v2.4.1
if: env.SHOULD_PUBLISH == 'true'
Expand All @@ -379,7 +379,7 @@ jobs:
- uses: coursier/cache-action@v6.3
- uses: coursier/setup-action@v1.1.2
with:
jvm: 8
jvm: 11
- uses: actions/setup-node@v2.4.1
with:
node-version: '12.x'
Expand Down
16 changes: 11 additions & 5 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,16 @@ implicit def millModuleBasePath: define.BasePath =
object cli extends Cli
object `build-macros` extends Cross[BuildMacros](Scala.defaultInternal)
object build extends Cross[Build](Scala.defaultInternal)
object stubs extends JavaModule with ScalaCliPublishModule
object runner extends Cross[Runner](Scala.all: _*)
object `test-runner` extends Cross[TestRunner](Scala.all: _*)
object `bloop-rifle` extends Cross[BloopRifle](Scala.allScala2: _*)
object `tasty-lib` extends Cross[TastyLib](Scala.all: _*)

object stubs extends JavaModule with ScalaCliPublishModule {
def javacOptions = T {
super.javacOptions() ++ Seq("-target", "8", "-source", "8")
}
}
object integration extends Module {
object docker extends CliIntegrationDocker {
object test extends Tests {
Expand Down Expand Up @@ -435,7 +439,8 @@ class Runner(val crossScalaVersion: String) extends CrossSbtModule with ScalaCli
super.scalacOptions() ++ {
if (scalaVersion().startsWith("2.")) Seq("-Ywarn-unused")
else Nil
}
} ++ Seq("-release", "8")

}
def mainClass = Some("scala.cli.runner.Runner")
def ivyDeps =
Expand Down Expand Up @@ -474,7 +479,7 @@ class TestRunner(val crossScalaVersion: String) extends CrossSbtModule with Scal
super.scalacOptions() ++ {
if (scalaVersion().startsWith("2.")) Seq("-Ywarn-unused", "-deprecation")
else Nil
}
} ++ Seq("-release", "8")
}
def ivyDeps = super.ivyDeps() ++ Agg(
Deps.asm,
Expand Down Expand Up @@ -524,12 +529,13 @@ class BloopRifle(val crossScalaVersion: String) extends CrossSbtModule with Scal

class TastyLib(val crossScalaVersion: String) extends CrossSbtModule with ScalaCliPublishModule
with ScalaCliScalafixModule {
def scalacOptions = T {
def scalacOptions = T(
super.scalacOptions() ++ {
if (scalaVersion().startsWith("2.")) Seq("-Ywarn-unused")
else Nil
}
}
)

}

object `local-repo` extends LocalRepo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ object Package extends ScalaCommand[PackageOptions] {
}
val from = build.options.packageOptions.dockerOptions.from.getOrElse {
build.options.platform match {
case Platform.JVM => "openjdk:8-jre-slim"
case Platform.JVM => "openjdk:11-jre-slim"
case Platform.JS => "node"
case Platform.Native => "debian:stable-slim"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,7 @@ abstract class RunTestDefinitions(val scalaVersionOpt: Option[String])
expect(p.out.text().trim == "16")
}
}

if (!Properties.isWin)
test("CLI args passed to shebang script") {
val inputs = TestInputs(
Expand All @@ -1156,4 +1157,16 @@ abstract class RunTestDefinitions(val scalaVersionOpt: Option[String])
expect(p.out.text().trim == "List(1, 2, 3, -v)")
}
}

test("Runs with JVM 8") {
val inputs = TestInputs(
Seq(
os.rel / "run.scala" -> """object Main extends App { println("hello")}"""
)
)
inputs.fromRoot { root =>
val p = os.proc(TestUtil.cli, "run.scala", "--jvm", "8").call(cwd = root)
expect(p.out.text().trim == "hello")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,15 @@ abstract class TestTestDefinitions(val scalaVersionOpt: Option[String])
}
}

if (actualScalaVersion.startsWith("2"))
test("successful test JVM 8") {
successfulTestInputs.fromRoot { root =>
val output =
os.proc(TestUtil.cli, "test", "--jvm", "8", extraOptions, ".").call(cwd = root).out.text()
expect(output.contains("Hello from tests"))
}
}

def successfulJsTest(): Unit =
successfulTestInputs.fromRoot { root =>
val output = os.proc(TestUtil.cli, "test", extraOptions, ".", "--js")
Expand Down Expand Up @@ -509,5 +518,4 @@ abstract class TestTestDefinitions(val scalaVersionOpt: Option[String])
expect(output.contains("Hello from native"))
}
}

alexarchambault marked this conversation as resolved.
Show resolved Hide resolved
}
7 changes: 2 additions & 5 deletions website/docs/cookbooks/scala-docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Passing `--docker` to the `package` sub-command generates a Docker image. When c
The following command generates a `hello-docker` image with the `latest` tag:

```bash
scala-cli package --docker HelloDocker.scala --docker-image-repository hello-docker
scala-cli package --jvm 8 --docker HelloDocker.scala --docker-image-repository hello-docker
alexarchambault marked this conversation as resolved.
Show resolved Hide resolved
```

<!-- Expected:
Expand Down Expand Up @@ -51,12 +51,9 @@ Built docker image, run it with
This command creates a Scala Native Docker image:

```bash ignore
scala-cli package --native --docker HelloDocker.scala --docker-image-repository hello-docker
scala-cli package --native --jvm 8 --docker HelloDocker.scala --docker-image-repository hello-docker
alexarchambault marked this conversation as resolved.
Show resolved Hide resolved
```

:::note
Packaging a Scala Native application to a Docker image is supported only on Linux.
:::