From 0e28225acbb2b670359d4ebd59054a1e86e91563 Mon Sep 17 00:00:00 2001 From: Ivoyaa Date: Sat, 27 Apr 2024 10:32:45 +0300 Subject: [PATCH] move monofuntctor example into separate directory --- build.sbt | 164 ++++++++++-------- distage-example-monofunctor-tf/launcher | 6 + .../auto-cold/reflect-config.json | 0 .../native-image/auto-hot/proxy-config.json | 0 .../native-image/auto-hot/reflect-config.json | 0 .../native-image/auto/jni-config.json | 0 .../docker-java/reflect-config.json | 0 .../leaderboard/native-image.properties | 0 .../leaderboard/resource-config.json | 0 .../src}/main/resources/common-reference.conf | 0 .../scala/leaderboard/LeaderboardRole.scala | 0 .../main/scala/leaderboard/api/HttpApi.scala | 0 .../scala/leaderboard/api/LadderApi.scala | 0 .../scala/leaderboard/api/ProfileApi.scala | 0 .../leaderboard/config/PostgresCfg.scala | 0 .../leaderboard/config/PostgresPortCfg.scala | 0 .../scala/leaderboard/http/HttpServer.scala | 0 .../leaderboard/model/QueryFailure.scala | 0 .../leaderboard/model/RankedProfile.scala | 0 .../scala/leaderboard/model/UserProfile.scala | 0 .../scala/leaderboard/model/package.scala | 0 .../plugins/LeaderboardPlugin.scala | 0 .../plugins/PostgresDockerPlugin.scala | 0 .../main/scala/leaderboard/repo/Ladder.scala | 0 .../scala/leaderboard/repo/Profiles.scala | 0 .../scala/leaderboard/services/Ranks.scala | 0 .../src}/main/scala/leaderboard/sql/SQL.scala | 0 .../leaderboard/sql/TransactorResource.scala | 0 .../src}/test/scala/leaderboard/Rnd.scala | 0 .../test/scala/leaderboard/WiringTest.scala | 0 .../src}/test/scala/leaderboard/tests.scala | 0 .../src}/test/scala/leaderboard/zioenv.scala | 0 launcher | 4 - 33 files changed, 96 insertions(+), 78 deletions(-) create mode 100755 distage-example-monofunctor-tf/launcher rename {src => distage-example-monofunctor-tf/src}/main/resources/META-INF/native-image/auto-cold/reflect-config.json (100%) rename {src => distage-example-monofunctor-tf/src}/main/resources/META-INF/native-image/auto-hot/proxy-config.json (100%) rename {src => distage-example-monofunctor-tf/src}/main/resources/META-INF/native-image/auto-hot/reflect-config.json (100%) rename {src => distage-example-monofunctor-tf/src}/main/resources/META-INF/native-image/auto/jni-config.json (100%) rename {src => distage-example-monofunctor-tf/src}/main/resources/META-INF/native-image/docker-java/reflect-config.json (100%) rename {src => distage-example-monofunctor-tf/src}/main/resources/META-INF/native-image/leaderboard/native-image.properties (100%) rename {src => distage-example-monofunctor-tf/src}/main/resources/META-INF/native-image/leaderboard/resource-config.json (100%) rename {src => distage-example-monofunctor-tf/src}/main/resources/common-reference.conf (100%) rename {src => distage-example-monofunctor-tf/src}/main/scala/leaderboard/LeaderboardRole.scala (100%) rename {src => distage-example-monofunctor-tf/src}/main/scala/leaderboard/api/HttpApi.scala (100%) rename {src => distage-example-monofunctor-tf/src}/main/scala/leaderboard/api/LadderApi.scala (100%) rename {src => distage-example-monofunctor-tf/src}/main/scala/leaderboard/api/ProfileApi.scala (100%) rename {src => distage-example-monofunctor-tf/src}/main/scala/leaderboard/config/PostgresCfg.scala (100%) rename {src => distage-example-monofunctor-tf/src}/main/scala/leaderboard/config/PostgresPortCfg.scala (100%) rename {src => distage-example-monofunctor-tf/src}/main/scala/leaderboard/http/HttpServer.scala (100%) rename {src => distage-example-monofunctor-tf/src}/main/scala/leaderboard/model/QueryFailure.scala (100%) rename {src => distage-example-monofunctor-tf/src}/main/scala/leaderboard/model/RankedProfile.scala (100%) rename {src => distage-example-monofunctor-tf/src}/main/scala/leaderboard/model/UserProfile.scala (100%) rename {src => distage-example-monofunctor-tf/src}/main/scala/leaderboard/model/package.scala (100%) rename {src => distage-example-monofunctor-tf/src}/main/scala/leaderboard/plugins/LeaderboardPlugin.scala (100%) rename {src => distage-example-monofunctor-tf/src}/main/scala/leaderboard/plugins/PostgresDockerPlugin.scala (100%) rename {src => distage-example-monofunctor-tf/src}/main/scala/leaderboard/repo/Ladder.scala (100%) rename {src => distage-example-monofunctor-tf/src}/main/scala/leaderboard/repo/Profiles.scala (100%) rename {src => distage-example-monofunctor-tf/src}/main/scala/leaderboard/services/Ranks.scala (100%) rename {src => distage-example-monofunctor-tf/src}/main/scala/leaderboard/sql/SQL.scala (100%) rename {src => distage-example-monofunctor-tf/src}/main/scala/leaderboard/sql/TransactorResource.scala (100%) rename {src => distage-example-monofunctor-tf/src}/test/scala/leaderboard/Rnd.scala (100%) rename {src => distage-example-monofunctor-tf/src}/test/scala/leaderboard/WiringTest.scala (100%) rename {src => distage-example-monofunctor-tf/src}/test/scala/leaderboard/tests.scala (100%) rename {src => distage-example-monofunctor-tf/src}/test/scala/leaderboard/zioenv.scala (100%) delete mode 100755 launcher diff --git a/build.sbt b/build.sbt index 235ef9e..7dd5b20 100644 --- a/build.sbt +++ b/build.sbt @@ -43,6 +43,26 @@ val Deps = new { val catsCore = "org.typelevel" %% "cats-core" % V.catsCore val graalMetadata = "org.graalvm.buildtools" % "graalvm-reachability-metadata" % V.graalMetadata + + val CoreDeps = Seq( + distageCore, + distageRoles, + distageConfig, + logstageSlf4j, + distageDocker, + distageTestkit % Test, + scalatest % Test, + scalacheck % Test, + http4sDsl, + http4sServer, + http4sClient % Test, + http4sCirce, + circeGeneric, + doobie, + doobiePostgres, + doobieHikari, + graalMetadata, + ) } inThisBuild( @@ -58,79 +78,75 @@ inThisBuild( // that's just for quick experiments with distage snapshots ThisBuild / resolvers ++= Resolver.sonatypeOssRepos("snapshots") -lazy val leaderboard = project +def makeExampleProject(moduleName: String, dir: String)(deps: Seq[ModuleID]) = + Project(moduleName, file(dir)) + .settings( + name := moduleName, + libraryDependencies ++= deps, + libraryDependencies ++= { + if (scalaVersion.value.startsWith("2")) { + Seq(compilerPlugin(Deps.kindProjector)) + } else { + Seq.empty + } + }, + scalacOptions -= "-Xfatal-warnings", + scalacOptions -= "-Ykind-projector", + scalacOptions -= "-Wnonunit-statement", + scalacOptions ++= { + if (scalaVersion.value.startsWith("2")) { + Seq( + "-Xsource:3", + "-P:kind-projector:underscore-placeholders", + "-Wmacros:after", + ) + } else { + Seq( + "-source:3.2", + "-Ykind-projector:underscores", + "-Yretain-trees", + ) + } + }, + scalacOptions ++= Seq( + s"-Xmacro-settings:product-name=${name.value}", + s"-Xmacro-settings:product-version=${version.value}", + s"-Xmacro-settings:product-group=${organization.value}", + s"-Xmacro-settings:scala-version=${scalaVersion.value}", + s"-Xmacro-settings:scala-versions=${crossScalaVersions.value.mkString(":")}", + s"-Xmacro-settings:sbt-version=${sbtVersion.value}", + s"-Xmacro-settings:git-repo-clean=${git.gitUncommittedChanges.value}", + s"-Xmacro-settings:git-branch=${git.gitCurrentBranch.value}", + s"-Xmacro-settings:git-described-version=${git.gitDescribedVersion.value.getOrElse("")}", + s"-Xmacro-settings:git-head-commit=${git.gitHeadCommit.value.getOrElse("")}", + ), + GraalVMNativeImage / mainClass := Some("leaderboard.GenericLauncher"), + graalVMNativeImageOptions ++= Seq( + "--no-fallback", + "-H:+ReportExceptionStackTraces", + "--report-unsupported-elements-at-runtime", + "--enable-https", + "--enable-http", + "-J-Xmx8G", + ), + graalVMNativeImageGraalVersion := Some("ol9-java17-22.3.1"), + run / fork := true, + ) + .enablePlugins(GraalVMNativeImagePlugin, UniversalPlugin) + +lazy val root = project .in(file(".")) - .settings( - name := "leaderboard", - libraryDependencies ++= Seq( - Deps.distageCore, - Deps.distageRoles, - Deps.distageConfig, - Deps.logstageSlf4j, - Deps.distageDocker, - Deps.distageTestkit % Test, - Deps.scalatest % Test, - Deps.scalacheck % Test, - Deps.http4sDsl, - Deps.http4sServer, - Deps.http4sClient % Test, - Deps.http4sCirce, - Deps.circeGeneric, - Deps.doobie, - Deps.doobiePostgres, - Deps.doobieHikari, - Deps.zio, - Deps.zioCats, - Deps.catsCore, - Deps.graalMetadata, - ), - libraryDependencies ++= { - if (scalaVersion.value.startsWith("2")) { - Seq(compilerPlugin(Deps.kindProjector)) - } else { - Seq.empty - } - }, - scalacOptions -= "-Xfatal-warnings", - scalacOptions -= "-Ykind-projector", - scalacOptions -= "-Wnonunit-statement", - scalacOptions ++= { - if (scalaVersion.value.startsWith("2")) { - Seq( - "-Xsource:3", - "-P:kind-projector:underscore-placeholders", - "-Wmacros:after", - ) - } else { - Seq( - "-source:3.2", - "-Ykind-projector:underscores", - "-Yretain-trees", - ) - } - }, - scalacOptions ++= Seq( - s"-Xmacro-settings:product-name=${name.value}", - s"-Xmacro-settings:product-version=${version.value}", - s"-Xmacro-settings:product-group=${organization.value}", - s"-Xmacro-settings:scala-version=${scalaVersion.value}", - s"-Xmacro-settings:scala-versions=${crossScalaVersions.value.mkString(":")}", - s"-Xmacro-settings:sbt-version=${sbtVersion.value}", - s"-Xmacro-settings:git-repo-clean=${git.gitUncommittedChanges.value}", - s"-Xmacro-settings:git-branch=${git.gitCurrentBranch.value}", - s"-Xmacro-settings:git-described-version=${git.gitDescribedVersion.value.getOrElse("")}", - s"-Xmacro-settings:git-head-commit=${git.gitHeadCommit.value.getOrElse("")}", - ), - GraalVMNativeImage / mainClass := Some("leaderboard.GenericLauncher"), - graalVMNativeImageOptions ++= Seq( - "--no-fallback", - "-H:+ReportExceptionStackTraces", - "--report-unsupported-elements-at-runtime", - "--enable-https", - "--enable-http", - "-J-Xmx4G", - ), - graalVMNativeImageGraalVersion := Some("ol9-java17-22.3.1"), - run / fork := true, + .aggregate( + `leaderboard-monofunctor-tf` ) - .enablePlugins(GraalVMNativeImagePlugin, UniversalPlugin) + +lazy val `leaderboard-monofunctor-tf` = makeExampleProject( + moduleName = "leaderboard-monofunctor-tf", + dir = "distage-example-monofunctor-tf", +)(deps = + Deps.CoreDeps ++ Seq( + Deps.zio, + Deps.zioCats, + Deps.catsCore, + ) +) diff --git a/distage-example-monofunctor-tf/launcher b/distage-example-monofunctor-tf/launcher new file mode 100755 index 0000000..a887ef9 --- /dev/null +++ b/distage-example-monofunctor-tf/launcher @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +ARGS="$@" + +cd ../ +sbt "project leaderboard-monofunctor-tf; runMain leaderboard.GenericLauncher $ARGS" diff --git a/src/main/resources/META-INF/native-image/auto-cold/reflect-config.json b/distage-example-monofunctor-tf/src/main/resources/META-INF/native-image/auto-cold/reflect-config.json similarity index 100% rename from src/main/resources/META-INF/native-image/auto-cold/reflect-config.json rename to distage-example-monofunctor-tf/src/main/resources/META-INF/native-image/auto-cold/reflect-config.json diff --git a/src/main/resources/META-INF/native-image/auto-hot/proxy-config.json b/distage-example-monofunctor-tf/src/main/resources/META-INF/native-image/auto-hot/proxy-config.json similarity index 100% rename from src/main/resources/META-INF/native-image/auto-hot/proxy-config.json rename to distage-example-monofunctor-tf/src/main/resources/META-INF/native-image/auto-hot/proxy-config.json diff --git a/src/main/resources/META-INF/native-image/auto-hot/reflect-config.json b/distage-example-monofunctor-tf/src/main/resources/META-INF/native-image/auto-hot/reflect-config.json similarity index 100% rename from src/main/resources/META-INF/native-image/auto-hot/reflect-config.json rename to distage-example-monofunctor-tf/src/main/resources/META-INF/native-image/auto-hot/reflect-config.json diff --git a/src/main/resources/META-INF/native-image/auto/jni-config.json b/distage-example-monofunctor-tf/src/main/resources/META-INF/native-image/auto/jni-config.json similarity index 100% rename from src/main/resources/META-INF/native-image/auto/jni-config.json rename to distage-example-monofunctor-tf/src/main/resources/META-INF/native-image/auto/jni-config.json diff --git a/src/main/resources/META-INF/native-image/docker-java/reflect-config.json b/distage-example-monofunctor-tf/src/main/resources/META-INF/native-image/docker-java/reflect-config.json similarity index 100% rename from src/main/resources/META-INF/native-image/docker-java/reflect-config.json rename to distage-example-monofunctor-tf/src/main/resources/META-INF/native-image/docker-java/reflect-config.json diff --git a/src/main/resources/META-INF/native-image/leaderboard/native-image.properties b/distage-example-monofunctor-tf/src/main/resources/META-INF/native-image/leaderboard/native-image.properties similarity index 100% rename from src/main/resources/META-INF/native-image/leaderboard/native-image.properties rename to distage-example-monofunctor-tf/src/main/resources/META-INF/native-image/leaderboard/native-image.properties diff --git a/src/main/resources/META-INF/native-image/leaderboard/resource-config.json b/distage-example-monofunctor-tf/src/main/resources/META-INF/native-image/leaderboard/resource-config.json similarity index 100% rename from src/main/resources/META-INF/native-image/leaderboard/resource-config.json rename to distage-example-monofunctor-tf/src/main/resources/META-INF/native-image/leaderboard/resource-config.json diff --git a/src/main/resources/common-reference.conf b/distage-example-monofunctor-tf/src/main/resources/common-reference.conf similarity index 100% rename from src/main/resources/common-reference.conf rename to distage-example-monofunctor-tf/src/main/resources/common-reference.conf diff --git a/src/main/scala/leaderboard/LeaderboardRole.scala b/distage-example-monofunctor-tf/src/main/scala/leaderboard/LeaderboardRole.scala similarity index 100% rename from src/main/scala/leaderboard/LeaderboardRole.scala rename to distage-example-monofunctor-tf/src/main/scala/leaderboard/LeaderboardRole.scala diff --git a/src/main/scala/leaderboard/api/HttpApi.scala b/distage-example-monofunctor-tf/src/main/scala/leaderboard/api/HttpApi.scala similarity index 100% rename from src/main/scala/leaderboard/api/HttpApi.scala rename to distage-example-monofunctor-tf/src/main/scala/leaderboard/api/HttpApi.scala diff --git a/src/main/scala/leaderboard/api/LadderApi.scala b/distage-example-monofunctor-tf/src/main/scala/leaderboard/api/LadderApi.scala similarity index 100% rename from src/main/scala/leaderboard/api/LadderApi.scala rename to distage-example-monofunctor-tf/src/main/scala/leaderboard/api/LadderApi.scala diff --git a/src/main/scala/leaderboard/api/ProfileApi.scala b/distage-example-monofunctor-tf/src/main/scala/leaderboard/api/ProfileApi.scala similarity index 100% rename from src/main/scala/leaderboard/api/ProfileApi.scala rename to distage-example-monofunctor-tf/src/main/scala/leaderboard/api/ProfileApi.scala diff --git a/src/main/scala/leaderboard/config/PostgresCfg.scala b/distage-example-monofunctor-tf/src/main/scala/leaderboard/config/PostgresCfg.scala similarity index 100% rename from src/main/scala/leaderboard/config/PostgresCfg.scala rename to distage-example-monofunctor-tf/src/main/scala/leaderboard/config/PostgresCfg.scala diff --git a/src/main/scala/leaderboard/config/PostgresPortCfg.scala b/distage-example-monofunctor-tf/src/main/scala/leaderboard/config/PostgresPortCfg.scala similarity index 100% rename from src/main/scala/leaderboard/config/PostgresPortCfg.scala rename to distage-example-monofunctor-tf/src/main/scala/leaderboard/config/PostgresPortCfg.scala diff --git a/src/main/scala/leaderboard/http/HttpServer.scala b/distage-example-monofunctor-tf/src/main/scala/leaderboard/http/HttpServer.scala similarity index 100% rename from src/main/scala/leaderboard/http/HttpServer.scala rename to distage-example-monofunctor-tf/src/main/scala/leaderboard/http/HttpServer.scala diff --git a/src/main/scala/leaderboard/model/QueryFailure.scala b/distage-example-monofunctor-tf/src/main/scala/leaderboard/model/QueryFailure.scala similarity index 100% rename from src/main/scala/leaderboard/model/QueryFailure.scala rename to distage-example-monofunctor-tf/src/main/scala/leaderboard/model/QueryFailure.scala diff --git a/src/main/scala/leaderboard/model/RankedProfile.scala b/distage-example-monofunctor-tf/src/main/scala/leaderboard/model/RankedProfile.scala similarity index 100% rename from src/main/scala/leaderboard/model/RankedProfile.scala rename to distage-example-monofunctor-tf/src/main/scala/leaderboard/model/RankedProfile.scala diff --git a/src/main/scala/leaderboard/model/UserProfile.scala b/distage-example-monofunctor-tf/src/main/scala/leaderboard/model/UserProfile.scala similarity index 100% rename from src/main/scala/leaderboard/model/UserProfile.scala rename to distage-example-monofunctor-tf/src/main/scala/leaderboard/model/UserProfile.scala diff --git a/src/main/scala/leaderboard/model/package.scala b/distage-example-monofunctor-tf/src/main/scala/leaderboard/model/package.scala similarity index 100% rename from src/main/scala/leaderboard/model/package.scala rename to distage-example-monofunctor-tf/src/main/scala/leaderboard/model/package.scala diff --git a/src/main/scala/leaderboard/plugins/LeaderboardPlugin.scala b/distage-example-monofunctor-tf/src/main/scala/leaderboard/plugins/LeaderboardPlugin.scala similarity index 100% rename from src/main/scala/leaderboard/plugins/LeaderboardPlugin.scala rename to distage-example-monofunctor-tf/src/main/scala/leaderboard/plugins/LeaderboardPlugin.scala diff --git a/src/main/scala/leaderboard/plugins/PostgresDockerPlugin.scala b/distage-example-monofunctor-tf/src/main/scala/leaderboard/plugins/PostgresDockerPlugin.scala similarity index 100% rename from src/main/scala/leaderboard/plugins/PostgresDockerPlugin.scala rename to distage-example-monofunctor-tf/src/main/scala/leaderboard/plugins/PostgresDockerPlugin.scala diff --git a/src/main/scala/leaderboard/repo/Ladder.scala b/distage-example-monofunctor-tf/src/main/scala/leaderboard/repo/Ladder.scala similarity index 100% rename from src/main/scala/leaderboard/repo/Ladder.scala rename to distage-example-monofunctor-tf/src/main/scala/leaderboard/repo/Ladder.scala diff --git a/src/main/scala/leaderboard/repo/Profiles.scala b/distage-example-monofunctor-tf/src/main/scala/leaderboard/repo/Profiles.scala similarity index 100% rename from src/main/scala/leaderboard/repo/Profiles.scala rename to distage-example-monofunctor-tf/src/main/scala/leaderboard/repo/Profiles.scala diff --git a/src/main/scala/leaderboard/services/Ranks.scala b/distage-example-monofunctor-tf/src/main/scala/leaderboard/services/Ranks.scala similarity index 100% rename from src/main/scala/leaderboard/services/Ranks.scala rename to distage-example-monofunctor-tf/src/main/scala/leaderboard/services/Ranks.scala diff --git a/src/main/scala/leaderboard/sql/SQL.scala b/distage-example-monofunctor-tf/src/main/scala/leaderboard/sql/SQL.scala similarity index 100% rename from src/main/scala/leaderboard/sql/SQL.scala rename to distage-example-monofunctor-tf/src/main/scala/leaderboard/sql/SQL.scala diff --git a/src/main/scala/leaderboard/sql/TransactorResource.scala b/distage-example-monofunctor-tf/src/main/scala/leaderboard/sql/TransactorResource.scala similarity index 100% rename from src/main/scala/leaderboard/sql/TransactorResource.scala rename to distage-example-monofunctor-tf/src/main/scala/leaderboard/sql/TransactorResource.scala diff --git a/src/test/scala/leaderboard/Rnd.scala b/distage-example-monofunctor-tf/src/test/scala/leaderboard/Rnd.scala similarity index 100% rename from src/test/scala/leaderboard/Rnd.scala rename to distage-example-monofunctor-tf/src/test/scala/leaderboard/Rnd.scala diff --git a/src/test/scala/leaderboard/WiringTest.scala b/distage-example-monofunctor-tf/src/test/scala/leaderboard/WiringTest.scala similarity index 100% rename from src/test/scala/leaderboard/WiringTest.scala rename to distage-example-monofunctor-tf/src/test/scala/leaderboard/WiringTest.scala diff --git a/src/test/scala/leaderboard/tests.scala b/distage-example-monofunctor-tf/src/test/scala/leaderboard/tests.scala similarity index 100% rename from src/test/scala/leaderboard/tests.scala rename to distage-example-monofunctor-tf/src/test/scala/leaderboard/tests.scala diff --git a/src/test/scala/leaderboard/zioenv.scala b/distage-example-monofunctor-tf/src/test/scala/leaderboard/zioenv.scala similarity index 100% rename from src/test/scala/leaderboard/zioenv.scala rename to distage-example-monofunctor-tf/src/test/scala/leaderboard/zioenv.scala diff --git a/launcher b/launcher deleted file mode 100755 index 16ef065..0000000 --- a/launcher +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -ARGS="$@" -sbt "runMain leaderboard.GenericLauncher $ARGS"