From eff0dc83fb3befbf86769089f78c1df18ea2b7dc Mon Sep 17 00:00:00 2001 From: Ondra Pelech Date: Sun, 5 Mar 2023 19:57:13 +0100 Subject: [PATCH] Macros multiplatform --- .github/workflows/ci.yml | 2 +- build.sbt | 81 ++++++++++--------- .../{zio-sql => zio/sql}/HelloWorldSpec.scala | 0 .../scala-2/zio/sql/macros/Normalizer.scala | 0 .../scala-2/zio/sql/macros/groupbylike.scala | 0 .../scala-2/zio/sql/macros/havinglike.scala | 0 .../scala-2/zio/sql/macros/insertlike.scala | 0 .../scala-2/zio/sql/macros/notliteral.scala | 0 .../scala-2/zio/sql/macros/tablelike.scala | 0 .../scala-2/zio/sql/macros/wherelike.scala | 0 .../scala-3/zio/sql/macros/groupbylike.scala | 0 .../scala-3/zio/sql/macros/havinglike.scala | 0 .../scala-3/zio/sql/macros/insertlike.scala | 0 .../scala-3/zio/sql/macros/normalizer.scala | 0 .../scala-3/zio/sql/macros/notliteral.scala | 0 .../scala-3/zio/sql/macros/tablelike.scala | 0 .../scala-3/zio/sql/macros/wherelike.scala | 0 .../src/main/scala/zio/sql/Features.scala | 0 project/plugins.sbt | 2 +- 19 files changed, 45 insertions(+), 40 deletions(-) rename core/shared/src/test/scala/{zio-sql => zio/sql}/HelloWorldSpec.scala (100%) rename macros/{ => shared}/src/main/scala-2/zio/sql/macros/Normalizer.scala (100%) rename macros/{ => shared}/src/main/scala-2/zio/sql/macros/groupbylike.scala (100%) rename macros/{ => shared}/src/main/scala-2/zio/sql/macros/havinglike.scala (100%) rename macros/{ => shared}/src/main/scala-2/zio/sql/macros/insertlike.scala (100%) rename macros/{ => shared}/src/main/scala-2/zio/sql/macros/notliteral.scala (100%) rename macros/{ => shared}/src/main/scala-2/zio/sql/macros/tablelike.scala (100%) rename macros/{ => shared}/src/main/scala-2/zio/sql/macros/wherelike.scala (100%) rename macros/{ => shared}/src/main/scala-3/zio/sql/macros/groupbylike.scala (100%) rename macros/{ => shared}/src/main/scala-3/zio/sql/macros/havinglike.scala (100%) rename macros/{ => shared}/src/main/scala-3/zio/sql/macros/insertlike.scala (100%) rename macros/{ => shared}/src/main/scala-3/zio/sql/macros/normalizer.scala (100%) rename macros/{ => shared}/src/main/scala-3/zio/sql/macros/notliteral.scala (100%) rename macros/{ => shared}/src/main/scala-3/zio/sql/macros/tablelike.scala (100%) rename macros/{ => shared}/src/main/scala-3/zio/sql/macros/wherelike.scala (100%) rename macros/{ => shared}/src/main/scala/zio/sql/Features.scala (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7cfc7a0a7..284805ffa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,7 +35,7 @@ jobs: fail-fast: false matrix: java: ['adopt@1.8', 'adopt@1.11'] - scala: ['2.12.17', '2.13.10'] + scala: ['2.12.*', '2.13.*'] steps: - name: Checkout current branch uses: actions/checkout@v2.3.4 diff --git a/build.sbt b/build.sbt index 429b6fe06..c988bc372 100644 --- a/build.sbt +++ b/build.sbt @@ -4,27 +4,25 @@ import sbtcrossproject.CrossPlugin.autoImport.crossProject inThisBuild( List( - organization := "dev.zio", - homepage := Some(url("https://zio.dev/zio-sql/")), - licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")), - developers := List( + organization := "dev.zio", + homepage := Some(url("https://zio.dev/zio-sql/")), + licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")), + developers := List( Developer("jdegoes", "John De Goes", "john@degoes.net", url("http://degoes.net")) - ), - pgpPassphrase := sys.env.get("PGP_PASSWORD").map(_.toArray), - pgpPublicRing := file("/tmp/public.asc"), - pgpSecretRing := file("/tmp/secret.asc"), - scmInfo := Some( - ScmInfo(url("https://github.com/zio/zio-sql/"), "scm:git:git@github.com:zio/zio-sql.git") ) ) ) addCommandAlias("fmtOnce", "all scalafmtSbt scalafmt test:scalafmt") addCommandAlias("fmt", "fmtOnce;fmtOnce") -addCommandAlias("check", "all scalafmtSbtCheck scalafmtCheck test:scalafmtCheck") +addCommandAlias("fix", "all scalafmtSbt scalafmtAll") +addCommandAlias( + "check", + "; scalafmtSbtCheck; scalafmtCheckAll; Test/compile" +) -val zioVersion = "2.0.6" -val zioSchemaVersion = "0.4.2" +val zioVersion = "2.0.9" +val zioSchemaVersion = "0.4.8" val testcontainersVersion = "1.17.6" val testcontainersScalaVersion = "0.40.11" val logbackVersion = "1.2.11" @@ -36,8 +34,8 @@ lazy val root = project unusedCompileDependenciesFilter -= moduleFilter("org.scala-js", "scalajs-library") ) .aggregate( - coreJVM, - coreJS, + core.js, + core.jvm, driver, examples, jdbc, @@ -46,48 +44,50 @@ lazy val root = project postgres, sqlserver, jdbc_hikaricp, - macros, + macros.js, + macros.jvm, docs ) lazy val core = crossProject(JSPlatform, JVMPlatform) .in(file("core")) + .dependsOn(macros) .settings(stdSettings("zio-sql")) .settings(crossProjectSettings) .settings(buildInfoSettings("zio.sql")) .settings( libraryDependencies ++= Seq( - "dev.zio" %% "zio" % zioVersion, - "dev.zio" %% "zio-streams" % zioVersion, - "dev.zio" %% "zio-schema" % zioSchemaVersion, - "dev.zio" %% "zio-schema-derivation" % zioSchemaVersion, - "dev.zio" %% "zio-test" % zioVersion % Test, - "dev.zio" %% "zio-test-sbt" % zioVersion % Test - ), - dependencyOverrides += "dev.zio" %% "zio" % zioVersion, - resolvers ++= Resolver.sonatypeOssRepos("snapshots") + "dev.zio" %%% "zio-streams" % zioVersion, + "dev.zio" %%% "zio-schema" % zioSchemaVersion, + "dev.zio" %%% "zio-schema-derivation" % zioSchemaVersion, + "dev.zio" %%% "zio-test" % zioVersion % Test, + "dev.zio" %%% "zio-test-sbt" % zioVersion % Test + ) ) .settings(testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework")) + .jsSettings( + scalaJSUseMainModuleInitializer := true + ) + .enablePlugins(BuildInfoPlugin) -lazy val coreJS = core.js - .settings(scalaJSUseMainModuleInitializer := true) - -lazy val coreJVM = core.jvm.dependsOn(macros) - -lazy val macros = project +lazy val macros = crossProject(JSPlatform, JVMPlatform) .in(file("macros")) .settings(stdSettings("zio-sql-macros")) + .settings(buildInfoSettings("zio.sql.macros")) .settings( + libraryDependencies ++= Seq( + "dev.zio" %%% "zio" % zioVersion + ), libraryDependencies ++= { if (scalaVersion.value == ScalaDotty) { Seq() } else Seq( - "org.scala-lang" % "scala-reflect" % scalaVersion.value, - "dev.zio" %% "zio" % zioVersion + "org.scala-lang" % "scala-reflect" % scalaVersion.value ) } ) + .enablePlugins(BuildInfoPlugin) lazy val docs = project .in(file("zio-sql-docs")) @@ -97,7 +97,7 @@ lazy val docs = project scalacOptions -= "-Xfatal-warnings", crossScalaVersions := Seq(Scala213, Scala212, ScalaDotty), projectName := "ZIO SQL", - mainModuleName := (coreJVM / moduleName).value, + mainModuleName := (core.jvm / moduleName).value, projectStage := ProjectStage.ProductionReady, ScalaUnidoc / unidoc / unidocProjectFilter := inProjects(), docsPublishBranch := "master", @@ -142,11 +142,10 @@ lazy val driver = project "dev.zio" %% "zio-schema-derivation" % zioSchemaVersion, "dev.zio" %% "zio-test" % zioVersion % Test, "dev.zio" %% "zio-test-sbt" % zioVersion % Test - ), - dependencyOverrides += "dev.zio" %% "zio" % zioVersion, - resolvers ++= Resolver.sonatypeOssRepos("snapshots") + ) ) .settings(testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework")) + .enablePlugins(BuildInfoPlugin) lazy val jdbc = project .in(file("jdbc")) @@ -169,11 +168,12 @@ lazy val jdbc = project ) .settings(testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework")) .dependsOn(core.jvm) + .enablePlugins(BuildInfoPlugin) lazy val jdbc_hikaricp = project .in(file("jdbc-hikaricp")) .settings(stdSettings("zio-sql-jdbc-hickaricp")) - .settings(buildInfoSettings("zio.sql.jdbc-hickaricp")) + .settings(buildInfoSettings("zio.sql.jdbc.hickaricp")) .settings( libraryDependencies ++= Seq( "com.zaxxer" % "HikariCP" % "4.0.3", // 5.x doesn't support Java 1.8 @@ -186,6 +186,7 @@ lazy val jdbc_hikaricp = project ) .settings(testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework")) .dependsOn(jdbc) + .enablePlugins(BuildInfoPlugin) lazy val mysql = project .in(file("mysql")) @@ -205,6 +206,7 @@ lazy val mysql = project ) ) .settings(testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework")) + .enablePlugins(BuildInfoPlugin) lazy val oracle = project .in(file("oracle")) @@ -224,6 +226,7 @@ lazy val oracle = project ) ) .settings(testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework")) + .enablePlugins(BuildInfoPlugin) lazy val postgres = project .in(file("postgres")) @@ -243,6 +246,7 @@ lazy val postgres = project ) ) .settings(testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework")) + .enablePlugins(BuildInfoPlugin) lazy val sqlserver = project .in(file("sqlserver")) @@ -262,3 +266,4 @@ lazy val sqlserver = project ) ) .settings(testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework")) + .enablePlugins(BuildInfoPlugin) diff --git a/core/shared/src/test/scala/zio-sql/HelloWorldSpec.scala b/core/shared/src/test/scala/zio/sql/HelloWorldSpec.scala similarity index 100% rename from core/shared/src/test/scala/zio-sql/HelloWorldSpec.scala rename to core/shared/src/test/scala/zio/sql/HelloWorldSpec.scala diff --git a/macros/src/main/scala-2/zio/sql/macros/Normalizer.scala b/macros/shared/src/main/scala-2/zio/sql/macros/Normalizer.scala similarity index 100% rename from macros/src/main/scala-2/zio/sql/macros/Normalizer.scala rename to macros/shared/src/main/scala-2/zio/sql/macros/Normalizer.scala diff --git a/macros/src/main/scala-2/zio/sql/macros/groupbylike.scala b/macros/shared/src/main/scala-2/zio/sql/macros/groupbylike.scala similarity index 100% rename from macros/src/main/scala-2/zio/sql/macros/groupbylike.scala rename to macros/shared/src/main/scala-2/zio/sql/macros/groupbylike.scala diff --git a/macros/src/main/scala-2/zio/sql/macros/havinglike.scala b/macros/shared/src/main/scala-2/zio/sql/macros/havinglike.scala similarity index 100% rename from macros/src/main/scala-2/zio/sql/macros/havinglike.scala rename to macros/shared/src/main/scala-2/zio/sql/macros/havinglike.scala diff --git a/macros/src/main/scala-2/zio/sql/macros/insertlike.scala b/macros/shared/src/main/scala-2/zio/sql/macros/insertlike.scala similarity index 100% rename from macros/src/main/scala-2/zio/sql/macros/insertlike.scala rename to macros/shared/src/main/scala-2/zio/sql/macros/insertlike.scala diff --git a/macros/src/main/scala-2/zio/sql/macros/notliteral.scala b/macros/shared/src/main/scala-2/zio/sql/macros/notliteral.scala similarity index 100% rename from macros/src/main/scala-2/zio/sql/macros/notliteral.scala rename to macros/shared/src/main/scala-2/zio/sql/macros/notliteral.scala diff --git a/macros/src/main/scala-2/zio/sql/macros/tablelike.scala b/macros/shared/src/main/scala-2/zio/sql/macros/tablelike.scala similarity index 100% rename from macros/src/main/scala-2/zio/sql/macros/tablelike.scala rename to macros/shared/src/main/scala-2/zio/sql/macros/tablelike.scala diff --git a/macros/src/main/scala-2/zio/sql/macros/wherelike.scala b/macros/shared/src/main/scala-2/zio/sql/macros/wherelike.scala similarity index 100% rename from macros/src/main/scala-2/zio/sql/macros/wherelike.scala rename to macros/shared/src/main/scala-2/zio/sql/macros/wherelike.scala diff --git a/macros/src/main/scala-3/zio/sql/macros/groupbylike.scala b/macros/shared/src/main/scala-3/zio/sql/macros/groupbylike.scala similarity index 100% rename from macros/src/main/scala-3/zio/sql/macros/groupbylike.scala rename to macros/shared/src/main/scala-3/zio/sql/macros/groupbylike.scala diff --git a/macros/src/main/scala-3/zio/sql/macros/havinglike.scala b/macros/shared/src/main/scala-3/zio/sql/macros/havinglike.scala similarity index 100% rename from macros/src/main/scala-3/zio/sql/macros/havinglike.scala rename to macros/shared/src/main/scala-3/zio/sql/macros/havinglike.scala diff --git a/macros/src/main/scala-3/zio/sql/macros/insertlike.scala b/macros/shared/src/main/scala-3/zio/sql/macros/insertlike.scala similarity index 100% rename from macros/src/main/scala-3/zio/sql/macros/insertlike.scala rename to macros/shared/src/main/scala-3/zio/sql/macros/insertlike.scala diff --git a/macros/src/main/scala-3/zio/sql/macros/normalizer.scala b/macros/shared/src/main/scala-3/zio/sql/macros/normalizer.scala similarity index 100% rename from macros/src/main/scala-3/zio/sql/macros/normalizer.scala rename to macros/shared/src/main/scala-3/zio/sql/macros/normalizer.scala diff --git a/macros/src/main/scala-3/zio/sql/macros/notliteral.scala b/macros/shared/src/main/scala-3/zio/sql/macros/notliteral.scala similarity index 100% rename from macros/src/main/scala-3/zio/sql/macros/notliteral.scala rename to macros/shared/src/main/scala-3/zio/sql/macros/notliteral.scala diff --git a/macros/src/main/scala-3/zio/sql/macros/tablelike.scala b/macros/shared/src/main/scala-3/zio/sql/macros/tablelike.scala similarity index 100% rename from macros/src/main/scala-3/zio/sql/macros/tablelike.scala rename to macros/shared/src/main/scala-3/zio/sql/macros/tablelike.scala diff --git a/macros/src/main/scala-3/zio/sql/macros/wherelike.scala b/macros/shared/src/main/scala-3/zio/sql/macros/wherelike.scala similarity index 100% rename from macros/src/main/scala-3/zio/sql/macros/wherelike.scala rename to macros/shared/src/main/scala-3/zio/sql/macros/wherelike.scala diff --git a/macros/src/main/scala/zio/sql/Features.scala b/macros/shared/src/main/scala/zio/sql/Features.scala similarity index 100% rename from macros/src/main/scala/zio/sql/Features.scala rename to macros/shared/src/main/scala/zio/sql/Features.scala diff --git a/project/plugins.sbt b/project/plugins.sbt index c81f8d2b7..5b36cc236 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -7,6 +7,6 @@ addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.6" addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.5.3") addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.9") addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies" % "0.2.16") -addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.10.1") +addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.10.4") addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.4.2") addSbtPlugin("dev.zio" % "zio-sbt-website" % "0.3.10")