Skip to content

Commit

Permalink
Macros multiplatform
Browse files Browse the repository at this point in the history
  • Loading branch information
sideeffffect committed Mar 5, 2023
1 parent 868cfab commit eff0dc8
Show file tree
Hide file tree
Showing 19 changed files with 45 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
81 changes: 43 additions & 38 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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,
Expand All @@ -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"))
Expand All @@ -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",
Expand Down Expand Up @@ -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"))
Expand All @@ -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
Expand All @@ -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"))
Expand All @@ -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"))
Expand All @@ -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"))
Expand All @@ -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"))
Expand All @@ -262,3 +266,4 @@ lazy val sqlserver = project
)
)
.settings(testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework"))
.enablePlugins(BuildInfoPlugin)
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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")

0 comments on commit eff0dc8

Please sign in to comment.