diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2bfc67ef..9154a1e7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,135 +1,252 @@ -name: CI +# This file was autogenerated using `zio-sbt-ci` plugin via `sbt ciGenerateGithubWorkflow` +# task and should be included in the git repository. Please do not edit it manually. +name: CI env: - JDK_JAVA_OPTIONS: -XX:+PrintCommandLineFlags # JDK_JAVA_OPTIONS is _the_ env. variable to use for modern Java - JVM_OPTS: -XX:+PrintCommandLineFlags # for Java 8 only (sadly, it is not modern enough for JDK_JAVA_OPTIONS) - -on: - pull_request: - push: - branches: ['series/2.x'] + JDK_JAVA_OPTIONS: -XX:+PrintCommandLineFlags +'on': + workflow_dispatch: {} release: types: - - published - + - published + push: {} + pull_request: + branches-ignore: + - gh-pages jobs: - lint: - runs-on: ubuntu-20.04 - timeout-minutes: 30 - steps: - - name: Checkout current branch - uses: actions/checkout@v4.1.2 - with: - fetch-depth: 0 - - name: Setup Java - uses: actions/setup-java@v4.2.1 - with: - distribution: temurin - java-version: 11 - check-latest: true - - name: Cache scala dependencies - uses: coursier/cache-action@v6 - - name: Lint code - run: sbt check - - benchmarks: - runs-on: ubuntu-20.04 - strategy: - fail-fast: false - matrix: - java: ['11', '17'] - scala: ['2.13.13'] + build: + name: Build + runs-on: ubuntu-latest + continue-on-error: true steps: - - name: Checkout current branch - uses: actions/checkout@v4.1.2 - with: - fetch-depth: 0 - - name: Setup Java - uses: actions/setup-java@v4.2.1 - with: - distribution: temurin - java-version: ${{ matrix.java }} - check-latest: true - - name: Cache scala dependencies - uses: coursier/cache-action@v6 - - name: Compile benchmarks - run: sbt ++${{ matrix.scala }}! jmh:compile - - mdoc: - runs-on: ubuntu-20.04 - timeout-minutes: 60 + - name: Git Checkout + uses: actions/checkout@v4.1.1 + with: + fetch-depth: '0' + - name: Install libuv + run: sudo apt-get update && sudo apt-get install -y libuv1-dev + - name: Setup Scala + uses: actions/setup-java@v4.2.1 + with: + distribution: corretto + java-version: '17' + check-latest: true + - name: Cache Dependencies + uses: coursier/cache-action@v6.4.5 + - name: Check all code compiles + run: sbt +Test/compile + - name: Check artifacts build process + run: sbt +publishLocal + - name: Check website build process + run: sbt docs/clean; sbt docs/buildWebsite + lint: + name: Lint + runs-on: ubuntu-latest + continue-on-error: false steps: - - name: Checkout current branch - uses: actions/checkout@v4.1.2 - - name: Setup Java - uses: actions/setup-java@v4.2.1 - with: - distribution: temurin - java-version: 8 - check-latest: true - - name: Cache scala dependencies - uses: coursier/cache-action@v6 - - name: Check Document Generation - run: sbt compileDocs - + - name: Git Checkout + uses: actions/checkout@v4.1.1 + with: + fetch-depth: '0' + - name: Install libuv + run: sudo apt-get update && sudo apt-get install -y libuv1-dev + - name: Setup Scala + uses: actions/setup-java@v4.2.1 + with: + distribution: corretto + java-version: '17' + check-latest: true + - name: Cache Dependencies + uses: coursier/cache-action@v6.4.5 + - name: Check if the site workflow is up to date + run: sbt ciCheckGithubWorkflow + - name: Lint + run: sbt lint test: - runs-on: ubuntu-20.04 - timeout-minutes: 30 + name: Test + runs-on: ubuntu-latest + continue-on-error: false strategy: fail-fast: false matrix: - java: ['11', '17'] - scala: ['2.12.19', '2.13.13', '3.3.3'] - platform: ['JVM', 'JS', 'Native'] + java: + - '11' + - '17' + - '21' steps: - - name: Checkout current branch - uses: actions/checkout@v4.1.2 - with: - fetch-depth: 0 - - name: Setup Java - uses: actions/setup-java@v4.2.1 - with: - distribution: temurin - java-version: ${{ matrix.java }} - check-latest: true - - name: Cache scala dependencies - uses: coursier/cache-action@v6 - - name: Install libuv - if: matrix.platform == 'Native' - run: sudo apt-get update && sudo apt-get install -y libuv1-dev - - name: Run Macros tests - if: ${{ !startsWith(matrix.scala, '3.3.') }} - run: sbt ++${{ matrix.scala }}! testScala2${{ matrix.platform }} - - name: Run tests - run: sbt ++${{ matrix.scala }}! test${{ matrix.platform }} + - name: Install libuv + run: sudo apt-get update && sudo apt-get install -y libuv1-dev + - name: Setup Scala + uses: actions/setup-java@v4.2.1 + with: + distribution: corretto + java-version: ${{ matrix.java }} + check-latest: true + - name: Cache Dependencies + uses: coursier/cache-action@v6.4.5 + - name: Git Checkout + uses: actions/checkout@v4.1.1 + with: + fetch-depth: '0' + - name: Test + run: sbt +test + update-readme: + name: Update README + runs-on: ubuntu-latest + continue-on-error: false + if: ${{ github.event_name == 'push' }} + steps: + - name: Git Checkout + uses: actions/checkout@v4.1.1 + with: + fetch-depth: '0' + - name: Install libuv + run: sudo apt-get update && sudo apt-get install -y libuv1-dev + - name: Setup Scala + uses: actions/setup-java@v4.2.1 + with: + distribution: corretto + java-version: '17' + check-latest: true + - name: Cache Dependencies + uses: coursier/cache-action@v6.4.5 + - name: Generate Readme + run: sbt docs/generateReadme + - name: Commit Changes + run: | + git config --local user.email "zio-assistant[bot]@users.noreply.github.com" + git config --local user.name "ZIO Assistant" + git add README.md + git commit -m "Update README.md" || echo "No changes to commit" + - name: Generate Token + id: generate-token + uses: zio/generate-github-app-token@v1.0.0 + with: + app_id: ${{ secrets.APP_ID }} + app_private_key: ${{ secrets.APP_PRIVATE_KEY }} + - name: Create Pull Request + id: cpr + uses: peter-evans/create-pull-request@v6.0.2 + with: + body: |- + Autogenerated changes after running the `sbt docs/generateReadme` command of the [zio-sbt-website](https://zio.dev/zio-sbt) plugin. + I will automatically update the README.md file whenever there is new change for README.md, e.g. + - After each release, I will update the version in the installation section. + - After any changes to the "docs/index.md" file, I will update the README.md file accordingly. + branch: zio-sbt-website/update-readme + commit-message: Update README.md + token: ${{ steps.generate-token.outputs.token }} + delete-branch: true + title: Update README.md + - name: Approve PR + if: ${{ steps.cpr.outputs.pull-request-number }} + run: gh pr review "$PR_URL" --approve + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_URL: ${{ steps.cpr.outputs.pull-request-url }} + - name: Enable Auto-Merge + if: ${{ steps.cpr.outputs.pull-request-number }} + run: gh pr merge --auto --squash "$PR_URL" || gh pr merge --squash "$PR_URL" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_URL: ${{ steps.cpr.outputs.pull-request-url }} ci: - runs-on: ubuntu-20.04 - needs: [lint, mdoc, benchmarks, test] + name: ci + runs-on: ubuntu-latest + continue-on-error: false + needs: + - lint + - test + - build steps: - - name: Aggregate of lint, and all tests - run: echo "ci passed" - - publish: - runs-on: ubuntu-20.04 - timeout-minutes: 60 - needs: [ci] - if: github.event_name != 'pull_request' + - name: Report Successful CI + run: echo "ci passed" + release: + name: Release + runs-on: ubuntu-latest + continue-on-error: false + needs: + - ci + if: ${{ github.event_name != 'pull_request' }} + steps: + - name: Git Checkout + uses: actions/checkout@v4.1.1 + with: + fetch-depth: '0' + - name: Install libuv + run: sudo apt-get update && sudo apt-get install -y libuv1-dev + - name: Setup Scala + uses: actions/setup-java@v4.2.1 + with: + distribution: corretto + java-version: '17' + check-latest: true + - name: Cache Dependencies + uses: coursier/cache-action@v6.4.5 + - name: Release + run: sbt ci-release + env: + PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} + PGP_SECRET: ${{ secrets.PGP_SECRET }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + release-docs: + name: Release Docs + runs-on: ubuntu-latest + continue-on-error: false + needs: + - release + if: ${{ ((github.event_name == 'release') && (github.event.action == 'published')) || (github.event_name == 'workflow_dispatch') }} + steps: + - name: Git Checkout + uses: actions/checkout@v4.1.1 + with: + fetch-depth: '0' + - name: Install libuv + run: sudo apt-get update && sudo apt-get install -y libuv1-dev + - name: Setup Scala + uses: actions/setup-java@v4.2.1 + with: + distribution: corretto + java-version: '17' + check-latest: true + - name: Cache Dependencies + uses: coursier/cache-action@v6.4.5 + - name: Setup NodeJs + uses: actions/setup-node@v4 + with: + node-version: 16.x + registry-url: https://registry.npmjs.org + - name: Publish Docs to NPM Registry + run: sbt docs/publishToNpm + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + notify-docs-release: + name: Notify Docs Release + runs-on: ubuntu-latest + continue-on-error: false + needs: + - release-docs + if: ${{ (github.event_name == 'release') && (github.event.action == 'published') }} steps: - - name: Checkout current branch - uses: actions/checkout@v4.1.2 - with: - fetch-depth: 0 - - name: Setup Java - uses: actions/setup-java@v4.2.1 - with: - distribution: temurin - java-version: 8 - check-latest: true - - name: Release - run: sbt ci-release - env: - PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} - PGP_SECRET: ${{ secrets.PGP_SECRET }} - SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} - SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + - name: Git Checkout + uses: actions/checkout@v4.1.1 + with: + fetch-depth: '0' + - name: notify the main repo about the new release of docs package + run: | + PACKAGE_NAME=$(cat docs/package.json | grep '"name"' | awk -F'"' '{print $4}') + PACKAGE_VERSION=$(npm view $PACKAGE_NAME version) + curl -L \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: token ${{ secrets.PAT_TOKEN }}"\ + https://api.github.com/repos/zio/zio/dispatches \ + -d '{ + "event_type":"update-docs", + "client_payload":{ + "package_name":"'"${PACKAGE_NAME}"'", + "package_version": "'"${PACKAGE_VERSION}"'" + } + }' diff --git a/.java-version b/.java-version index da2d3988..98d9bcb7 100644 --- a/.java-version +++ b/.java-version @@ -1 +1 @@ -14 \ No newline at end of file +17 diff --git a/build.sbt b/build.sbt index aa577ae1..11147617 100644 --- a/build.sbt +++ b/build.sbt @@ -4,8 +4,14 @@ import sbtcrossproject.CrossPlugin.autoImport.crossProject Global / onChangedBuildSource := IgnoreSourceChanges +enablePlugins(ZioSbtEcosystemPlugin, ZioSbtCiPlugin) + inThisBuild( List( + name := "zio-json", + scala212 := Scala212, + scala213 := Scala213, + scala3 := Scala3, organization := "dev.zio", homepage := Some(url("https://zio.dev/zio-json/")), licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")), @@ -64,7 +70,7 @@ lazy val zioJsonRoot = project unusedCompileDependenciesFilter -= moduleFilter("org.scala-js", "scalajs-library") ) .aggregate( - docs, + //docs, zioJsonJVM, zioJsonJS, zioJson.native, @@ -86,10 +92,9 @@ val circeVersion = "0.14.3" lazy val zioJson = crossProject(JSPlatform, JVMPlatform, NativePlatform) .in(file("zio-json")) - .settings(stdSettings("zio-json")) + .settings(zjsonStdSettings("zio-json")) .settings(crossProjectSettings) .settings(buildInfoSettings("zio.json")) - .enablePlugins(NeoJmhPlugin) .settings( scalacOptions -= "-Xfatal-warnings", // not quite ready. @@ -97,7 +102,7 @@ lazy val zioJson = crossProject(JSPlatform, JVMPlatform, NativePlatform) scalacOptions -= "-opt:l:inline", scalacOptions -= "-opt-inline-from:zio.internal.**", Test / scalacOptions ++= { - if (scalaVersion.value == ScalaDotty) + if (scalaVersion.value == Scala3) Vector("-Yretain-trees") else Vector.empty @@ -269,7 +274,7 @@ lazy val zioJsonJVM = zioJson.jvm lazy val zioJsonGolden = project .in(file("zio-json-golden")) - .settings(stdSettings("zio-json-golden")) + .settings(zjsonStdSettings("zio-json-golden")) .settings(buildInfoSettings("zio.json.golden")) .settings( libraryDependencies ++= Seq( @@ -285,7 +290,7 @@ lazy val zioJsonGolden = project lazy val zioJsonYaml = project .in(file("zio-json-yaml")) - .settings(stdSettings("zio-json-yaml")) + .settings(zjsonStdSettings("zio-json-yaml")) .settings(buildInfoSettings("zio.json.yaml")) .settings( libraryDependencies ++= Seq( @@ -302,11 +307,11 @@ lazy val zioJsonYaml = project lazy val zioJsonMacros = crossProject(JSPlatform, JVMPlatform, NativePlatform) .in(file("zio-json-macros")) .nativeConfigure(_.dependsOn(zioJson.native)) - .settings(stdSettings("zio-json-macros")) + .settings(zjsonStdSettings("zio-json-macros")) .settings(crossProjectSettings) .settings(macroExpansionSettings) .settings( - crossScalaVersions -= ScalaDotty, + crossScalaVersions -= Scala3, scalacOptions -= "-Xfatal-warnings", // not quite ready. libraryDependencies ++= Seq( "org.scala-lang" % "scala-reflect" % scalaVersion.value % Provided, @@ -325,10 +330,10 @@ lazy val zioJsonMacrosJS = zioJsonMacros.js lazy val zioJsonInteropHttp4s = project .in(file("zio-json-interop-http4s")) - .settings(stdSettings("zio-json-interop-http4s")) + .settings(zjsonStdSettings("zio-json-interop-http4s")) .settings(buildInfoSettings("zio.json.interop.http4s")) .settings( - crossScalaVersions -= ScalaDotty, + crossScalaVersions -= Scala3, libraryDependencies ++= Seq( "org.http4s" %% "http4s-dsl" % "0.23.26", "dev.zio" %% "zio" % zioVersion, @@ -345,11 +350,11 @@ lazy val zioJsonInteropHttp4s = project lazy val zioJsonInteropRefined = crossProject(JSPlatform, JVMPlatform, NativePlatform) .in(file("zio-json-interop-refined")) .dependsOn(zioJson) - .settings(stdSettings("zio-json-interop-refined")) + .settings(zjsonStdSettings("zio-json-interop-refined")) .settings(buildInfoSettings("zio.json.interop.refined")) .settings( libraryDependencies ++= Seq( - "eu.timepit" %%% "refined" % "0.10.2", + "eu.timepit" %%% "refined" % "0.11.1", "dev.zio" %%% "zio-test" % zioVersion % "test", "dev.zio" %%% "zio-test-sbt" % zioVersion % "test" ), @@ -360,10 +365,10 @@ lazy val zioJsonInteropRefined = crossProject(JSPlatform, JVMPlatform, NativePla lazy val zioJsonInteropScalaz7x = crossProject(JSPlatform, JVMPlatform, NativePlatform) .in(file("zio-json-interop-scalaz7x")) .dependsOn(zioJson) - .settings(stdSettings("zio-json-interop-scalaz7x")) + .settings(zjsonStdSettings("zio-json-interop-scalaz7x")) .settings(buildInfoSettings("zio.json.interop.scalaz7x")) .settings( - crossScalaVersions -= ScalaDotty, + crossScalaVersions -= Scala3, libraryDependencies ++= Seq( "org.scalaz" %%% "scalaz-core" % "7.3.7", "dev.zio" %%% "zio-test" % zioVersion % "test", @@ -385,7 +390,7 @@ lazy val docs = project zioJsonInteropScalaz7x.jvm ) .settings( - crossScalaVersions -= ScalaDotty, + crossScalaVersions -= Scala3, moduleName := "zio-json-docs", scalacOptions += "-Ymacro-annotations", projectName := "ZIO JSON", diff --git a/project/BuildHelper.scala b/project/BuildHelper.scala index 9fb86145..f689f4dc 100644 --- a/project/BuildHelper.scala +++ b/project/BuildHelper.scala @@ -1,26 +1,12 @@ -import explicitdeps.ExplicitDepsPlugin.autoImport._ -import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport._ -import sbt.Keys._ -import sbt._ -import sbtbuildinfo.BuildInfoKeys._ -import sbtbuildinfo._ -import sbtcrossproject.CrossPlugin.autoImport._ +import explicitdeps.ExplicitDepsPlugin.autoImport.* +import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport.* +import sbt.* +import sbt.Keys.* object BuildHelper { - private val versions: Map[String, String] = { - import org.snakeyaml.engine.v2.api.{ Load, LoadSettings } - import java.util.{ List => JList, Map => JMap } - import scala.jdk.CollectionConverters._ - - val doc = new Load(LoadSettings.builder().build()) - .loadFromReader(scala.io.Source.fromFile(".github/workflows/ci.yml").bufferedReader()) - val yaml = doc.asInstanceOf[JMap[String, JMap[String, JMap[String, JMap[String, JMap[String, JList[String]]]]]]] - val list = yaml.get("jobs").get("test").get("strategy").get("matrix").get("scala").asScala - list.map(v => (v.split('.').take(2).mkString("."), v)).toMap - } - val Scala212: String = versions("2.12") - val Scala213: String = versions("2.13") - val ScalaDotty: String = "3.3.3" + val Scala212: String = "2.12.19" + val Scala213: String = "2.13.13" + val Scala3: String = "3.3.3" val SilencerVersion = "1.7.16" @@ -56,29 +42,29 @@ object BuildHelper { ) else Nil - def buildInfoSettings(packageName: String) = - Seq( - buildInfoKeys := Seq[BuildInfoKey](organization, moduleName, name, version, scalaVersion, sbtVersion, isSnapshot), - buildInfoPackage := packageName - ) +// def buildInfoSettings(packageName: String) = +// Seq( +// buildInfoKeys := Seq[BuildInfoKey](organization, moduleName, name, version, scalaVersion, sbtVersion, isSnapshot), +// buildInfoPackage := packageName +// ) val dottySettings = Seq( - crossScalaVersions += ScalaDotty, + crossScalaVersions += Scala3, scalacOptions ++= { - if (scalaVersion.value == ScalaDotty) + if (scalaVersion.value == Scala3) Seq("-noindent") else Seq() }, scalacOptions --= { - if (scalaVersion.value == ScalaDotty) + if (scalaVersion.value == Scala3) Seq("-Xfatal-warnings") else Seq() }, Compile / doc / sources := { val old = (Compile / doc / sources).value - if (scalaVersion.value == ScalaDotty) { + if (scalaVersion.value == Scala3) { Nil } else { old @@ -86,7 +72,7 @@ object BuildHelper { }, Test / parallelExecution := { val old = (Test / parallelExecution).value - if (scalaVersion.value == ScalaDotty) { + if (scalaVersion.value == Scala3) { false } else { old @@ -191,32 +177,32 @@ object BuildHelper { platformSpecificSources(platform, conf, baseDir)(versions: _*) } - lazy val crossProjectSettings = Seq( - Compile / unmanagedSourceDirectories ++= { - crossPlatformSources( - scalaVersion.value, - crossProjectPlatform.value.identifier, - "main", - baseDirectory.value - ) - }, - Test / unmanagedSourceDirectories ++= { - crossPlatformSources( - scalaVersion.value, - crossProjectPlatform.value.identifier, - "test", - baseDirectory.value - ) - } - ) +// lazy val crossProjectSettings = Seq( +// Compile / unmanagedSourceDirectories ++= { +// crossPlatformSources( +// scalaVersion.value, +// crossProjectPlatform.value.identifier, +// "main", +// baseDirectory.value +// ) +// }, +// Test / unmanagedSourceDirectories ++= { +// crossPlatformSources( +// scalaVersion.value, +// crossProjectPlatform.value.identifier, +// "test", +// baseDirectory.value +// ) +// } +// ) - def stdSettings(prjName: String) = Seq( + def zjsonStdSettings(prjName: String) = Seq( name := s"$prjName", - crossScalaVersions := Seq(Scala212, Scala213, ScalaDotty), + crossScalaVersions := Seq(Scala212, Scala213, Scala3), ThisBuild / scalaVersion := Scala213, scalacOptions ++= stdOptions ++ extraOptions(scalaVersion.value, optimize = !isSnapshot.value), libraryDependencies ++= { - if (scalaVersion.value == ScalaDotty) + if (scalaVersion.value == Scala3) Seq( "com.github.ghik" % s"silencer-lib_$Scala213" % SilencerVersion % Provided ) @@ -227,7 +213,7 @@ object BuildHelper { compilerPlugin("org.typelevel" %% "kind-projector" % "0.13.3" cross CrossVersion.full) ) }, - semanticdbEnabled := scalaVersion.value != ScalaDotty, // enable SemanticDB + semanticdbEnabled := scalaVersion.value != Scala3, // enable SemanticDB semanticdbOptions += "-P:semanticdb:synthetics:on", semanticdbVersion := "4.9.2", Test / parallelExecution := true, @@ -236,26 +222,26 @@ object BuildHelper { unusedCompileDependenciesFilter -= moduleFilter("org.scala-js", "scalajs-library") ) - def macroExpansionSettings = Seq( - scalacOptions ++= { - CrossVersion.partialVersion(scalaVersion.value) match { - case Some((2, 13)) => Seq("-Ymacro-annotations") - case _ => Seq.empty - } - }, - libraryDependencies ++= { - CrossVersion.partialVersion(scalaVersion.value) match { - case Some((2, x)) if x <= 12 => - Seq(compilerPlugin(("org.scalamacros" % "paradise" % "2.1.1").cross(CrossVersion.full))) - case _ => Seq.empty - } - } - ) +// def macroExpansionSettings = Seq( +// scalacOptions ++= { +// CrossVersion.partialVersion(scalaVersion.value) match { +// case Some((2, 13)) => Seq("-Ymacro-annotations") +// case _ => Seq.empty +// } +// }, +// libraryDependencies ++= { +// CrossVersion.partialVersion(scalaVersion.value) match { +// case Some((2, x)) if x <= 12 => +// Seq(compilerPlugin(("org.scalamacros" % "paradise" % "2.1.1").cross(CrossVersion.full))) +// case _ => Seq.empty +// } +// } +// ) def macroDefinitionSettings = Seq( scalacOptions += "-language:experimental.macros", libraryDependencies ++= { - if (scalaVersion.value == ScalaDotty) Seq() + if (scalaVersion.value == Scala3) Seq() else Seq( "org.scala-lang" % "scala-reflect" % scalaVersion.value % "provided", @@ -277,7 +263,7 @@ object BuildHelper { val scalaReflectTestSettings: List[Setting[_]] = List( libraryDependencies ++= { - if (scalaVersion.value == ScalaDotty) + if (scalaVersion.value == Scala3) Seq("org.scala-lang" % "scala-reflect" % Scala213 % Test) else Seq("org.scala-lang" % "scala-reflect" % scalaVersion.value % Test) @@ -285,7 +271,6 @@ object BuildHelper { ) def welcomeMessage = onLoadMessage := { - import scala.Console def header(text: String): String = s"${Console.RED}$text${Console.RESET}" @@ -312,6 +297,6 @@ object BuildHelper { } implicit class ModuleHelper(p: Project) { - def module: Project = p.in(file(p.id)).settings(stdSettings(p.id)) + def module: Project = p.in(file(p.id)).settings(zjsonStdSettings(p.id)) } } diff --git a/project/NeoJmhPlugin.scala b/project/NeoJmhPlugin.scala deleted file mode 100644 index a831c348..00000000 --- a/project/NeoJmhPlugin.scala +++ /dev/null @@ -1,165 +0,0 @@ -package fommil - -import sbt._ -import sbt.Keys._ - -import scala.collection.immutable.Set -import scala.util.Try - -object NeoJmhKeys { - - val jmhVersion = settingKey[String]("version of jmh") - val jmhExtrasVersion = settingKey[String]("version of jmh-extras") - - /** Where you put your JMH code. */ - val Jmh = config("jmh") extend Test - - val neoJmhGenerator = settingKey[String]("Available: `reflection` or `asm`") - - /** - * If non-empty, yourkit will be enabled. - * - * https://www.yourkit.com/docs/java/help/startup_options.jsp - */ - val neoJmhYourkit = - settingKey[Seq[String]]("Startup options for Yourkit") - -} - -/** - * https://github.com/ktoso/sbt-jmh/ rewritten as an idiomatic sbt - * Configuration (not requiring a separate Project). - */ -object NeoJmhPlugin extends AutoPlugin { - import NeoJmhKeys._ - val autoImport = NeoJmhKeys - - val JmhInternal = (config("jmh-internal") extend Test).hide - - val generateJmhSourcesAndResources = taskKey[(Seq[File], Seq[File])]( - "Generate benchmark JMH Java code and resources" - ) - - override def requires = plugins.JvmPlugin - override def trigger = noTrigger - override def projectConfigurations = Seq(Jmh, JmhInternal) - - override def buildSettings = Seq( - jmhVersion := "1.36", - jmhExtrasVersion := "0.3.7" - ) - - override def projectSettings = - inConfig(Jmh)( - Defaults.testSettings ++ Seq( - run := (JmhInternal / run).evaluated, - neoJmhGenerator := "reflection", - neoJmhYourkit := Nil, - javaOptions ++= Seq( - "-XX:+PerfDisableSharedMem", - "-XX:+AlwaysPreTouch", - "-Xms1g", - "-Xmx1g" - ), - javaOptions ++= { - if (neoJmhYourkit.value.isEmpty) Nil - else { - val flags = "=" + neoJmhYourkit.value.mkString(",") - List(s"-agentpath:${sys.env("YOURKIT_AGENT")}$flags") - } - } - ) - ) ++ inConfig(JmhInternal)( - Defaults.testSettings ++ Seq( - javaOptions := (Jmh / javaOptions).value, - envVars := (Jmh / envVars).value, - run / mainClass := Some("org.openjdk.jmh.Main"), - run / fork := true, - dependencyClasspath ++= (Jmh / fullClasspath).value, - sourceGenerators += generateJmhSourcesAndResources.map { case (sources, _) => - sources - }, - resourceGenerators += generateJmhSourcesAndResources.map { case (_, res) => - res - }, - generateJmhSourcesAndResources := generateBenchmarkSourcesAndResources.value - ) - ) ++ Seq( - libraryDependencies ++= Seq( - "jmh-core", - "jmh-generator-bytecode", - "jmh-generator-reflection", - "jmh-generator-asm" - ).map( - // WORKAROUND: https://github.com/sbt/sbt/issues/1380 - "org.openjdk.jmh" % _ % jmhVersion.value % s"${Jmh.name},test" - ) :+ "pl.project13.scala" % "sbt-jmh-extras" % jmhExtrasVersion.value % s"${Jmh.name},test" - ) ++ backCompatProjectSettings - - implicit class BackCompatDepOverrides[A](val deps: Set[A]) { - def compat: Seq[A] = deps.toSeq - } - - implicit class BackCompatForkRun(val result: Try[Unit]) { - def dealWithIt(): Unit = result.failed.foreach(f => sys.error(f.getMessage)) - } - - def backCompatProjectSettings: Seq[Setting[_]] = Seq( - // WORKAROUND https://github.com/sbt/sbt/issues/3935 - NeoJmhPlugin.JmhInternal / dependencyClasspathAsJars ++= (NeoJmhKeys.Jmh / fullClasspathAsJars).value - ) - - def generateBenchmarkSourcesAndResources: Def.Initialize[Task[(Seq[File], Seq[File])]] = Def.task { - val s = streams.value - val cacheDir = crossTarget.value / "jmh-cache" - val bytecodeDir = (Jmh / classDirectory).value - val sourceDir = sourceManaged.value - val resourceDir = resourceManaged.value - val generator = (Jmh / neoJmhGenerator).value - val classpath = dependencyClasspath.value - val javaHomeV = (Jmh / javaHome).value - val outputStrategyV = (Jmh / outputStrategy).value - val workingDirectory = Option((Jmh / baseDirectory).value) - val connectInputV = (Jmh / connectInput).value - val envVarsV = (Jmh / envVars).value - val javaFlags = (Jmh / javaOptions).value.toVector - - val inputs: Set[File] = (bytecodeDir ** "*").filter(_.isFile).get.toSet - val cachedGeneration = FileFunction.cached(cacheDir, FilesInfo.hash) { _ => - IO.delete(sourceDir) - IO.createDirectory(sourceDir) - IO.delete(resourceDir) - IO.createDirectory(resourceDir) - - val options = ForkOptions( - javaHome = javaHomeV, - outputStrategy = outputStrategyV, - bootJars = Vector.empty[java.io.File], - workingDirectory = workingDirectory, - runJVMOptions = javaFlags, - connectInput = connectInputV, - envVars = envVarsV - ) - new ForkRun(options) - .run( - "org.openjdk.jmh.generators.bytecode.JmhBytecodeGenerator", - Attributed.data(classpath), - List( - bytecodeDir.getPath, - sourceDir.getPath, - resourceDir.getPath, - generator - ), - s.log - ) - .dealWithIt() - - ((sourceDir ** "*").filter(_.isFile) +++ (resourceDir ** "*").filter( - _.isFile - )).get.toSet - } - cachedGeneration(inputs).toSeq - .partition(f => IO.relativizeFile(sourceDir, f).nonEmpty) - } - -} diff --git a/project/plugins.sbt b/project/plugins.sbt index 458f709e..d194c477 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -10,6 +10,8 @@ addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.17") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.0") addSbtPlugin("pl.project13.scala" % "sbt-jcstress" % "0.2.0") addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.11") +addSbtPlugin("dev.zio" % "zio-sbt-ecosystem" % "0.4.0-alpha.25") addSbtPlugin("dev.zio" % "zio-sbt-website" % "0.4.0-alpha.25") +addSbtPlugin("dev.zio" % "zio-sbt-ci" % "0.4.0-alpha.25") libraryDependencies += "org.snakeyaml" % "snakeyaml-engine" % "2.7" diff --git a/zio-json-interop-refined/shared/src/main/scala/zio/json/interop/refined/package.scala b/zio-json-interop-refined/shared/src/main/scala/zio/json/interop/refined/package.scala index ba558edc..6dbe2948 100644 --- a/zio-json-interop-refined/shared/src/main/scala/zio/json/interop/refined/package.scala +++ b/zio-json-interop-refined/shared/src/main/scala/zio/json/interop/refined/package.scala @@ -3,7 +3,8 @@ package zio.json.interop import eu.timepit.refined.api.{ Refined, Validate } import eu.timepit.refined.{ refineV } import zio.json._ - +//Scala 2 only for now, since macro migration for Scala 3 is not done yet +// https://github.com/fthomas/refined/issues/932 package object refined { implicit def encodeRefined[A: JsonEncoder, B]: JsonEncoder[A Refined B] = JsonEncoder[A].contramap(_.value) diff --git a/zio-json-interop-refined/shared/src/test/scala/zio/json/interop/refined/RefinedSpec.scala b/zio-json-interop-refined/shared/src/test/scala-2/zio/json/interop/refined/RefinedSpec.scala similarity index 100% rename from zio-json-interop-refined/shared/src/test/scala/zio/json/interop/refined/RefinedSpec.scala rename to zio-json-interop-refined/shared/src/test/scala-2/zio/json/interop/refined/RefinedSpec.scala