From 3a44fe898c1221f9a6866a1eccf30151839324a8 Mon Sep 17 00:00:00 2001 From: Jules Ivanic Date: Sun, 24 Sep 2023 19:33:06 +0400 Subject: [PATCH] Drop Java 8 support && Introduce Java21 (#296) * Drop Java 8 support * Drop Java 8 support * Drop Java 8 support * Drop Java 8 support * scalafmt * Update actions/checkout to v4.1.0 --- .github/workflows/ci.yml | 39 +++++++++---------- README.md | 26 +++++-------- docs/index.md | 27 +++++-------- project/Versions.scala | 6 +-- zio-sbt-ci/src/main/scala/zio/sbt/V.scala | 2 +- .../main/scala/zio/sbt/ZioSbtCiPlugin.scala | 33 +++++++--------- .../scala/zio/sbt/ScalaCompilerSettings.scala | 2 +- .../src/main/scala/zio/sbt/Versions.scala | 6 +-- .../.github/workflows/ci.yml | 9 ++--- 9 files changed, 66 insertions(+), 84 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 03b2b303..b0c5c307 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,7 +4,6 @@ name: CI env: JDK_JAVA_OPTIONS: -XX:+PrintCommandLineFlags - JVM_OPTS: -XX:+PrintCommandLineFlags 'on': workflow_dispatch: {} release: @@ -21,7 +20,7 @@ jobs: continue-on-error: true steps: - name: Git Checkout - uses: actions/checkout@v4.0.0 + uses: actions/checkout@v4.1.0 with: fetch-depth: '0' - name: Install libuv @@ -29,8 +28,8 @@ jobs: - name: Setup Scala uses: actions/setup-java@v3.13.0 with: - distribution: temurin - java-version: '8' + distribution: corretto + java-version: '17' check-latest: true - name: Cache Dependencies uses: coursier/cache-action@v6 @@ -46,7 +45,7 @@ jobs: continue-on-error: false steps: - name: Git Checkout - uses: actions/checkout@v4.0.0 + uses: actions/checkout@v4.1.0 with: fetch-depth: '0' - name: Install libuv @@ -54,8 +53,8 @@ jobs: - name: Setup Scala uses: actions/setup-java@v3.13.0 with: - distribution: temurin - java-version: '8' + distribution: corretto + java-version: '17' check-latest: true - name: Cache Dependencies uses: coursier/cache-action@v6 @@ -71,22 +70,22 @@ jobs: fail-fast: false matrix: java: - - '8' - '11' - '17' + - '21' steps: - name: Install libuv run: sudo apt-get update && sudo apt-get install -y libuv1-dev - name: Setup Scala uses: actions/setup-java@v3.13.0 with: - distribution: temurin + distribution: corretto java-version: ${{ matrix.java }} check-latest: true - name: Cache Dependencies uses: coursier/cache-action@v6 - name: Git Checkout - uses: actions/checkout@v4.0.0 + uses: actions/checkout@v4.1.0 with: fetch-depth: '0' - name: Test @@ -98,7 +97,7 @@ jobs: if: ${{ github.event_name == 'push' }} steps: - name: Git Checkout - uses: actions/checkout@v4.0.0 + uses: actions/checkout@v4.1.0 with: fetch-depth: '0' - name: Install libuv @@ -106,8 +105,8 @@ jobs: - name: Setup Scala uses: actions/setup-java@v3.13.0 with: - distribution: temurin - java-version: '8' + distribution: corretto + java-version: '17' check-latest: true - name: Cache Dependencies uses: coursier/cache-action@v6 @@ -172,7 +171,7 @@ jobs: if: ${{ github.event_name != 'pull_request' }} steps: - name: Git Checkout - uses: actions/checkout@v4.0.0 + uses: actions/checkout@v4.1.0 with: fetch-depth: '0' - name: Install libuv @@ -180,8 +179,8 @@ jobs: - name: Setup Scala uses: actions/setup-java@v3.13.0 with: - distribution: temurin - java-version: '8' + distribution: corretto + java-version: '17' check-latest: true - name: Cache Dependencies uses: coursier/cache-action@v6 @@ -201,7 +200,7 @@ jobs: if: ${{ ((github.event_name == 'release') && (github.event.action == 'published')) || (github.event_name == 'workflow_dispatch') }} steps: - name: Git Checkout - uses: actions/checkout@v4.0.0 + uses: actions/checkout@v4.1.0 with: fetch-depth: '0' - name: Install libuv @@ -209,8 +208,8 @@ jobs: - name: Setup Scala uses: actions/setup-java@v3.13.0 with: - distribution: temurin - java-version: '8' + distribution: corretto + java-version: '17' check-latest: true - name: Cache Dependencies uses: coursier/cache-action@v6 @@ -232,7 +231,7 @@ jobs: if: ${{ (github.event_name == 'release') && (github.event.action == 'published') }} steps: - name: Git Checkout - uses: actions/checkout@v4.0.0 + uses: actions/checkout@v4.1.0 with: fetch-depth: '0' - name: notify the main repo about the new release of docs package diff --git a/README.md b/README.md index 4df2ca73..9cec2c4e 100644 --- a/README.md +++ b/README.md @@ -140,23 +140,20 @@ test: strategy: fail-fast: false matrix: - java: - - '8' - - '11' - - '17' + java: ['11', '17', '21'] steps: - name: Install libuv run: sudo apt-get update && sudo apt-get install -y libuv1-dev - name: Setup Scala uses: actions/setup-java@v3.12.0 with: - distribution: temurin + distribution: corretto java-version: ${{ matrix.java }} check-latest: true - name: Cache Dependencies uses: coursier/cache-action@v6 - name: Git Checkout - uses: actions/checkout@v4.0.0 + uses: actions/checkout@v4.1.0 with: fetch-depth: '0' - name: Test @@ -171,12 +168,12 @@ In some cases, we may have multiple submodules in our project and we want to tes The `ciTargetScalaVersions` setting key is used to define a mapping of project names to the Scala versions that should be used for testing phase of continuous integration (CI). -For example, suppose we have a project with the name "submoduleA" and we want to test it against Scala `2.12.18`, and for the "submoduleB" we want to test it against Scala `2.12.18` and `2.13.11` and `3.3.0`, We can define the `ciTargetScalaVersions` setting as follows: +For example, suppose we have a project with the name "submoduleA" and we want to test it against Scala `2.12.18`, and for the "submoduleB" we want to test it against Scala `2.12.18` and `2.13.12` and `3.3.1`, We can define the `ciTargetScalaVersions` setting as follows: ```scala ThisBuild / ciTargetScalaVersions := Map( "submoduleA" -> Seq("2.12.18"), - "submoduleB" -> Seq("2.12.18", "2.13.11", "3.3.0") + "submoduleB" -> Seq("2.12.18", "2.13.12", "3.3.1") ) ``` @@ -207,28 +204,25 @@ test: strategy: fail-fast: false matrix: - java: - - '8' - - '11' - - '17' + java: ['11', '17', '21'] scala-project: - ++2.12.18 submoduleA - ++2.12.18 submoduleB - - ++2.13.11 submoduleB - - ++3.3.0 submoduleB + - ++2.13.12 submoduleB + - ++3.3.1 submoduleB steps: - name: Install libuv run: sudo apt-get update && sudo apt-get install -y libuv1-dev - name: Setup Scala uses: actions/setup-java@v3.10.0 with: - distribution: temurin + distribution: corretto java-version: ${{ matrix.java }} check-latest: true - name: Cache Dependencies uses: coursier/cache-action@v6 - name: Git Checkout - uses: actions/checkout@v4.0.0 + uses: actions/checkout@v4.1.0 with: fetch-depth: '0' - name: Test diff --git a/docs/index.md b/docs/index.md index 5fbd6cb1..990b5e81 100644 --- a/docs/index.md +++ b/docs/index.md @@ -138,24 +138,20 @@ test: continue-on-error: false strategy: fail-fast: false - matrix: - java: - - '8' - - '11' - - '17' + java: ['11', '17', '21'] steps: - name: Install libuv run: sudo apt-get update && sudo apt-get install -y libuv1-dev - name: Setup Scala uses: actions/setup-java@v3.12.0 with: - distribution: temurin + distribution: corretto java-version: ${{ matrix.java }} check-latest: true - name: Cache Dependencies uses: coursier/cache-action@v6 - name: Git Checkout - uses: actions/checkout@v4.0.0 + uses: actions/checkout@v4.1.0 with: fetch-depth: '0' - name: Test @@ -170,12 +166,12 @@ In some cases, we may have multiple submodules in our project and we want to tes The `ciTargetScalaVersions` setting key is used to define a mapping of project names to the Scala versions that should be used for testing phase of continuous integration (CI). -For example, suppose we have a project with the name "submoduleA" and we want to test it against Scala `2.12.18`, and for the "submoduleB" we want to test it against Scala `2.12.18` and `2.13.11` and `3.3.0`, We can define the `ciTargetScalaVersions` setting as follows: +For example, suppose we have a project with the name "submoduleA" and we want to test it against Scala `2.12.18`, and for the "submoduleB" we want to test it against Scala `2.12.18` and `2.13.12` and `3.3.1`, We can define the `ciTargetScalaVersions` setting as follows: ```scala ThisBuild / ciTargetScalaVersions := Map( "submoduleA" -> Seq("2.12.18"), - "submoduleB" -> Seq("2.12.18", "2.13.11", "3.3.0") + "submoduleB" -> Seq("2.12.18", "2.13.12", "3.3.1") ) ``` @@ -206,28 +202,25 @@ test: strategy: fail-fast: false matrix: - java: - - '8' - - '11' - - '17' + java: ['11', '17', '21'] scala-project: - ++2.12.18 submoduleA - ++2.12.18 submoduleB - - ++2.13.11 submoduleB - - ++3.3.0 submoduleB + - ++2.13.12 submoduleB + - ++3.3.1 submoduleB steps: - name: Install libuv run: sudo apt-get update && sudo apt-get install -y libuv1-dev - name: Setup Scala uses: actions/setup-java@v3.10.0 with: - distribution: temurin + distribution: corretto java-version: ${{ matrix.java }} check-latest: true - name: Cache Dependencies uses: coursier/cache-action@v6 - name: Git Checkout - uses: actions/checkout@v4.0.0 + uses: actions/checkout@v4.1.0 with: fetch-depth: '0' - name: Test diff --git a/project/Versions.scala b/project/Versions.scala index 536a8d11..01bee139 100644 --- a/project/Versions.scala +++ b/project/Versions.scala @@ -1,6 +1,6 @@ object Versions { val Scala212 = "2.12.18" - val Scala213 = "2.13.11" - val Scala3 = "3.3.0" - val zio = "2.0.16" + val Scala213 = "2.13.12" + val Scala3 = "3.3.1" + val zio = "2.0.17" } diff --git a/zio-sbt-ci/src/main/scala/zio/sbt/V.scala b/zio-sbt-ci/src/main/scala/zio/sbt/V.scala index f96dc512..f1ebd7b7 100644 --- a/zio-sbt-ci/src/main/scala/zio/sbt/V.scala +++ b/zio-sbt-ci/src/main/scala/zio/sbt/V.scala @@ -6,7 +6,7 @@ object V { "peter-evans/create-pull-request" -> "v5.0.2", "zio/generate-github-app-token" -> "v1.0.0", "pierotofy/set-swap-space" -> "master", - "actions/checkout" -> "v4.0.0", + "actions/checkout" -> "v4.1.0", "actions/setup-java" -> "v3.13.0", "coursier/cache-action" -> "v6", "actions/setup-node" -> "v3" diff --git a/zio-sbt-ci/src/main/scala/zio/sbt/ZioSbtCiPlugin.scala b/zio-sbt-ci/src/main/scala/zio/sbt/ZioSbtCiPlugin.scala index b3caedb4..a2b59f9b 100644 --- a/zio-sbt-ci/src/main/scala/zio/sbt/ZioSbtCiPlugin.scala +++ b/zio-sbt-ci/src/main/scala/zio/sbt/ZioSbtCiPlugin.scala @@ -45,7 +45,7 @@ object ZioSbtCiPlugin extends AutoPlugin { val ciUpdateReadmeCondition: SettingKey[Option[Condition]] = settingKey[Option[Condition]]("condition to update readme") val ciTargetJavaVersions: SettingKey[Seq[String]] = - settingKey[Seq[String]]("The default target Java versions for all modules, default is 8, 11, 17") + settingKey[Seq[String]]("The default target Java versions for all modules, default is 11, 17, 21") val ciTargetMinJavaVersions: SettingKey[Map[String, String]] = SettingKey[Map[String, String]]( "minimum target Java version for each module, default is an empty map which makes CI to use `ciAllTargetJavaVersions` to determine the minimum target Java version for all modules" @@ -56,7 +56,7 @@ object ZioSbtCiPlugin extends AutoPlugin { ) val ciDefaultJavaVersion: SettingKey[String] = settingKey[String]( - "The default Java version which is used in CI, especially for releasing artifacts, defaults to 8" + "The default Java version which is used in CI, especially for releasing artifacts, defaults to 17" ) val ciCheckGithubWorkflow: TaskKey[Unit] = taskKey[Unit]("Make sure if the ci.yml file is up-to-date") val ciCheckArtifactsBuildSteps: SettingKey[Seq[Step]] = @@ -187,7 +187,7 @@ object ZioSbtCiPlugin extends AutoPlugin { } } else { (for { - javaPlatform: String <- Set("8", "11", "17") + javaPlatform: String <- Set("11", "17", "21") scalaVersion: String <- scalaVersionMatrix.values.toSeq.flatten.toSet projects = scalaVersionMatrix.filterKeys { p => @@ -261,13 +261,6 @@ object ZioSbtCiPlugin extends AutoPlugin { } else { Step.StepSequence( Seq( - Step.SingleStep( - name = "Java 8 Tests", - condition = Some(Condition.Expression("matrix.java == '8'")), - run = Some( - prefixJobs + "sbt ${{ matrix.scala-project-java8 }}/test" - ) - ), Step.SingleStep( name = "Java 11 Tests", condition = Some(Condition.Expression("matrix.java == '11'")), @@ -281,6 +274,13 @@ object ZioSbtCiPlugin extends AutoPlugin { run = Some( prefixJobs + "sbt ${{ matrix.scala-project-java17 }}/test" ) + ), + Step.SingleStep( + name = "Java 21 Tests", + condition = Some(Condition.Expression("matrix.java == '21'")), + run = Some( + prefixJobs + "sbt ${{ matrix.scala-project-java21 }}/test" + ) ) ) ) @@ -521,10 +521,7 @@ object ZioSbtCiPlugin extends AutoPlugin { val nodeOptions = ciNodeOptions.value val jvmMap = Map( - // JDK_JAVA_OPTIONS is _the_ env. variable to use for modern Java - "JDK_JAVA_OPTIONS" -> jvmOptions.mkString(" "), - // For Java 8 only (sadly, it is not modern enough for JDK_JAVA_OPTIONS) - "JVM_OPTS" -> jvmOptions.mkString(" ") + "JDK_JAVA_OPTIONS" -> jvmOptions.mkString(" ") ) val nodeMap: Map[String, String] = if (nodeOptions.nonEmpty) Map("NODE_OPTIONS" -> nodeOptions.mkString(" ")) else Map.empty @@ -575,7 +572,7 @@ object ZioSbtCiPlugin extends AutoPlugin { ciUpdateReadmeCondition := None, ciGroupSimilarTests := false, ciSwapSizeGB := 0, - ciTargetJavaVersions := Seq("8", "11", "17"), + ciTargetJavaVersions := Seq("11", "17", "21"), ciCheckArtifactsBuildSteps := Seq( Step.SingleStep( @@ -600,7 +597,7 @@ object ZioSbtCiPlugin extends AutoPlugin { ), ciBackgroundJobs := Seq.empty, ciMatrixMaxParallel := None, - ciDefaultJavaVersion := "8", + ciDefaultJavaVersion := "17", ciBuildJobs := buildJobs.value, ciLintJobs := lintJobs.value, ciTestJobs := testJobs.value, @@ -662,11 +659,11 @@ object ZioSbtCiPlugin extends AutoPlugin { run = Some("sudo apt-get update && sudo apt-get install -y libuv1-dev") ) - def SetupJava(version: String = "8"): Step.SingleStep = Step.SingleStep( + def SetupJava(version: String = "17"): Step.SingleStep = Step.SingleStep( name = "Setup Scala", uses = Some(ActionRef(V("actions/setup-java"))), parameters = Map( - "distribution" -> "temurin".asJson, + "distribution" -> "corretto".asJson, "java-version" -> version.asJson, "check-latest" -> true.asJson ) diff --git a/zio-sbt-ecosystem/src/main/scala/zio/sbt/ScalaCompilerSettings.scala b/zio-sbt-ecosystem/src/main/scala/zio/sbt/ScalaCompilerSettings.scala index 16661421..c19521f4 100644 --- a/zio-sbt-ecosystem/src/main/scala/zio/sbt/ScalaCompilerSettings.scala +++ b/zio-sbt-ecosystem/src/main/scala/zio/sbt/ScalaCompilerSettings.scala @@ -158,7 +158,7 @@ trait ScalaCompilerSettings { def stdSettings( name: Option[String] = None, packageName: Option[String] = None, - javaPlatform: String = "8", + javaPlatform: String = "11", enableKindProjector: Boolean = true, enableCrossProject: Boolean = false, enableScalafix: Boolean = true, diff --git a/zio-sbt-ecosystem/src/main/scala/zio/sbt/Versions.scala b/zio-sbt-ecosystem/src/main/scala/zio/sbt/Versions.scala index bca39e40..d333e0c0 100644 --- a/zio-sbt-ecosystem/src/main/scala/zio/sbt/Versions.scala +++ b/zio-sbt-ecosystem/src/main/scala/zio/sbt/Versions.scala @@ -22,11 +22,11 @@ object Versions { val KindProjectorVersion = "0.13.2" val ScaluzziVersion = "0.1.23" - val scala3 = "3.3.0" + val scala3 = "3.3.1" val scala212 = "2.12.18" - val scala213 = "2.13.11" + val scala213 = "2.13.12" - val zioVersion = "2.0.16" + val zioVersion = "2.0.17" lazy val betterMonadFor: ModuleID = "com.olegpy" %% "better-monadic-for" % "0.3.1" } diff --git a/zio-sbt-ecosystem/src/sbt-test/zio-sbt-ecosystem/verifySettingsWithCI/.github/workflows/ci.yml b/zio-sbt-ecosystem/src/sbt-test/zio-sbt-ecosystem/verifySettingsWithCI/.github/workflows/ci.yml index 85ed6c5b..1dadb578 100644 --- a/zio-sbt-ecosystem/src/sbt-test/zio-sbt-ecosystem/verifySettingsWithCI/.github/workflows/ci.yml +++ b/zio-sbt-ecosystem/src/sbt-test/zio-sbt-ecosystem/verifySettingsWithCI/.github/workflows/ci.yml @@ -2,7 +2,6 @@ name: CI env: JDK_JAVA_OPTIONS: -XX:+PrintCommandLineFlags -Xmx6G -Xss4M -XX:+UseG1GC # JDK_JAVA_OPTIONS is _the_ env. variable to use for modern Java - JVM_OPTS: -XX:+PrintCommandLineFlags -Xmx6G -Xss4M -XX:+UseG1GC # for Java 8 only (sadly, it is not modern enough for JDK_JAVA_OPTIONS) NODE_OPTIONS: --max_old_space_size=6144 on: @@ -21,14 +20,14 @@ jobs: strategy: fail-fast: false matrix: - java: ['8', '11', '17'] + java: ['11', '17', '21'] # These version must be different than the versions in V.scala to verify that we are reading from the ci.yml file. - scala: ['2.12.18', '2.13.11', '3.3.0' ] + scala: ['2.12.18', '2.13.12', '3.3.1' ] steps: - - uses: actions/checkout@v4.0.0 + - uses: actions/checkout@v4.1.0 - uses: actions/setup-java@v3.12.0 with: - distribution: temurin + distribution: corretto java-version: ${{ matrix.java }} check-latest: true - name: Cache scala dependencies