From f8d21be7cd3b36bd5056edb271c83e4e48cedd09 Mon Sep 17 00:00:00 2001 From: "Paul S." Date: Tue, 13 Aug 2024 18:05:49 +0100 Subject: [PATCH] #1968: locator-private bindings (#2162) * #1968: private bindings PoC * #1968: private bindings PoC * #1968: locator-private bindings PoC * #1968: public roots mode * #1968: public roots mode for bootstrap injector * docs * bootstrap planning mode customization * docs * locator pretty-print * locator pretty-print * better formatting * better formatting --- build.sbt | 1236 +++++++---------- .../scala/izumi/distage/AbstractLocator.scala | 15 +- .../scala/izumi/distage/model/Locator.scala | 24 +- .../scala/izumi/distage/model/Planner.scala | 15 +- .../izumi/distage/model/PlannerInput.scala | 62 +- .../distage/model/definition/BindingTag.scala | 3 + .../distage/model/definition/LocatorDef.scala | 14 +- .../model/definition/LocatorPrivacy.scala | 17 + .../dsl/AbstractBindingDefDSL.scala | 14 +- .../model/definition/dsl/IncludesDSL.scala | 8 +- .../model/definition/dsl/ModuleDefDSL.scala | 22 +- .../model/definition/dsl/Tagging.scala | 10 + .../plan/repr/DIPlanCompactFormatter.scala | 5 +- .../model/plan/repr/LocatorFormatter.scala | 25 + .../izumi/distage/gc/GcBasicTestsJvm.scala | 208 ++- .../distage/injector/AnimalModelTestJvm.scala | 26 +- .../injector/CglibProxiesTestJvm.scala | 4 +- .../src/main/scala/distage/Distage.scala | 3 + .../src/main/scala/distage/Injector.scala | 23 +- .../src/main/scala/distage/package.scala | 3 + .../izumi/distage/InjectorDefaultImpl.scala | 22 +- .../scala/izumi/distage/InjectorFactory.scala | 14 +- .../izumi/distage/LocatorDefaultImpl.scala | 5 + .../distage/bootstrap/BootstrapLocator.scala | 25 +- .../bootstrap/BootstrapRootsMode.scala | 15 + .../scala/izumi/distage/model/Injector.scala | 15 +- .../distage/model/recursive/Bootloader.scala | 8 +- .../distage/planning/AutoSetModule.scala | 4 +- .../distage/planning/SubcontextHandler.scala | 2 +- ...nInterpreterNonSequentialRuntimeImpl.scala | 51 +- .../provisioning/ProvisionMutable.scala | 5 +- .../distage/injector/InnerClassesTest.scala | 23 +- .../scala/izumi/distage/dsl/DSLTest.scala | 2 +- .../scala/izumi/distage/gc/GcBasicTests.scala | 6 +- .../izumi/distage/impl/BootstrapTest.scala | 13 +- .../izumi/distage/injector/AxisTest.scala | 36 +- .../distage/injector/PlanOperationsTest.scala | 2 +- .../injector/PrivateBindingsTest.scala | 110 ++ .../injector/ResourceEffectBindingsTest.scala | 6 +- .../izumi/distage/config/ConfigTest.scala | 3 +- .../distage/config/AppConfigModule.scala | 2 +- .../logstage/distage/LogstageModule.scala | 1 + .../test3/bootstrap/BootstrapFixture3.scala | 4 +- .../distage/roles/test/RoleAppTest.scala | 6 +- .../framework/services/ModuleProvider.scala | 8 +- .../framework/services/RoleAppPlanner.scala | 21 +- .../distage/roles/RoleAppBootModule.scala | 2 +- .../testkit/runner/impl/TestPlanner.scala | 6 +- .../testkit/runner/impl/TestTreeBuilder.scala | 2 +- .../distage/testkit/spec/DistageTestEnv.scala | 2 +- .../src/main/tut/distage/advanced-features.md | 2 +- doc/microsite/src/main/tut/distage/basics.md | 2 +- project/plugins.sbt | 11 - 53 files changed, 1136 insertions(+), 1037 deletions(-) create mode 100644 distage/distage-core-api/src/main/scala/izumi/distage/model/definition/LocatorPrivacy.scala create mode 100644 distage/distage-core-api/src/main/scala/izumi/distage/model/definition/dsl/Tagging.scala create mode 100644 distage/distage-core-api/src/main/scala/izumi/distage/model/plan/repr/LocatorFormatter.scala create mode 100644 distage/distage-core/src/main/scala/izumi/distage/bootstrap/BootstrapRootsMode.scala create mode 100644 distage/distage-core/src/test/scala/izumi/distage/injector/PrivateBindingsTest.scala diff --git a/build.sbt b/build.sbt index b66f126afc..dac36f5a5b 100644 --- a/build.sbt +++ b/build.sbt @@ -3,26 +3,38 @@ // ALL CHANGES WILL BE LOST -import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType} - import com.github.sbt.git.SbtGit.GitKeys._ enablePlugins(SbtgenVerificationPlugin) disablePlugins(AssemblyPlugin) -lazy val `fundamentals-basics` = crossProject(JVMPlatform, JSPlatform).crossType(CrossType.Pure).in(file("fundamentals/fundamentals-basics")) +lazy val `fundamentals-basics` = project.in(file("fundamentals/fundamentals-basics")) .settings( libraryDependencies ++= Seq( - "org.scala-lang.modules" %%% "scala-collection-compat" % V.collection_compat, - "org.scalatest" %%% "scalatest" % V.scalatest % Test + "org.scala-lang.modules" %% "scala-collection-compat" % V.collection_compat, + "org.scalatest" %% "scalatest" % V.scalatest % Test ), libraryDependencies ++= { if (scalaVersion.value.startsWith("2.")) Seq( compilerPlugin("org.typelevel" % "kind-projector" % V.kind_projector cross CrossVersion.full) ) else Seq.empty } ) .settings( + crossScalaVersions := Seq( + "3.3.4-RC1", + "2.13.14", + "2.12.19" + ), + scalaVersion := crossScalaVersions.value.head, organization := "io.7mind.izumi", + Compile / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/main/scala" , + Compile / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/main/scala-$v").distinct, + Compile / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/main/resources" , + Test / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/test/scala" , + Test / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/test/scala-$v").distinct, + Test / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/test/resources" , scalacOptions ++= Seq( s"-Xmacro-settings:product-name=${name.value}", s"-Xmacro-settings:product-version=${version.value}", @@ -201,45 +213,38 @@ lazy val `fundamentals-basics` = crossProject(JVMPlatform, JSPlatform).crossType } }, Test / packageDoc / publishArtifact := false ) - .jvmSettings( - crossScalaVersions := Seq( - "3.3.4-RC1", - "2.13.14", - "2.12.19" - ), - scalaVersion := crossScalaVersions.value.head - ) - .jsSettings( - crossScalaVersions := Seq( - "3.3.4-RC1", - "2.13.14", - "2.12.19" - ), - scalaVersion := crossScalaVersions.value.head, - coverageEnabled := false, - scalaJSLinkerConfig := { scalaJSLinkerConfig.value.withBatchMode(true).withModuleKind(ModuleKind.CommonJSModule) } - ) .enablePlugins(SitePreviewPlugin) -lazy val `fundamentals-basicsJVM` = `fundamentals-basics`.jvm - .disablePlugins(AssemblyPlugin) -lazy val `fundamentals-basicsJS` = `fundamentals-basics`.js .disablePlugins(AssemblyPlugin) -lazy val `fundamentals-functional` = crossProject(JVMPlatform, JSPlatform).crossType(CrossType.Pure).in(file("fundamentals/fundamentals-functional")) +lazy val `fundamentals-functional` = project.in(file("fundamentals/fundamentals-functional")) .dependsOn( `fundamentals-basics` % "test->compile;compile->compile" ) .settings( libraryDependencies ++= Seq( - "org.scala-lang.modules" %%% "scala-collection-compat" % V.collection_compat, - "org.scalatest" %%% "scalatest" % V.scalatest % Test + "org.scala-lang.modules" %% "scala-collection-compat" % V.collection_compat, + "org.scalatest" %% "scalatest" % V.scalatest % Test ), libraryDependencies ++= { if (scalaVersion.value.startsWith("2.")) Seq( compilerPlugin("org.typelevel" % "kind-projector" % V.kind_projector cross CrossVersion.full) ) else Seq.empty } ) .settings( + crossScalaVersions := Seq( + "3.3.4-RC1", + "2.13.14", + "2.12.19" + ), + scalaVersion := crossScalaVersions.value.head, organization := "io.7mind.izumi", + Compile / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/main/scala" , + Compile / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/main/scala-$v").distinct, + Compile / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/main/resources" , + Test / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/test/scala" , + Test / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/test/scala-$v").distinct, + Test / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/test/resources" , scalacOptions ++= Seq( s"-Xmacro-settings:product-name=${name.value}", s"-Xmacro-settings:product-version=${version.value}", @@ -418,46 +423,39 @@ lazy val `fundamentals-functional` = crossProject(JVMPlatform, JSPlatform).cross } }, Test / packageDoc / publishArtifact := false ) - .jvmSettings( - crossScalaVersions := Seq( - "3.3.4-RC1", - "2.13.14", - "2.12.19" - ), - scalaVersion := crossScalaVersions.value.head - ) - .jsSettings( - crossScalaVersions := Seq( - "3.3.4-RC1", - "2.13.14", - "2.12.19" - ), - scalaVersion := crossScalaVersions.value.head, - coverageEnabled := false, - scalaJSLinkerConfig := { scalaJSLinkerConfig.value.withBatchMode(true).withModuleKind(ModuleKind.CommonJSModule) } - ) .enablePlugins(SitePreviewPlugin) -lazy val `fundamentals-functionalJVM` = `fundamentals-functional`.jvm - .disablePlugins(AssemblyPlugin) -lazy val `fundamentals-functionalJS` = `fundamentals-functional`.js .disablePlugins(AssemblyPlugin) -lazy val `fundamentals-collections` = crossProject(JVMPlatform, JSPlatform).crossType(CrossType.Pure).in(file("fundamentals/fundamentals-collections")) +lazy val `fundamentals-collections` = project.in(file("fundamentals/fundamentals-collections")) .dependsOn( `fundamentals-basics` % "test->compile;compile->compile", `fundamentals-functional` % "test->compile;compile->compile" ) .settings( libraryDependencies ++= Seq( - "org.scala-lang.modules" %%% "scala-collection-compat" % V.collection_compat, - "org.scalatest" %%% "scalatest" % V.scalatest % Test + "org.scala-lang.modules" %% "scala-collection-compat" % V.collection_compat, + "org.scalatest" %% "scalatest" % V.scalatest % Test ), libraryDependencies ++= { if (scalaVersion.value.startsWith("2.")) Seq( compilerPlugin("org.typelevel" % "kind-projector" % V.kind_projector cross CrossVersion.full) ) else Seq.empty } ) .settings( + crossScalaVersions := Seq( + "3.3.4-RC1", + "2.13.14", + "2.12.19" + ), + scalaVersion := crossScalaVersions.value.head, organization := "io.7mind.izumi", + Compile / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/main/scala" , + Compile / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/main/scala-$v").distinct, + Compile / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/main/resources" , + Test / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/test/scala" , + Test / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/test/scala-$v").distinct, + Test / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/test/resources" , scalacOptions ++= Seq( s"-Xmacro-settings:product-name=${name.value}", s"-Xmacro-settings:product-version=${version.value}", @@ -636,38 +634,17 @@ lazy val `fundamentals-collections` = crossProject(JVMPlatform, JSPlatform).cros } }, Test / packageDoc / publishArtifact := false ) - .jvmSettings( - crossScalaVersions := Seq( - "3.3.4-RC1", - "2.13.14", - "2.12.19" - ), - scalaVersion := crossScalaVersions.value.head - ) - .jsSettings( - crossScalaVersions := Seq( - "3.3.4-RC1", - "2.13.14", - "2.12.19" - ), - scalaVersion := crossScalaVersions.value.head, - coverageEnabled := false, - scalaJSLinkerConfig := { scalaJSLinkerConfig.value.withBatchMode(true).withModuleKind(ModuleKind.CommonJSModule) } - ) .enablePlugins(SitePreviewPlugin) -lazy val `fundamentals-collectionsJVM` = `fundamentals-collections`.jvm - .disablePlugins(AssemblyPlugin) -lazy val `fundamentals-collectionsJS` = `fundamentals-collections`.js .disablePlugins(AssemblyPlugin) -lazy val `fundamentals-literals` = crossProject(JVMPlatform, JSPlatform).crossType(CrossType.Pure).in(file("fundamentals/fundamentals-literals")) +lazy val `fundamentals-literals` = project.in(file("fundamentals/fundamentals-literals")) .dependsOn( `fundamentals-basics` % "test->compile;compile->compile" ) .settings( libraryDependencies ++= Seq( - "org.scala-lang.modules" %%% "scala-collection-compat" % V.collection_compat, - "org.scalatest" %%% "scalatest" % V.scalatest % Test + "org.scala-lang.modules" %% "scala-collection-compat" % V.collection_compat, + "org.scalatest" %% "scalatest" % V.scalatest % Test ), libraryDependencies ++= { if (scalaVersion.value.startsWith("2.")) Seq( compilerPlugin("org.typelevel" % "kind-projector" % V.kind_projector cross CrossVersion.full), @@ -675,7 +652,21 @@ lazy val `fundamentals-literals` = crossProject(JVMPlatform, JSPlatform).crossTy ) else Seq.empty } ) .settings( + crossScalaVersions := Seq( + "3.3.4-RC1", + "2.13.14", + "2.12.19" + ), + scalaVersion := crossScalaVersions.value.head, organization := "io.7mind.izumi", + Compile / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/main/scala" , + Compile / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/main/scala-$v").distinct, + Compile / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/main/resources" , + Test / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/test/scala" , + Test / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/test/scala-$v").distinct, + Test / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/test/resources" , scalacOptions ++= Seq( s"-Xmacro-settings:product-name=${name.value}", s"-Xmacro-settings:product-version=${version.value}", @@ -854,50 +845,43 @@ lazy val `fundamentals-literals` = crossProject(JVMPlatform, JSPlatform).crossTy } }, Test / packageDoc / publishArtifact := false ) - .jvmSettings( - crossScalaVersions := Seq( - "3.3.4-RC1", - "2.13.14", - "2.12.19" - ), - scalaVersion := crossScalaVersions.value.head - ) - .jsSettings( - crossScalaVersions := Seq( - "3.3.4-RC1", - "2.13.14", - "2.12.19" - ), - scalaVersion := crossScalaVersions.value.head, - coverageEnabled := false, - scalaJSLinkerConfig := { scalaJSLinkerConfig.value.withBatchMode(true).withModuleKind(ModuleKind.CommonJSModule) } - ) .enablePlugins(SitePreviewPlugin) -lazy val `fundamentals-literalsJVM` = `fundamentals-literals`.jvm - .disablePlugins(AssemblyPlugin) -lazy val `fundamentals-literalsJS` = `fundamentals-literals`.js .disablePlugins(AssemblyPlugin) -lazy val `fundamentals-orphans` = crossProject(JVMPlatform, JSPlatform).crossType(CrossType.Pure).in(file("fundamentals/fundamentals-orphans")) +lazy val `fundamentals-orphans` = project.in(file("fundamentals/fundamentals-orphans")) .dependsOn( `fundamentals-basics` % "test->compile;compile->compile" ) .settings( libraryDependencies ++= Seq( - "org.scala-lang.modules" %%% "scala-collection-compat" % V.collection_compat, - "org.scalatest" %%% "scalatest" % V.scalatest % Test, - "org.typelevel" %%% "cats-core" % V.cats % Optional, - "org.typelevel" %%% "cats-effect" % V.cats_effect % Optional, - "dev.zio" %%% "zio" % V.zio % Optional excludeAll("dev.zio" %% "izumi-reflect"), - "dev.zio" %%% "izumi-reflect" % V.izumi_reflect % Optional, - "dev.zio" %%% "zio-interop-cats" % V.zio_interop_cats % Optional excludeAll("dev.zio" %% "izumi-reflect") + "org.scala-lang.modules" %% "scala-collection-compat" % V.collection_compat, + "org.scalatest" %% "scalatest" % V.scalatest % Test, + "org.typelevel" %% "cats-core" % V.cats % Optional, + "org.typelevel" %% "cats-effect" % V.cats_effect % Optional, + "dev.zio" %% "zio" % V.zio % Optional excludeAll("dev.zio" %% "izumi-reflect"), + "dev.zio" %% "izumi-reflect" % V.izumi_reflect % Optional, + "dev.zio" %% "zio-interop-cats" % V.zio_interop_cats % Optional excludeAll("dev.zio" %% "izumi-reflect") ), libraryDependencies ++= { if (scalaVersion.value.startsWith("2.")) Seq( compilerPlugin("org.typelevel" % "kind-projector" % V.kind_projector cross CrossVersion.full) ) else Seq.empty } ) .settings( + crossScalaVersions := Seq( + "3.3.4-RC1", + "2.13.14", + "2.12.19" + ), + scalaVersion := crossScalaVersions.value.head, organization := "io.7mind.izumi", + Compile / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/main/scala" , + Compile / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/main/scala-$v").distinct, + Compile / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/main/resources" , + Test / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/test/scala" , + Test / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/test/scala-$v").distinct, + Test / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/test/resources" , scalacOptions ++= Seq( s"-Xmacro-settings:product-name=${name.value}", s"-Xmacro-settings:product-version=${version.value}", @@ -1080,39 +1064,18 @@ lazy val `fundamentals-orphans` = crossProject(JVMPlatform, JSPlatform).crossTyp case (_, _) => (Compile / doc / sources).value } } ) - .jvmSettings( - crossScalaVersions := Seq( - "3.3.4-RC1", - "2.13.14", - "2.12.19" - ), - scalaVersion := crossScalaVersions.value.head - ) - .jsSettings( - crossScalaVersions := Seq( - "3.3.4-RC1", - "2.13.14", - "2.12.19" - ), - scalaVersion := crossScalaVersions.value.head, - coverageEnabled := false, - scalaJSLinkerConfig := { scalaJSLinkerConfig.value.withBatchMode(true).withModuleKind(ModuleKind.CommonJSModule) } - ) .enablePlugins(SitePreviewPlugin) -lazy val `fundamentals-orphansJVM` = `fundamentals-orphans`.jvm - .disablePlugins(AssemblyPlugin) -lazy val `fundamentals-orphansJS` = `fundamentals-orphans`.js .disablePlugins(AssemblyPlugin) -lazy val `fundamentals-language` = crossProject(JVMPlatform, JSPlatform).crossType(CrossType.Pure).in(file("fundamentals/fundamentals-language")) +lazy val `fundamentals-language` = project.in(file("fundamentals/fundamentals-language")) .dependsOn( `fundamentals-literals` % "test->compile;compile->compile", `fundamentals-basics` % "test->compile;compile->compile" ) .settings( libraryDependencies ++= Seq( - "org.scala-lang.modules" %%% "scala-collection-compat" % V.collection_compat, - "org.scalatest" %%% "scalatest" % V.scalatest % Test + "org.scala-lang.modules" %% "scala-collection-compat" % V.collection_compat, + "org.scalatest" %% "scalatest" % V.scalatest % Test ), libraryDependencies ++= { if (scalaVersion.value.startsWith("2.")) Seq( compilerPlugin("org.typelevel" % "kind-projector" % V.kind_projector cross CrossVersion.full), @@ -1128,7 +1091,21 @@ lazy val `fundamentals-language` = crossProject(JVMPlatform, JSPlatform).crossTy } ) .settings( + crossScalaVersions := Seq( + "3.3.4-RC1", + "2.13.14", + "2.12.19" + ), + scalaVersion := crossScalaVersions.value.head, organization := "io.7mind.izumi", + Compile / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/main/scala" , + Compile / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/main/scala-$v").distinct, + Compile / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/main/resources" , + Test / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/test/scala" , + Test / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/test/scala-$v").distinct, + Test / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/test/resources" , scalacOptions ++= Seq( s"-Xmacro-settings:product-name=${name.value}", s"-Xmacro-settings:product-version=${version.value}", @@ -1307,32 +1284,10 @@ lazy val `fundamentals-language` = crossProject(JVMPlatform, JSPlatform).crossTy } }, Test / packageDoc / publishArtifact := false ) - .jvmSettings( - crossScalaVersions := Seq( - "3.3.4-RC1", - "2.13.14", - "2.12.19" - ), - scalaVersion := crossScalaVersions.value.head - ) - .jsSettings( - crossScalaVersions := Seq( - "3.3.4-RC1", - "2.13.14", - "2.12.19" - ), - scalaVersion := crossScalaVersions.value.head, - coverageEnabled := false, - scalaJSLinkerConfig := { scalaJSLinkerConfig.value.withBatchMode(true).withModuleKind(ModuleKind.CommonJSModule) } - ) .enablePlugins(SitePreviewPlugin) -lazy val `fundamentals-languageJVM` = `fundamentals-language`.jvm - .disablePlugins(AssemblyPlugin) -lazy val `fundamentals-languageJS` = `fundamentals-language`.js - .enablePlugins(ScalaJSBundlerPlugin) .disablePlugins(AssemblyPlugin) -lazy val `fundamentals-platform` = crossProject(JVMPlatform, JSPlatform).crossType(CrossType.Pure).in(file("fundamentals/fundamentals-platform")) +lazy val `fundamentals-platform` = project.in(file("fundamentals/fundamentals-platform")) .dependsOn( `fundamentals-functional` % "test->compile;compile->compile", `fundamentals-basics` % "test->compile;compile->compile", @@ -1341,9 +1296,9 @@ lazy val `fundamentals-platform` = crossProject(JVMPlatform, JSPlatform).crossTy ) .settings( libraryDependencies ++= Seq( - "org.scala-lang.modules" %%% "scala-collection-compat" % V.collection_compat, - "org.scalatest" %%% "scalatest" % V.scalatest % Test, - "dev.zio" %%% "izumi-reflect" % V.izumi_reflect + "org.scala-lang.modules" %% "scala-collection-compat" % V.collection_compat, + "org.scalatest" %% "scalatest" % V.scalatest % Test, + "dev.zio" %% "izumi-reflect" % V.izumi_reflect ), libraryDependencies ++= { if (scalaVersion.value.startsWith("2.")) Seq( compilerPlugin("org.typelevel" % "kind-projector" % V.kind_projector cross CrossVersion.full), @@ -1351,7 +1306,21 @@ lazy val `fundamentals-platform` = crossProject(JVMPlatform, JSPlatform).crossTy ) else Seq.empty } ) .settings( + crossScalaVersions := Seq( + "3.3.4-RC1", + "2.13.14", + "2.12.19" + ), + scalaVersion := crossScalaVersions.value.head, organization := "io.7mind.izumi", + Compile / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/main/scala" , + Compile / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/main/scala-$v").distinct, + Compile / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/main/resources" , + Test / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/test/scala" , + Test / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/test/scala-$v").distinct, + Test / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/test/resources" , scalacOptions ++= Seq( s"-Xmacro-settings:product-name=${name.value}", s"-Xmacro-settings:product-version=${version.value}", @@ -1530,35 +1499,10 @@ lazy val `fundamentals-platform` = crossProject(JVMPlatform, JSPlatform).crossTy } }, Test / packageDoc / publishArtifact := false ) - .jvmSettings( - crossScalaVersions := Seq( - "3.3.4-RC1", - "2.13.14", - "2.12.19" - ), - scalaVersion := crossScalaVersions.value.head - ) - .jsSettings( - crossScalaVersions := Seq( - "3.3.4-RC1", - "2.13.14", - "2.12.19" - ), - scalaVersion := crossScalaVersions.value.head, - coverageEnabled := false, - scalaJSLinkerConfig := { scalaJSLinkerConfig.value.withBatchMode(true).withModuleKind(ModuleKind.CommonJSModule) }, - Test / npmDependencies ++= Seq( - ( "hash.js", "1.1.7") - ) - ) .enablePlugins(SitePreviewPlugin) -lazy val `fundamentals-platformJVM` = `fundamentals-platform`.jvm - .disablePlugins(AssemblyPlugin) -lazy val `fundamentals-platformJS` = `fundamentals-platform`.js - .enablePlugins(ScalaJSBundlerPlugin) .disablePlugins(AssemblyPlugin) -lazy val `fundamentals-functoid` = crossProject(JVMPlatform, JSPlatform).crossType(CrossType.Pure).in(file("fundamentals/fundamentals-functoid")) +lazy val `fundamentals-functoid` = project.in(file("fundamentals/fundamentals-functoid")) .dependsOn( `fundamentals-platform` % "test->compile;compile->compile", `fundamentals-language` % "test->compile;compile->compile", @@ -1566,9 +1510,9 @@ lazy val `fundamentals-functoid` = crossProject(JVMPlatform, JSPlatform).crossTy ) .settings( libraryDependencies ++= Seq( - "org.scala-lang.modules" %%% "scala-collection-compat" % V.collection_compat, - "org.scalatest" %%% "scalatest" % V.scalatest % Test, - "dev.zio" %%% "izumi-reflect" % V.izumi_reflect + "org.scala-lang.modules" %% "scala-collection-compat" % V.collection_compat, + "org.scalatest" %% "scalatest" % V.scalatest % Test, + "dev.zio" %% "izumi-reflect" % V.izumi_reflect ), libraryDependencies ++= { if (scalaVersion.value.startsWith("2.")) Seq( compilerPlugin("org.typelevel" % "kind-projector" % V.kind_projector cross CrossVersion.full), @@ -1576,7 +1520,21 @@ lazy val `fundamentals-functoid` = crossProject(JVMPlatform, JSPlatform).crossTy ) else Seq.empty } ) .settings( + crossScalaVersions := Seq( + "3.3.4-RC1", + "2.13.14", + "2.12.19" + ), + scalaVersion := crossScalaVersions.value.head, organization := "io.7mind.izumi", + Compile / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/main/scala" , + Compile / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/main/scala-$v").distinct, + Compile / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/main/resources" , + Test / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/test/scala" , + Test / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/test/scala-$v").distinct, + Test / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/test/resources" , scalacOptions ++= Seq( s"-Xmacro-settings:product-name=${name.value}", s"-Xmacro-settings:product-version=${version.value}", @@ -1755,59 +1713,52 @@ lazy val `fundamentals-functoid` = crossProject(JVMPlatform, JSPlatform).crossTy } }, Test / packageDoc / publishArtifact := false ) - .jvmSettings( - crossScalaVersions := Seq( - "3.3.4-RC1", - "2.13.14", - "2.12.19" - ), - scalaVersion := crossScalaVersions.value.head - ) - .jsSettings( - crossScalaVersions := Seq( - "3.3.4-RC1", - "2.13.14", - "2.12.19" - ), - scalaVersion := crossScalaVersions.value.head, - coverageEnabled := false, - scalaJSLinkerConfig := { scalaJSLinkerConfig.value.withBatchMode(true).withModuleKind(ModuleKind.CommonJSModule) } - ) .enablePlugins(SitePreviewPlugin) -lazy val `fundamentals-functoidJVM` = `fundamentals-functoid`.jvm - .disablePlugins(AssemblyPlugin) -lazy val `fundamentals-functoidJS` = `fundamentals-functoid`.js .disablePlugins(AssemblyPlugin) -lazy val `fundamentals-json-circe` = crossProject(JVMPlatform, JSPlatform).crossType(CrossType.Pure).in(file("fundamentals/fundamentals-json-circe")) +lazy val `fundamentals-json-circe` = project.in(file("fundamentals/fundamentals-json-circe")) .dependsOn( `fundamentals-platform` % "test->compile;compile->compile" ) .settings( libraryDependencies ++= Seq( - "org.scala-lang.modules" %%% "scala-collection-compat" % V.collection_compat, - "org.scalatest" %%% "scalatest" % V.scalatest % Test, - "io.circe" %%% "circe-core" % V.circe, + "org.scala-lang.modules" %% "scala-collection-compat" % V.collection_compat, + "org.scalatest" %% "scalatest" % V.scalatest % Test, + "io.circe" %% "circe-core" % V.circe, "org.typelevel" %% "jawn-parser" % V.jawn % Test, - "io.circe" %%% "circe-literal" % V.circe % Test + "io.circe" %% "circe-literal" % V.circe % Test ), libraryDependencies ++= { if (scalaVersion.value.startsWith("2.")) Seq( compilerPlugin("org.typelevel" % "kind-projector" % V.kind_projector cross CrossVersion.full), "org.scala-lang" % "scala-reflect" % scalaVersion.value % Provided, - "io.circe" %%% "circe-derivation" % V.circe_derivation % Test, - "io.circe" %%% "circe-generic" % V.circe % Test + "io.circe" %% "circe-derivation" % V.circe_derivation % Test, + "io.circe" %% "circe-generic" % V.circe % Test ) else Seq.empty }, libraryDependencies ++= { val version = scalaVersion.value if (version.startsWith("0.") || version.startsWith("3.")) { Seq( - "io.circe" %%% "circe-generic" % V.circe + "io.circe" %% "circe-generic" % V.circe ) } else Seq.empty } ) .settings( + crossScalaVersions := Seq( + "3.3.4-RC1", + "2.13.14", + "2.12.19" + ), + scalaVersion := crossScalaVersions.value.head, organization := "io.7mind.izumi", + Compile / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/main/scala" , + Compile / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/main/scala-$v").distinct, + Compile / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/main/resources" , + Test / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/test/scala" , + Test / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/test/scala-$v").distinct, + Test / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/test/resources" , scalacOptions ++= Seq( s"-Xmacro-settings:product-name=${name.value}", s"-Xmacro-settings:product-version=${version.value}", @@ -1988,31 +1939,10 @@ lazy val `fundamentals-json-circe` = crossProject(JVMPlatform, JSPlatform).cross Compile / libraryDependencySchemes += "io.circe" %% "circe-core" % VersionScheme.Always, Compile / libraryDependencySchemes += "io.circe" %% "circe-core_sjs1" % VersionScheme.Always ) - .jvmSettings( - crossScalaVersions := Seq( - "3.3.4-RC1", - "2.13.14", - "2.12.19" - ), - scalaVersion := crossScalaVersions.value.head - ) - .jsSettings( - crossScalaVersions := Seq( - "3.3.4-RC1", - "2.13.14", - "2.12.19" - ), - scalaVersion := crossScalaVersions.value.head, - coverageEnabled := false, - scalaJSLinkerConfig := { scalaJSLinkerConfig.value.withBatchMode(true).withModuleKind(ModuleKind.CommonJSModule) } - ) .enablePlugins(SitePreviewPlugin) -lazy val `fundamentals-json-circeJVM` = `fundamentals-json-circe`.jvm - .disablePlugins(AssemblyPlugin) -lazy val `fundamentals-json-circeJS` = `fundamentals-json-circe`.js .disablePlugins(AssemblyPlugin) -lazy val `fundamentals-bio` = crossProject(JVMPlatform, JSPlatform).crossType(CrossType.Pure).in(file("fundamentals/fundamentals-bio")) +lazy val `fundamentals-bio` = project.in(file("fundamentals/fundamentals-bio")) .dependsOn( `fundamentals-language` % "test->compile;compile->compile", `fundamentals-orphans` % "test->compile;compile->compile", @@ -2021,27 +1951,41 @@ lazy val `fundamentals-bio` = crossProject(JVMPlatform, JSPlatform).crossType(Cr ) .settings( libraryDependencies ++= Seq( - "org.scala-lang.modules" %%% "scala-collection-compat" % V.collection_compat, - "org.scalatest" %%% "scalatest" % V.scalatest % Test, - "org.typelevel" %%% "cats-core" % V.cats % Optional, - "org.typelevel" %%% "cats-effect" % V.cats_effect % Optional, - "dev.zio" %%% "zio" % V.zio % Optional excludeAll("dev.zio" %% "izumi-reflect"), - "dev.zio" %%% "izumi-reflect" % V.izumi_reflect % Optional, - "dev.zio" %%% "zio-managed" % V.zio % Optional excludeAll("dev.zio" %% "izumi-reflect"), - "dev.zio" %%% "zio-interop-tracer" % V.zio_interop_cats, - "org.typelevel" %%% "cats-effect-laws" % V.cats_effect % Test, - "org.typelevel" %%% "cats-effect-testkit" % V.cats_effect % Test, - "org.scalatest" %%% "scalatest" % V.scalatest % Test, - "org.typelevel" %%% "discipline-core" % V.discipline % Test, - "org.typelevel" %%% "discipline-scalatest" % V.discipline_scalatest % Test, - "dev.zio" %%% "zio-interop-cats" % V.zio_interop_cats % Test excludeAll("dev.zio" %% "izumi-reflect") + "org.scala-lang.modules" %% "scala-collection-compat" % V.collection_compat, + "org.scalatest" %% "scalatest" % V.scalatest % Test, + "org.typelevel" %% "cats-core" % V.cats % Optional, + "org.typelevel" %% "cats-effect" % V.cats_effect % Optional, + "dev.zio" %% "zio" % V.zio % Optional excludeAll("dev.zio" %% "izumi-reflect"), + "dev.zio" %% "izumi-reflect" % V.izumi_reflect % Optional, + "dev.zio" %% "zio-managed" % V.zio % Optional excludeAll("dev.zio" %% "izumi-reflect"), + "dev.zio" %% "zio-interop-tracer" % V.zio_interop_cats, + "org.typelevel" %% "cats-effect-laws" % V.cats_effect % Test, + "org.typelevel" %% "cats-effect-testkit" % V.cats_effect % Test, + "org.scalatest" %% "scalatest" % V.scalatest % Test, + "org.typelevel" %% "discipline-core" % V.discipline % Test, + "org.typelevel" %% "discipline-scalatest" % V.discipline_scalatest % Test, + "dev.zio" %% "zio-interop-cats" % V.zio_interop_cats % Test excludeAll("dev.zio" %% "izumi-reflect") ), libraryDependencies ++= { if (scalaVersion.value.startsWith("2.")) Seq( compilerPlugin("org.typelevel" % "kind-projector" % V.kind_projector cross CrossVersion.full) ) else Seq.empty } ) .settings( + crossScalaVersions := Seq( + "3.3.4-RC1", + "2.13.14", + "2.12.19" + ), + scalaVersion := crossScalaVersions.value.head, organization := "io.7mind.izumi", + Compile / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/main/scala" , + Compile / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/main/scala-$v").distinct, + Compile / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/main/resources" , + Test / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/test/scala" , + Test / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/test/scala-$v").distinct, + Test / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/test/resources" , scalacOptions ++= Seq( s"-Xmacro-settings:product-name=${name.value}", s"-Xmacro-settings:product-version=${version.value}", @@ -2224,36 +2168,10 @@ lazy val `fundamentals-bio` = crossProject(JVMPlatform, JSPlatform).crossType(Cr case (_, _) => (Compile / doc / sources).value } } ) - .jvmSettings( - crossScalaVersions := Seq( - "3.3.4-RC1", - "2.13.14", - "2.12.19" - ), - scalaVersion := crossScalaVersions.value.head - ) - .jsSettings( - crossScalaVersions := Seq( - "3.3.4-RC1", - "2.13.14", - "2.12.19" - ), - scalaVersion := crossScalaVersions.value.head, - coverageEnabled := false, - scalaJSLinkerConfig := { scalaJSLinkerConfig.value.withBatchMode(true).withModuleKind(ModuleKind.CommonJSModule) } - ) .enablePlugins(SitePreviewPlugin) -lazy val `fundamentals-bioJVM` = `fundamentals-bio`.jvm - .disablePlugins(AssemblyPlugin) -lazy val `fundamentals-bioJS` = `fundamentals-bio`.js - .settings( - libraryDependencies ++= Seq( - "io.github.cquiroz" %%% "scala-java-time" % V.scala_java_time % Test - ) - ) .disablePlugins(AssemblyPlugin) -lazy val `distage-core-api` = crossProject(JVMPlatform, JSPlatform).crossType(CrossType.Pure).in(file("distage/distage-core-api")) +lazy val `distage-core-api` = project.in(file("distage/distage-core-api")) .dependsOn( `fundamentals-platform` % "test->compile;compile->compile", `fundamentals-functoid` % "test->compile;compile->compile", @@ -2261,17 +2179,17 @@ lazy val `distage-core-api` = crossProject(JVMPlatform, JSPlatform).crossType(Cr ) .settings( libraryDependencies ++= Seq( - "org.scala-lang.modules" %%% "scala-collection-compat" % V.collection_compat, - "org.scalatest" %%% "scalatest" % V.scalatest % Test, - "org.typelevel" %%% "cats-core" % V.cats % Optional, - "org.typelevel" %%% "cats-effect" % V.cats_effect % Optional, - "dev.zio" %%% "zio" % V.zio % Optional excludeAll("dev.zio" %% "izumi-reflect"), - "dev.zio" %%% "izumi-reflect" % V.izumi_reflect % Optional, - "org.typelevel" %%% "cats-core" % V.cats % Test, - "org.typelevel" %%% "cats-effect" % V.cats_effect % Test, - "dev.zio" %%% "zio" % V.zio % Test excludeAll("dev.zio" %% "izumi-reflect"), - "dev.zio" %%% "izumi-reflect" % V.izumi_reflect % Test, - "dev.zio" %%% "zio-managed" % V.zio % Optional excludeAll("dev.zio" %% "izumi-reflect") + "org.scala-lang.modules" %% "scala-collection-compat" % V.collection_compat, + "org.scalatest" %% "scalatest" % V.scalatest % Test, + "org.typelevel" %% "cats-core" % V.cats % Optional, + "org.typelevel" %% "cats-effect" % V.cats_effect % Optional, + "dev.zio" %% "zio" % V.zio % Optional excludeAll("dev.zio" %% "izumi-reflect"), + "dev.zio" %% "izumi-reflect" % V.izumi_reflect % Optional, + "org.typelevel" %% "cats-core" % V.cats % Test, + "org.typelevel" %% "cats-effect" % V.cats_effect % Test, + "dev.zio" %% "zio" % V.zio % Test excludeAll("dev.zio" %% "izumi-reflect"), + "dev.zio" %% "izumi-reflect" % V.izumi_reflect % Test, + "dev.zio" %% "zio-managed" % V.zio % Optional excludeAll("dev.zio" %% "izumi-reflect") ), libraryDependencies ++= { if (scalaVersion.value.startsWith("2.")) Seq( compilerPlugin("org.typelevel" % "kind-projector" % V.kind_projector cross CrossVersion.full), @@ -2279,7 +2197,21 @@ lazy val `distage-core-api` = crossProject(JVMPlatform, JSPlatform).crossType(Cr ) else Seq.empty } ) .settings( + crossScalaVersions := Seq( + "3.3.4-RC1", + "2.13.14", + "2.12.19" + ), + scalaVersion := crossScalaVersions.value.head, organization := "io.7mind.izumi", + Compile / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/main/scala" , + Compile / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/main/scala-$v").distinct, + Compile / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/main/resources" , + Test / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/test/scala" , + Test / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/test/scala-$v").distinct, + Test / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/test/resources" , scalacOptions ++= Seq( s"-Xmacro-settings:product-name=${name.value}", s"-Xmacro-settings:product-version=${version.value}", @@ -2458,33 +2390,12 @@ lazy val `distage-core-api` = crossProject(JVMPlatform, JSPlatform).crossType(Cr } }, Test / packageDoc / publishArtifact := false ) - .jvmSettings( - crossScalaVersions := Seq( - "3.3.4-RC1", - "2.13.14", - "2.12.19" - ), - scalaVersion := crossScalaVersions.value.head - ) - .jsSettings( - crossScalaVersions := Seq( - "3.3.4-RC1", - "2.13.14", - "2.12.19" - ), - scalaVersion := crossScalaVersions.value.head, - coverageEnabled := false, - scalaJSLinkerConfig := { scalaJSLinkerConfig.value.withBatchMode(true).withModuleKind(ModuleKind.CommonJSModule) } - ) .enablePlugins(SitePreviewPlugin) -lazy val `distage-core-apiJVM` = `distage-core-api`.jvm - .disablePlugins(AssemblyPlugin) -lazy val `distage-core-apiJS` = `distage-core-api`.js .disablePlugins(AssemblyPlugin) lazy val `distage-core-proxy-bytebuddy` = project.in(file("distage/distage-core-proxy-bytebuddy")) .dependsOn( - `distage-core-apiJVM` % "test->compile;compile->compile" + `distage-core-api` % "test->compile;compile->compile" ) .settings( libraryDependencies ++= Seq( @@ -2504,6 +2415,14 @@ lazy val `distage-core-proxy-bytebuddy` = project.in(file("distage/distage-core- ), scalaVersion := crossScalaVersions.value.head, organization := "io.7mind.izumi", + Compile / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/main/scala" , + Compile / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/main/scala-$v").distinct, + Compile / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/main/resources" , + Test / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/test/scala" , + Test / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/test/scala-$v").distinct, + Test / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/test/resources" , scalacOptions ++= Seq( s"-Xmacro-settings:product-name=${name.value}", s"-Xmacro-settings:product-version=${version.value}", @@ -2685,14 +2604,14 @@ lazy val `distage-core-proxy-bytebuddy` = project.in(file("distage/distage-core- .enablePlugins(SitePreviewPlugin) .disablePlugins(AssemblyPlugin) -lazy val `distage-framework-api` = crossProject(JVMPlatform, JSPlatform).crossType(CrossType.Pure).in(file("distage/distage-framework-api")) +lazy val `distage-framework-api` = project.in(file("distage/distage-framework-api")) .dependsOn( `distage-core-api` % "test->compile;compile->compile" ) .settings( libraryDependencies ++= Seq( - "org.scala-lang.modules" %%% "scala-collection-compat" % V.collection_compat, - "org.scalatest" %%% "scalatest" % V.scalatest % Test + "org.scala-lang.modules" %% "scala-collection-compat" % V.collection_compat, + "org.scalatest" %% "scalatest" % V.scalatest % Test ), libraryDependencies ++= { if (scalaVersion.value.startsWith("2.")) Seq( compilerPlugin("org.typelevel" % "kind-projector" % V.kind_projector cross CrossVersion.full), @@ -2700,7 +2619,21 @@ lazy val `distage-framework-api` = crossProject(JVMPlatform, JSPlatform).crossTy ) else Seq.empty } ) .settings( + crossScalaVersions := Seq( + "3.3.4-RC1", + "2.13.14", + "2.12.19" + ), + scalaVersion := crossScalaVersions.value.head, organization := "io.7mind.izumi", + Compile / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/main/scala" , + Compile / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/main/scala-$v").distinct, + Compile / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/main/resources" , + Test / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/test/scala" , + Test / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/test/scala-$v").distinct, + Test / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/test/resources" , scalacOptions ++= Seq( s"-Xmacro-settings:product-name=${name.value}", s"-Xmacro-settings:product-version=${version.value}", @@ -2879,44 +2812,24 @@ lazy val `distage-framework-api` = crossProject(JVMPlatform, JSPlatform).crossTy } }, Test / packageDoc / publishArtifact := false ) - .jvmSettings( - crossScalaVersions := Seq( - "3.3.4-RC1", - "2.13.14", - "2.12.19" - ), - scalaVersion := crossScalaVersions.value.head - ) - .jsSettings( - crossScalaVersions := Seq( - "3.3.4-RC1", - "2.13.14", - "2.12.19" - ), - scalaVersion := crossScalaVersions.value.head, - coverageEnabled := false, - scalaJSLinkerConfig := { scalaJSLinkerConfig.value.withBatchMode(true).withModuleKind(ModuleKind.CommonJSModule) } - ) .enablePlugins(SitePreviewPlugin) -lazy val `distage-framework-apiJVM` = `distage-framework-api`.jvm - .disablePlugins(AssemblyPlugin) -lazy val `distage-framework-apiJS` = `distage-framework-api`.js .disablePlugins(AssemblyPlugin) -lazy val `distage-core` = crossProject(JVMPlatform, JSPlatform).crossType(CrossType.Pure).in(file("distage/distage-core")) +lazy val `distage-core` = project.in(file("distage/distage-core")) .dependsOn( `distage-core-api` % "test->compile;compile->compile", + `distage-core-proxy-bytebuddy` % "test->compile;compile->compile", `fundamentals-platform` % "test->test;compile->compile" ) .settings( libraryDependencies ++= Seq( - "org.scala-lang.modules" %%% "scala-collection-compat" % V.collection_compat, - "org.scalatest" %%% "scalatest" % V.scalatest % Test, - "org.typelevel" %%% "cats-core" % V.cats % Optional, - "org.typelevel" %%% "cats-effect" % V.cats_effect % Optional, - "dev.zio" %%% "zio" % V.zio % Optional excludeAll("dev.zio" %% "izumi-reflect"), - "dev.zio" %%% "izumi-reflect" % V.izumi_reflect % Optional, - "dev.zio" %%% "zio-interop-cats" % V.zio_interop_cats % Optional excludeAll("dev.zio" %% "izumi-reflect"), + "org.scala-lang.modules" %% "scala-collection-compat" % V.collection_compat, + "org.scalatest" %% "scalatest" % V.scalatest % Test, + "org.typelevel" %% "cats-core" % V.cats % Optional, + "org.typelevel" %% "cats-effect" % V.cats_effect % Optional, + "dev.zio" %% "zio" % V.zio % Optional excludeAll("dev.zio" %% "izumi-reflect"), + "dev.zio" %% "izumi-reflect" % V.izumi_reflect % Optional, + "dev.zio" %% "zio-interop-cats" % V.zio_interop_cats % Optional excludeAll("dev.zio" %% "izumi-reflect"), "javax.inject" % "javax.inject" % "1" % Test ), libraryDependencies ++= { if (scalaVersion.value.startsWith("2.")) Seq( @@ -2924,7 +2837,21 @@ lazy val `distage-core` = crossProject(JVMPlatform, JSPlatform).crossType(CrossT ) else Seq.empty } ) .settings( + crossScalaVersions := Seq( + "3.3.4-RC1", + "2.13.14", + "2.12.19" + ), + scalaVersion := crossScalaVersions.value.head, organization := "io.7mind.izumi", + Compile / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/main/scala" , + Compile / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/main/scala-$v").distinct, + Compile / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/main/resources" , + Test / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/test/scala" , + Test / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/test/scala-$v").distinct, + Test / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/test/resources" , scalacOptions ++= Seq( s"-Xmacro-settings:product-name=${name.value}", s"-Xmacro-settings:product-version=${version.value}", @@ -3103,60 +3030,43 @@ lazy val `distage-core` = crossProject(JVMPlatform, JSPlatform).crossType(CrossT } }, Test / packageDoc / publishArtifact := false ) - .jvmSettings( - crossScalaVersions := Seq( - "3.3.4-RC1", - "2.13.14", - "2.12.19" - ), - scalaVersion := crossScalaVersions.value.head - ) - .jsSettings( - crossScalaVersions := Seq( - "3.3.4-RC1", - "2.13.14", - "2.12.19" - ), - scalaVersion := crossScalaVersions.value.head, - coverageEnabled := false, - scalaJSLinkerConfig := { scalaJSLinkerConfig.value.withBatchMode(true).withModuleKind(ModuleKind.CommonJSModule) }, - Test / npmDependencies ++= Seq( - ( "hash.js", "1.1.7") - ) - ) .enablePlugins(SitePreviewPlugin) -lazy val `distage-coreJVM` = `distage-core`.jvm - .dependsOn( - `distage-core-proxy-bytebuddy` % "test->compile;compile->compile" - ) - .disablePlugins(AssemblyPlugin) -lazy val `distage-coreJS` = `distage-core`.js - .settings( - libraryDependencies ++= Seq( - "io.github.cquiroz" %%% "scala-java-time" % V.scala_java_time % Test - ) - ) - .enablePlugins(ScalaJSBundlerPlugin) .disablePlugins(AssemblyPlugin) -lazy val `distage-extension-config` = crossProject(JVMPlatform, JSPlatform).crossType(CrossType.Pure).in(file("distage/distage-extension-config")) +lazy val `distage-extension-config` = project.in(file("distage/distage-extension-config")) .dependsOn( `distage-core-api` % "test->compile;compile->compile", `distage-core` % "test->compile" ) .settings( libraryDependencies ++= Seq( - "org.scala-lang.modules" %%% "scala-collection-compat" % V.collection_compat, - "org.scalatest" %%% "scalatest" % V.scalatest % Test + "org.scala-lang.modules" %% "scala-collection-compat" % V.collection_compat, + "org.scalatest" %% "scalatest" % V.scalatest % Test, + "com.github.pureconfig" %% "pureconfig-core" % V.pureconfig ), libraryDependencies ++= { if (scalaVersion.value.startsWith("2.")) Seq( compilerPlugin("org.typelevel" % "kind-projector" % V.kind_projector cross CrossVersion.full), - "com.softwaremill.magnolia1_2" %%% "magnolia" % V.magnolia, + "com.github.pureconfig" %% "pureconfig-magnolia" % V.pureconfig, + "com.softwaremill.magnolia1_2" %% "magnolia" % V.magnolia, "org.scala-lang" % "scala-reflect" % scalaVersion.value % Provided ) else Seq.empty } ) .settings( + crossScalaVersions := Seq( + "3.3.4-RC1", + "2.13.14", + "2.12.19" + ), + scalaVersion := crossScalaVersions.value.head, organization := "io.7mind.izumi", + Compile / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/main/scala" , + Compile / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/main/scala-$v").distinct, + Compile / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/main/resources" , + Test / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/test/scala" , + Test / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/test/scala-$v").distinct, + Test / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/test/resources" , scalacOptions ++= Seq( s"-Xmacro-settings:product-name=${name.value}", s"-Xmacro-settings:product-version=${version.value}", @@ -3335,39 +3245,10 @@ lazy val `distage-extension-config` = crossProject(JVMPlatform, JSPlatform).cros } }, Test / packageDoc / publishArtifact := false ) - .jvmSettings( - crossScalaVersions := Seq( - "3.3.4-RC1", - "2.13.14", - "2.12.19" - ), - scalaVersion := crossScalaVersions.value.head - ) - .jsSettings( - crossScalaVersions := Seq( - "3.3.4-RC1", - "2.13.14", - "2.12.19" - ), - scalaVersion := crossScalaVersions.value.head, - coverageEnabled := false, - scalaJSLinkerConfig := { scalaJSLinkerConfig.value.withBatchMode(true).withModuleKind(ModuleKind.CommonJSModule) } - ) .enablePlugins(SitePreviewPlugin) -lazy val `distage-extension-configJVM` = `distage-extension-config`.jvm - .settings( - libraryDependencies ++= Seq( - "com.github.pureconfig" %% "pureconfig-core" % V.pureconfig - ), - libraryDependencies ++= { if (scalaVersion.value.startsWith("2.")) Seq( - "com.github.pureconfig" %% "pureconfig-magnolia" % V.pureconfig - ) else Seq.empty } - ) - .disablePlugins(AssemblyPlugin) -lazy val `distage-extension-configJS` = `distage-extension-config`.js .disablePlugins(AssemblyPlugin) -lazy val `distage-extension-logstage` = crossProject(JVMPlatform, JSPlatform).crossType(CrossType.Pure).in(file("distage/distage-extension-logstage")) +lazy val `distage-extension-logstage` = project.in(file("distage/distage-extension-logstage")) .dependsOn( `distage-extension-config` % "test->compile;compile->compile", `distage-core-api` % "test->compile;compile->compile", @@ -3376,16 +3257,30 @@ lazy val `distage-extension-logstage` = crossProject(JVMPlatform, JSPlatform).cr ) .settings( libraryDependencies ++= Seq( - "org.scala-lang.modules" %%% "scala-collection-compat" % V.collection_compat, - "org.scalatest" %%% "scalatest" % V.scalatest % Test, - "dev.zio" %%% "zio" % V.zio % Test excludeAll("dev.zio" %% "izumi-reflect") + "org.scala-lang.modules" %% "scala-collection-compat" % V.collection_compat, + "org.scalatest" %% "scalatest" % V.scalatest % Test, + "dev.zio" %% "zio" % V.zio % Test excludeAll("dev.zio" %% "izumi-reflect") ), libraryDependencies ++= { if (scalaVersion.value.startsWith("2.")) Seq( compilerPlugin("org.typelevel" % "kind-projector" % V.kind_projector cross CrossVersion.full) ) else Seq.empty } ) .settings( + crossScalaVersions := Seq( + "3.3.4-RC1", + "2.13.14", + "2.12.19" + ), + scalaVersion := crossScalaVersions.value.head, organization := "io.7mind.izumi", + Compile / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/main/scala" , + Compile / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/main/scala-$v").distinct, + Compile / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/main/resources" , + Test / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/test/scala" , + Test / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/test/scala-$v").distinct, + Test / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/test/resources" , scalacOptions ++= Seq( s"-Xmacro-settings:product-name=${name.value}", s"-Xmacro-settings:product-version=${version.value}", @@ -3564,41 +3459,25 @@ lazy val `distage-extension-logstage` = crossProject(JVMPlatform, JSPlatform).cr } }, Test / packageDoc / publishArtifact := false ) - .jvmSettings( - crossScalaVersions := Seq( - "3.3.4-RC1", - "2.13.14", - "2.12.19" - ), - scalaVersion := crossScalaVersions.value.head - ) - .jsSettings( - crossScalaVersions := Seq( - "3.3.4-RC1", - "2.13.14", - "2.12.19" - ), - scalaVersion := crossScalaVersions.value.head, - coverageEnabled := false, - scalaJSLinkerConfig := { scalaJSLinkerConfig.value.withBatchMode(true).withModuleKind(ModuleKind.CommonJSModule) } - ) .enablePlugins(SitePreviewPlugin) -lazy val `distage-extension-logstageJVM` = `distage-extension-logstage`.jvm - .disablePlugins(AssemblyPlugin) -lazy val `distage-extension-logstageJS` = `distage-extension-logstage`.js .disablePlugins(AssemblyPlugin) -lazy val `distage-extension-plugins` = crossProject(JVMPlatform, JSPlatform).crossType(CrossType.Pure).in(file("distage/distage-extension-plugins")) +lazy val `distage-extension-plugins` = project.in(file("distage/distage-extension-plugins")) .dependsOn( `distage-core-api` % "test->compile;compile->compile", `distage-core` % "test->compile", `distage-extension-config` % "test->compile", - `logstage-core` % "test->compile" + `logstage-core` % "test->compile", + `fundamentals-platform` % "test->compile,test" ) .settings( libraryDependencies ++= Seq( - "org.scala-lang.modules" %%% "scala-collection-compat" % V.collection_compat, - "org.scalatest" %%% "scalatest" % V.scalatest % Test + "org.scala-lang.modules" %% "scala-collection-compat" % V.collection_compat, + "org.scalatest" %% "scalatest" % V.scalatest % Test, + "io.github.classgraph" % "classgraph" % V.classgraph, + "dev.zio" %% "zio-managed" % V.zio % Test excludeAll("dev.zio" %% "izumi-reflect"), + "dev.zio" %% "zio-interop-cats" % V.zio_interop_cats % Test excludeAll("dev.zio" %% "izumi-reflect"), + "org.typelevel" %% "cats-effect" % V.cats_effect % Test ), libraryDependencies ++= { if (scalaVersion.value.startsWith("2.")) Seq( compilerPlugin("org.typelevel" % "kind-projector" % V.kind_projector cross CrossVersion.full), @@ -3606,7 +3485,21 @@ lazy val `distage-extension-plugins` = crossProject(JVMPlatform, JSPlatform).cro ) else Seq.empty } ) .settings( + crossScalaVersions := Seq( + "3.3.4-RC1", + "2.13.14", + "2.12.19" + ), + scalaVersion := crossScalaVersions.value.head, organization := "io.7mind.izumi", + Compile / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/main/scala" , + Compile / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/main/scala-$v").distinct, + Compile / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/main/resources" , + Test / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/test/scala" , + Test / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/test/scala-$v").distinct, + Test / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/test/resources" , scalacOptions ++= Seq( s"-Xmacro-settings:product-name=${name.value}", s"-Xmacro-settings:product-version=${version.value}", @@ -3785,42 +3678,10 @@ lazy val `distage-extension-plugins` = crossProject(JVMPlatform, JSPlatform).cro } }, Test / packageDoc / publishArtifact := false ) - .jvmSettings( - crossScalaVersions := Seq( - "3.3.4-RC1", - "2.13.14", - "2.12.19" - ), - scalaVersion := crossScalaVersions.value.head - ) - .jsSettings( - crossScalaVersions := Seq( - "3.3.4-RC1", - "2.13.14", - "2.12.19" - ), - scalaVersion := crossScalaVersions.value.head, - coverageEnabled := false, - scalaJSLinkerConfig := { scalaJSLinkerConfig.value.withBatchMode(true).withModuleKind(ModuleKind.CommonJSModule) } - ) .enablePlugins(SitePreviewPlugin) -lazy val `distage-extension-pluginsJVM` = `distage-extension-plugins`.jvm - .dependsOn( - `fundamentals-platformJVM` % "test->compile,test" - ) - .settings( - libraryDependencies ++= Seq( - "io.github.classgraph" % "classgraph" % V.classgraph, - "dev.zio" %% "zio-managed" % V.zio % Test excludeAll("dev.zio" %% "izumi-reflect"), - "dev.zio" %% "zio-interop-cats" % V.zio_interop_cats % Test excludeAll("dev.zio" %% "izumi-reflect"), - "org.typelevel" %% "cats-effect" % V.cats_effect % Test - ) - ) - .disablePlugins(AssemblyPlugin) -lazy val `distage-extension-pluginsJS` = `distage-extension-plugins`.js .disablePlugins(AssemblyPlugin) -lazy val `distage-framework` = crossProject(JVMPlatform, JSPlatform).crossType(CrossType.Pure).in(file("distage/distage-framework")) +lazy val `distage-framework` = project.in(file("distage/distage-framework")) .dependsOn( `distage-extension-logstage` % "test->compile;compile->compile", `logstage-rendering-circe` % "test->compile;compile->compile", @@ -3832,14 +3693,14 @@ lazy val `distage-framework` = crossProject(JVMPlatform, JSPlatform).crossType(C ) .settings( libraryDependencies ++= Seq( - "org.scala-lang.modules" %%% "scala-collection-compat" % V.collection_compat, - "org.scalatest" %%% "scalatest" % V.scalatest % Test, - "org.typelevel" %%% "cats-core" % V.cats % Optional, - "org.typelevel" %%% "cats-effect" % V.cats_effect % Optional, - "org.typelevel" %%% "cats-core" % V.cats % Test, - "org.typelevel" %%% "cats-effect" % V.cats_effect % Test, - "dev.zio" %%% "zio" % V.zio % Test excludeAll("dev.zio" %% "izumi-reflect"), - "dev.zio" %%% "izumi-reflect" % V.izumi_reflect % Test + "org.scala-lang.modules" %% "scala-collection-compat" % V.collection_compat, + "org.scalatest" %% "scalatest" % V.scalatest % Test, + "org.typelevel" %% "cats-core" % V.cats % Optional, + "org.typelevel" %% "cats-effect" % V.cats_effect % Optional, + "org.typelevel" %% "cats-core" % V.cats % Test, + "org.typelevel" %% "cats-effect" % V.cats_effect % Test, + "dev.zio" %% "zio" % V.zio % Test excludeAll("dev.zio" %% "izumi-reflect"), + "dev.zio" %% "izumi-reflect" % V.izumi_reflect % Test ), libraryDependencies ++= { if (scalaVersion.value.startsWith("2.")) Seq( compilerPlugin("org.typelevel" % "kind-projector" % V.kind_projector cross CrossVersion.full), @@ -3855,7 +3716,21 @@ lazy val `distage-framework` = crossProject(JVMPlatform, JSPlatform).crossType(C } ) .settings( + crossScalaVersions := Seq( + "3.3.4-RC1", + "2.13.14", + "2.12.19" + ), + scalaVersion := crossScalaVersions.value.head, organization := "io.7mind.izumi", + Compile / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/main/scala" , + Compile / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/main/scala-$v").distinct, + Compile / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/main/resources" , + Test / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/test/scala" , + Test / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/test/scala-$v").distinct, + Test / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/test/resources" , scalacOptions ++= Seq( s"-Xmacro-settings:product-name=${name.value}", s"-Xmacro-settings:product-version=${version.value}", @@ -4034,36 +3909,15 @@ lazy val `distage-framework` = crossProject(JVMPlatform, JSPlatform).crossType(C } }, Test / packageDoc / publishArtifact := false ) - .jvmSettings( - crossScalaVersions := Seq( - "3.3.4-RC1", - "2.13.14", - "2.12.19" - ), - scalaVersion := crossScalaVersions.value.head - ) - .jsSettings( - crossScalaVersions := Seq( - "3.3.4-RC1", - "2.13.14", - "2.12.19" - ), - scalaVersion := crossScalaVersions.value.head, - coverageEnabled := false, - scalaJSLinkerConfig := { scalaJSLinkerConfig.value.withBatchMode(true).withModuleKind(ModuleKind.CommonJSModule) } - ) .enablePlugins(SitePreviewPlugin) -lazy val `distage-frameworkJVM` = `distage-framework`.jvm - .disablePlugins(AssemblyPlugin) -lazy val `distage-frameworkJS` = `distage-framework`.js .disablePlugins(AssemblyPlugin) lazy val `distage-framework-docker` = project.in(file("distage/distage-framework-docker")) .dependsOn( - `distage-coreJVM` % "test->compile;compile->compile", - `distage-extension-configJVM` % "test->compile;compile->compile", - `distage-framework-apiJVM` % "test->compile;compile->compile", - `distage-extension-logstageJVM` % "test->compile;compile->compile", + `distage-core` % "test->compile;compile->compile", + `distage-extension-config` % "test->compile;compile->compile", + `distage-framework-api` % "test->compile;compile->compile", + `distage-extension-logstage` % "test->compile;compile->compile", `distage-testkit-scalatest` % "test->compile" ) .settings( @@ -4089,6 +3943,14 @@ lazy val `distage-framework-docker` = project.in(file("distage/distage-framework ), scalaVersion := crossScalaVersions.value.head, organization := "io.7mind.izumi", + Compile / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/main/scala" , + Compile / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/main/scala-$v").distinct, + Compile / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/main/resources" , + Test / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/test/scala" , + Test / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/test/scala-$v").distinct, + Test / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/test/resources" , scalacOptions ++= Seq( s"-Xmacro-settings:product-name=${name.value}", s"-Xmacro-settings:product-version=${version.value}", @@ -4272,7 +4134,7 @@ lazy val `distage-framework-docker` = project.in(file("distage/distage-framework lazy val `distage-testkit-core` = project.in(file("distage/distage-testkit-core")) .dependsOn( - `distage-frameworkJVM` % "test->compile;compile->compile" + `distage-framework` % "test->compile;compile->compile" ) .settings( libraryDependencies ++= Seq( @@ -4291,6 +4153,14 @@ lazy val `distage-testkit-core` = project.in(file("distage/distage-testkit-core" ), scalaVersion := crossScalaVersions.value.head, organization := "io.7mind.izumi", + Compile / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/main/scala" , + Compile / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/main/scala-$v").distinct, + Compile / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/main/resources" , + Test / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/test/scala" , + Test / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/test/scala-$v").distinct, + Test / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/test/resources" , scalacOptions ++= Seq( s"-Xmacro-settings:product-name=${name.value}", s"-Xmacro-settings:product-version=${version.value}", @@ -4475,9 +4345,9 @@ lazy val `distage-testkit-core` = project.in(file("distage/distage-testkit-core" lazy val `distage-testkit-scalatest` = project.in(file("distage/distage-testkit-scalatest")) .dependsOn( `distage-testkit-core` % "test->compile;compile->compile", - `distage-coreJVM` % "test->compile;compile->compile", - `distage-extension-pluginsJVM` % "test->compile;compile->compile", - `distage-frameworkJVM` % "test->test;compile->compile" + `distage-core` % "test->compile;compile->compile", + `distage-extension-plugins` % "test->compile;compile->compile", + `distage-framework` % "test->test;compile->compile" ) .settings( libraryDependencies ++= Seq( @@ -4502,6 +4372,14 @@ lazy val `distage-testkit-scalatest` = project.in(file("distage/distage-testkit- ), scalaVersion := crossScalaVersions.value.head, organization := "io.7mind.izumi", + Compile / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/main/scala" , + Compile / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/main/scala-$v").distinct, + Compile / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/main/resources" , + Test / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/test/scala" , + Test / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/test/scala-$v").distinct, + Test / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/test/resources" , scalacOptions ++= Seq( s"-Xmacro-settings:product-name=${name.value}", s"-Xmacro-settings:product-version=${version.value}", @@ -4705,6 +4583,14 @@ lazy val `distage-testkit-scalatest-sbt-module-filtering-test` = project.in(file ), scalaVersion := crossScalaVersions.value.head, organization := "io.7mind.izumi", + Compile / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/main/scala" , + Compile / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/main/scala-$v").distinct, + Compile / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/main/resources" , + Test / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/test/scala" , + Test / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/test/scala-$v").distinct, + Test / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/test/resources" , scalacOptions ++= Seq( s"-Xmacro-settings:product-name=${name.value}", s"-Xmacro-settings:product-version=${version.value}", @@ -4887,19 +4773,19 @@ lazy val `distage-testkit-scalatest-sbt-module-filtering-test` = project.in(file .enablePlugins(SitePreviewPlugin) .disablePlugins(AssemblyPlugin) -lazy val `logstage-core` = crossProject(JVMPlatform, JSPlatform).crossType(CrossType.Pure).in(file("logstage/logstage-core")) +lazy val `logstage-core` = project.in(file("logstage/logstage-core")) .dependsOn( `fundamentals-bio` % "test->compile;compile->compile", `fundamentals-platform` % "test->compile;compile->compile" ) .settings( libraryDependencies ++= Seq( - "org.scala-lang.modules" %%% "scala-collection-compat" % V.collection_compat, - "org.scalatest" %%% "scalatest" % V.scalatest % Test, - "org.typelevel" %%% "cats-core" % V.cats % Optional, - "org.typelevel" %%% "cats-effect" % V.cats_effect % Optional, - "dev.zio" %%% "zio" % V.zio % Optional excludeAll("dev.zio" %% "izumi-reflect"), - "dev.zio" %%% "izumi-reflect" % V.izumi_reflect % Optional + "org.scala-lang.modules" %% "scala-collection-compat" % V.collection_compat, + "org.scalatest" %% "scalatest" % V.scalatest % Test, + "org.typelevel" %% "cats-core" % V.cats % Optional, + "org.typelevel" %% "cats-effect" % V.cats_effect % Optional, + "dev.zio" %% "zio" % V.zio % Optional excludeAll("dev.zio" %% "izumi-reflect"), + "dev.zio" %% "izumi-reflect" % V.izumi_reflect % Optional ), libraryDependencies ++= { if (scalaVersion.value.startsWith("2.")) Seq( compilerPlugin("org.typelevel" % "kind-projector" % V.kind_projector cross CrossVersion.full), @@ -4907,7 +4793,21 @@ lazy val `logstage-core` = crossProject(JVMPlatform, JSPlatform).crossType(Cross ) else Seq.empty } ) .settings( + crossScalaVersions := Seq( + "3.3.4-RC1", + "2.13.14", + "2.12.19" + ), + scalaVersion := crossScalaVersions.value.head, organization := "io.7mind.izumi", + Compile / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/main/scala" , + Compile / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/main/scala-$v").distinct, + Compile / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/main/resources" , + Test / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/test/scala" , + Test / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/test/scala-$v").distinct, + Test / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/test/resources" , scalacOptions ++= Seq( s"-Xmacro-settings:product-name=${name.value}", s"-Xmacro-settings:product-version=${version.value}", @@ -5086,56 +4986,44 @@ lazy val `logstage-core` = crossProject(JVMPlatform, JSPlatform).crossType(Cross } }, Test / packageDoc / publishArtifact := false ) - .jvmSettings( - crossScalaVersions := Seq( - "3.3.4-RC1", - "2.13.14", - "2.12.19" - ), - scalaVersion := crossScalaVersions.value.head - ) - .jsSettings( - crossScalaVersions := Seq( - "3.3.4-RC1", - "2.13.14", - "2.12.19" - ), - scalaVersion := crossScalaVersions.value.head, - coverageEnabled := false, - scalaJSLinkerConfig := { scalaJSLinkerConfig.value.withBatchMode(true).withModuleKind(ModuleKind.CommonJSModule) } - ) .enablePlugins(SitePreviewPlugin) -lazy val `logstage-coreJVM` = `logstage-core`.jvm - .disablePlugins(AssemblyPlugin) -lazy val `logstage-coreJS` = `logstage-core`.js - .settings( - libraryDependencies ++= Seq( - "io.github.cquiroz" %%% "scala-java-time" % V.scala_java_time - ) - ) .disablePlugins(AssemblyPlugin) -lazy val `logstage-rendering-circe` = crossProject(JVMPlatform, JSPlatform).crossType(CrossType.Pure).in(file("logstage/logstage-rendering-circe")) +lazy val `logstage-rendering-circe` = project.in(file("logstage/logstage-rendering-circe")) .dependsOn( `logstage-core` % "test->test;compile->compile" ) .settings( libraryDependencies ++= Seq( - "org.scala-lang.modules" %%% "scala-collection-compat" % V.collection_compat, - "org.scalatest" %%% "scalatest" % V.scalatest % Test, - "io.circe" %%% "circe-core" % V.circe, + "org.scala-lang.modules" %% "scala-collection-compat" % V.collection_compat, + "org.scalatest" %% "scalatest" % V.scalatest % Test, + "io.circe" %% "circe-core" % V.circe, "org.typelevel" %% "jawn-parser" % V.jawn % Test, - "io.circe" %%% "circe-parser" % V.circe % Test, - "io.circe" %%% "circe-literal" % V.circe % Test, - "io.circe" %%% "circe-generic" % V.circe % Test, - "dev.zio" %%% "zio" % V.zio % Test excludeAll("dev.zio" %% "izumi-reflect") + "io.circe" %% "circe-parser" % V.circe % Test, + "io.circe" %% "circe-literal" % V.circe % Test, + "io.circe" %% "circe-generic" % V.circe % Test, + "dev.zio" %% "zio" % V.zio % Test excludeAll("dev.zio" %% "izumi-reflect") ), libraryDependencies ++= { if (scalaVersion.value.startsWith("2.")) Seq( compilerPlugin("org.typelevel" % "kind-projector" % V.kind_projector cross CrossVersion.full) ) else Seq.empty } ) .settings( + crossScalaVersions := Seq( + "3.3.4-RC1", + "2.13.14", + "2.12.19" + ), + scalaVersion := crossScalaVersions.value.head, organization := "io.7mind.izumi", + Compile / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/main/scala" , + Compile / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/main/scala-$v").distinct, + Compile / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/main/resources" , + Test / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/test/scala" , + Test / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/test/scala-$v").distinct, + Test / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/test/resources" , scalacOptions ++= Seq( s"-Xmacro-settings:product-name=${name.value}", s"-Xmacro-settings:product-version=${version.value}", @@ -5314,33 +5202,12 @@ lazy val `logstage-rendering-circe` = crossProject(JVMPlatform, JSPlatform).cros } }, Test / packageDoc / publishArtifact := false ) - .jvmSettings( - crossScalaVersions := Seq( - "3.3.4-RC1", - "2.13.14", - "2.12.19" - ), - scalaVersion := crossScalaVersions.value.head - ) - .jsSettings( - crossScalaVersions := Seq( - "3.3.4-RC1", - "2.13.14", - "2.12.19" - ), - scalaVersion := crossScalaVersions.value.head, - coverageEnabled := false, - scalaJSLinkerConfig := { scalaJSLinkerConfig.value.withBatchMode(true).withModuleKind(ModuleKind.CommonJSModule) } - ) .enablePlugins(SitePreviewPlugin) -lazy val `logstage-rendering-circeJVM` = `logstage-rendering-circe`.jvm - .disablePlugins(AssemblyPlugin) -lazy val `logstage-rendering-circeJS` = `logstage-rendering-circe`.js .disablePlugins(AssemblyPlugin) lazy val `logstage-adapter-slf4j` = project.in(file("logstage/logstage-adapter-slf4j")) .dependsOn( - `logstage-coreJVM` % "test->test;compile->compile" + `logstage-core` % "test->test;compile->compile" ) .settings( libraryDependencies ++= Seq( @@ -5360,6 +5227,14 @@ lazy val `logstage-adapter-slf4j` = project.in(file("logstage/logstage-adapter-s ), scalaVersion := crossScalaVersions.value.head, organization := "io.7mind.izumi", + Compile / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/main/scala" , + Compile / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/main/scala-$v").distinct, + Compile / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/main/resources" , + Test / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/test/scala" , + Test / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/test/scala-$v").distinct, + Test / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/test/resources" , scalacOptions ++= Seq( s"-Xmacro-settings:product-name=${name.value}", s"-Xmacro-settings:product-version=${version.value}", @@ -5546,7 +5421,7 @@ lazy val `logstage-adapter-slf4j` = project.in(file("logstage/logstage-adapter-s lazy val `logstage-sink-slf4j` = project.in(file("logstage/logstage-sink-slf4j")) .dependsOn( - `logstage-coreJVM` % "test->test;compile->compile" + `logstage-core` % "test->test;compile->compile" ) .settings( libraryDependencies ++= Seq( @@ -5567,6 +5442,14 @@ lazy val `logstage-sink-slf4j` = project.in(file("logstage/logstage-sink-slf4j") ), scalaVersion := crossScalaVersions.value.head, organization := "io.7mind.izumi", + Compile / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/main/scala" , + Compile / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/main/scala-$v").distinct, + Compile / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/main/resources" , + Test / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/test/scala" , + Test / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/test/scala-$v").distinct, + Test / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/test/resources" , scalacOptions ++= Seq( s"-Xmacro-settings:product-name=${name.value}", s"-Xmacro-settings:product-version=${version.value}", @@ -5750,30 +5633,30 @@ lazy val `logstage-sink-slf4j` = project.in(file("logstage/logstage-sink-slf4j") lazy val `microsite` = project.in(file("doc/microsite")) .dependsOn( - `fundamentals-basicsJVM` % "test->compile;compile->compile", - `fundamentals-functionalJVM` % "test->compile;compile->compile", - `fundamentals-collectionsJVM` % "test->compile;compile->compile", - `fundamentals-literalsJVM` % "test->compile;compile->compile", - `fundamentals-orphansJVM` % "test->compile;compile->compile", - `fundamentals-languageJVM` % "test->compile;compile->compile", - `fundamentals-platformJVM` % "test->compile;compile->compile", - `fundamentals-functoidJVM` % "test->compile;compile->compile", - `fundamentals-json-circeJVM` % "test->compile;compile->compile", - `fundamentals-bioJVM` % "test->compile;compile->compile", - `distage-core-apiJVM` % "test->compile;compile->compile", + `fundamentals-basics` % "test->compile;compile->compile", + `fundamentals-functional` % "test->compile;compile->compile", + `fundamentals-collections` % "test->compile;compile->compile", + `fundamentals-literals` % "test->compile;compile->compile", + `fundamentals-orphans` % "test->compile;compile->compile", + `fundamentals-language` % "test->compile;compile->compile", + `fundamentals-platform` % "test->compile;compile->compile", + `fundamentals-functoid` % "test->compile;compile->compile", + `fundamentals-json-circe` % "test->compile;compile->compile", + `fundamentals-bio` % "test->compile;compile->compile", + `distage-core-api` % "test->compile;compile->compile", `distage-core-proxy-bytebuddy` % "test->compile;compile->compile", - `distage-framework-apiJVM` % "test->compile;compile->compile", - `distage-coreJVM` % "test->compile;compile->compile", - `distage-extension-configJVM` % "test->compile;compile->compile", - `distage-extension-logstageJVM` % "test->compile;compile->compile", - `distage-extension-pluginsJVM` % "test->compile;compile->compile", - `distage-frameworkJVM` % "test->compile;compile->compile", + `distage-framework-api` % "test->compile;compile->compile", + `distage-core` % "test->compile;compile->compile", + `distage-extension-config` % "test->compile;compile->compile", + `distage-extension-logstage` % "test->compile;compile->compile", + `distage-extension-plugins` % "test->compile;compile->compile", + `distage-framework` % "test->compile;compile->compile", `distage-framework-docker` % "test->compile;compile->compile", `distage-testkit-core` % "test->compile;compile->compile", `distage-testkit-scalatest` % "test->compile;compile->compile", `distage-testkit-scalatest-sbt-module-filtering-test` % "test->compile;compile->compile", - `logstage-coreJVM` % "test->compile;compile->compile", - `logstage-rendering-circeJVM` % "test->compile;compile->compile", + `logstage-core` % "test->compile;compile->compile", + `logstage-rendering-circe` % "test->compile;compile->compile", `logstage-adapter-slf4j` % "test->compile;compile->compile", `logstage-sink-slf4j` % "test->compile;compile->compile" ) @@ -5802,6 +5685,14 @@ lazy val `microsite` = project.in(file("doc/microsite")) ), scalaVersion := crossScalaVersions.value.head, organization := "io.7mind.izumi", + Compile / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/main/scala" , + Compile / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/main/scala-$v").distinct, + Compile / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/main/resources" , + Test / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/test/scala" , + Test / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/test/scala-$v").distinct, + Test / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/test/resources" , scalacOptions ++= Seq( s"-Xmacro-settings:product-name=${name.value}", s"-Xmacro-settings:product-version=${version.value}", @@ -6066,6 +5957,14 @@ lazy val `sbt-izumi-deps` = project.in(file("sbt-plugins/sbt-izumi-deps")) scalaVersion := crossScalaVersions.value.head, coverageEnabled := false, organization := "io.7mind.izumi", + Compile / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/main/scala" , + Compile / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/main/scala-$v").distinct, + Compile / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/main/resources" , + Test / unmanagedSourceDirectories += baseDirectory.value / ".jvm/src/test/scala" , + Test / unmanagedSourceDirectories ++= (scalaBinaryVersion.value :: CrossVersion.partialVersion(scalaVersion.value).toList.map(_._1)) + .map(v => baseDirectory.value / s".jvm/src/test/scala-$v").distinct, + Test / unmanagedResourceDirectories += baseDirectory.value / ".jvm/src/test/resources" , scalacOptions ++= Seq( s"-Xmacro-settings:product-name=${name.value}", s"-Xmacro-settings:product-version=${version.value}", @@ -6259,26 +6158,16 @@ lazy val `fundamentals` = (project in file(".agg/fundamentals-fundamentals")) .enablePlugins(SitePreviewPlugin) .disablePlugins(AssemblyPlugin) .aggregate( - `fundamentals-basicsJVM`, - `fundamentals-basicsJS`, - `fundamentals-functionalJVM`, - `fundamentals-functionalJS`, - `fundamentals-collectionsJVM`, - `fundamentals-collectionsJS`, - `fundamentals-literalsJVM`, - `fundamentals-literalsJS`, - `fundamentals-orphansJVM`, - `fundamentals-orphansJS`, - `fundamentals-languageJVM`, - `fundamentals-languageJS`, - `fundamentals-platformJVM`, - `fundamentals-platformJS`, - `fundamentals-functoidJVM`, - `fundamentals-functoidJS`, - `fundamentals-json-circeJVM`, - `fundamentals-json-circeJS`, - `fundamentals-bioJVM`, - `fundamentals-bioJS` + `fundamentals-basics`, + `fundamentals-functional`, + `fundamentals-collections`, + `fundamentals-literals`, + `fundamentals-orphans`, + `fundamentals-language`, + `fundamentals-platform`, + `fundamentals-functoid`, + `fundamentals-json-circe`, + `fundamentals-bio` ) lazy val `fundamentals-jvm` = (project in file(".agg/fundamentals-fundamentals-jvm")) @@ -6289,36 +6178,16 @@ lazy val `fundamentals-jvm` = (project in file(".agg/fundamentals-fundamentals-j ) .disablePlugins(AssemblyPlugin) .aggregate( - `fundamentals-basicsJVM`, - `fundamentals-functionalJVM`, - `fundamentals-collectionsJVM`, - `fundamentals-literalsJVM`, - `fundamentals-orphansJVM`, - `fundamentals-languageJVM`, - `fundamentals-platformJVM`, - `fundamentals-functoidJVM`, - `fundamentals-json-circeJVM`, - `fundamentals-bioJVM` - ) - -lazy val `fundamentals-js` = (project in file(".agg/fundamentals-fundamentals-js")) - .settings( - publish / skip := true, - SettingKey[Boolean]("ide-skip-project") := true, - crossScalaVersions := Nil - ) - .disablePlugins(AssemblyPlugin) - .aggregate( - `fundamentals-basicsJS`, - `fundamentals-functionalJS`, - `fundamentals-collectionsJS`, - `fundamentals-literalsJS`, - `fundamentals-orphansJS`, - `fundamentals-languageJS`, - `fundamentals-platformJS`, - `fundamentals-functoidJS`, - `fundamentals-json-circeJS`, - `fundamentals-bioJS` + `fundamentals-basics`, + `fundamentals-functional`, + `fundamentals-collections`, + `fundamentals-literals`, + `fundamentals-orphans`, + `fundamentals-language`, + `fundamentals-platform`, + `fundamentals-functoid`, + `fundamentals-json-circe`, + `fundamentals-bio` ) lazy val `distage` = (project in file(".agg/distage-distage")) @@ -6330,21 +6199,14 @@ lazy val `distage` = (project in file(".agg/distage-distage")) .enablePlugins(SitePreviewPlugin) .disablePlugins(AssemblyPlugin) .aggregate( - `distage-core-apiJVM`, - `distage-core-apiJS`, + `distage-core-api`, `distage-core-proxy-bytebuddy`, - `distage-framework-apiJVM`, - `distage-framework-apiJS`, - `distage-coreJVM`, - `distage-coreJS`, - `distage-extension-configJVM`, - `distage-extension-configJS`, - `distage-extension-logstageJVM`, - `distage-extension-logstageJS`, - `distage-extension-pluginsJVM`, - `distage-extension-pluginsJS`, - `distage-frameworkJVM`, - `distage-frameworkJS`, + `distage-framework-api`, + `distage-core`, + `distage-extension-config`, + `distage-extension-logstage`, + `distage-extension-plugins`, + `distage-framework`, `distage-framework-docker`, `distage-testkit-core`, `distage-testkit-scalatest`, @@ -6359,37 +6221,20 @@ lazy val `distage-jvm` = (project in file(".agg/distage-distage-jvm")) ) .disablePlugins(AssemblyPlugin) .aggregate( - `distage-core-apiJVM`, + `distage-core-api`, `distage-core-proxy-bytebuddy`, - `distage-framework-apiJVM`, - `distage-coreJVM`, - `distage-extension-configJVM`, - `distage-extension-logstageJVM`, - `distage-extension-pluginsJVM`, - `distage-frameworkJVM`, + `distage-framework-api`, + `distage-core`, + `distage-extension-config`, + `distage-extension-logstage`, + `distage-extension-plugins`, + `distage-framework`, `distage-framework-docker`, `distage-testkit-core`, `distage-testkit-scalatest`, `distage-testkit-scalatest-sbt-module-filtering-test` ) -lazy val `distage-js` = (project in file(".agg/distage-distage-js")) - .settings( - publish / skip := true, - SettingKey[Boolean]("ide-skip-project") := true, - crossScalaVersions := Nil - ) - .disablePlugins(AssemblyPlugin) - .aggregate( - `distage-core-apiJS`, - `distage-framework-apiJS`, - `distage-coreJS`, - `distage-extension-configJS`, - `distage-extension-logstageJS`, - `distage-extension-pluginsJS`, - `distage-frameworkJS` - ) - lazy val `logstage` = (project in file(".agg/logstage-logstage")) .settings( publish / skip := true, @@ -6399,10 +6244,8 @@ lazy val `logstage` = (project in file(".agg/logstage-logstage")) .enablePlugins(SitePreviewPlugin) .disablePlugins(AssemblyPlugin) .aggregate( - `logstage-coreJVM`, - `logstage-coreJS`, - `logstage-rendering-circeJVM`, - `logstage-rendering-circeJS`, + `logstage-core`, + `logstage-rendering-circe`, `logstage-adapter-slf4j`, `logstage-sink-slf4j` ) @@ -6415,24 +6258,12 @@ lazy val `logstage-jvm` = (project in file(".agg/logstage-logstage-jvm")) ) .disablePlugins(AssemblyPlugin) .aggregate( - `logstage-coreJVM`, - `logstage-rendering-circeJVM`, + `logstage-core`, + `logstage-rendering-circe`, `logstage-adapter-slf4j`, `logstage-sink-slf4j` ) -lazy val `logstage-js` = (project in file(".agg/logstage-logstage-js")) - .settings( - publish / skip := true, - SettingKey[Boolean]("ide-skip-project") := true, - crossScalaVersions := Nil - ) - .disablePlugins(AssemblyPlugin) - .aggregate( - `logstage-coreJS`, - `logstage-rendering-circeJS` - ) - lazy val `docs` = (project in file(".agg/doc-docs")) .settings( publish / skip := true, @@ -6493,19 +6324,6 @@ lazy val `izumi-jvm` = (project in file(".agg/.agg-jvm")) `sbt-plugins-jvm` ) -lazy val `izumi-js` = (project in file(".agg/.agg-js")) - .settings( - publish / skip := true, - SettingKey[Boolean]("ide-skip-project") := true, - crossScalaVersions := Nil - ) - .disablePlugins(AssemblyPlugin) - .aggregate( - `fundamentals-js`, - `distage-js`, - `logstage-js` - ) - lazy val `izumi` = (project in file(".")) .settings( publish / skip := true, diff --git a/distage/distage-core-api/src/main/scala/izumi/distage/AbstractLocator.scala b/distage/distage-core-api/src/main/scala/izumi/distage/AbstractLocator.scala index 81c4da2d43..15e55467a1 100644 --- a/distage/distage-core-api/src/main/scala/izumi/distage/AbstractLocator.scala +++ b/distage/distage-core-api/src/main/scala/izumi/distage/AbstractLocator.scala @@ -48,12 +48,17 @@ trait AbstractLocator extends Locator { } override final def lookupRef[T: Tag](key: DIKey): Option[GenericTypedRef[T]] = { - recursiveLookup(key, this) + recursiveLookup(key, this, this) } - private final def recursiveLookup[T: Tag](key: DIKey, locator: Locator): Option[GenericTypedRef[T]] = { - locator - .lookupLocal[T](key) - .orElse(locator.parent.flatMap(p => recursiveLookup[T](key, p))) + private final def recursiveLookup[T: Tag](key: DIKey, locator: Locator, origin: Locator): Option[GenericTypedRef[T]] = { + locator.lookupLocal[T](key) match { + case Some(_) if (locator ne origin) && locator.isPrivate(key) => + None + case a @ Some(_) => a + case None => + locator.parent.flatMap(p => recursiveLookup[T](key, p, origin)) + } + } } diff --git a/distage/distage-core-api/src/main/scala/izumi/distage/model/Locator.scala b/distage/distage-core-api/src/main/scala/izumi/distage/model/Locator.scala index 87aacf434e..65b48a5db1 100644 --- a/distage/distage-core-api/src/main/scala/izumi/distage/model/Locator.scala +++ b/distage/distage-core-api/src/main/scala/izumi/distage/model/Locator.scala @@ -4,11 +4,13 @@ import izumi.distage.AbstractLocator import izumi.distage.model.Locator.LocatorMeta import izumi.distage.model.definition.Identifier import izumi.distage.model.plan.Plan +import izumi.distage.model.plan.repr.LocatorFormatter import izumi.distage.model.providers.Functoid import izumi.distage.model.provisioning.OpStatus import izumi.distage.model.provisioning.PlanInterpreter.Finalizer import izumi.distage.model.references.IdentifiedRef import izumi.distage.model.reflection.{DIKey, GenericTypedRef} +import izumi.functional.Renderable import izumi.functional.lifecycle.Lifecycle import izumi.functional.quasi.QuasiPrimitives import izumi.reflect.{Tag, TagK} @@ -41,6 +43,8 @@ trait Locator { def lookupRefOrThrow[T: Tag](key: DIKey): GenericTypedRef[T] def lookupRef[T: Tag](key: DIKey): Option[GenericTypedRef[T]] + def isPrivate(key: DIKey): Boolean + /** The plan that produced this object graph */ def plan: Plan def parent: Option[Locator] @@ -106,6 +110,22 @@ trait Locator { } args.map(fn.unsafeApply(_).asInstanceOf[T]) } + + final def depth: Int = { + var d = -1 + var loc: Option[Locator] = Some(this) + while (loc.nonEmpty) { + d = d + 1 + loc = loc.get.parent + } + d + } + + def render()(implicit ev: Renderable[Locator]): String = ev.render(this) + + override def toString: String = { + this.render() + } } object Locator { @@ -114,6 +134,8 @@ object Locator { resource.use(_.run(function)) } + @inline implicit final def defaultFormatter: Renderable[Locator] = LocatorFormatter + val empty: AbstractLocator = new AbstractLocator { override protected def lookupLocalUnsafe(key: DIKey): Option[Any] = None override def instances: immutable.Seq[IdentifiedRef] = Nil @@ -121,8 +143,8 @@ object Locator { override def parent: Option[Locator] = None override def finalizers[F[_]: TagK]: Seq[Finalizer[F]] = Nil override def index: Map[DIKey, Any] = Map.empty - override def meta: LocatorMeta = LocatorMeta.empty + override def isPrivate(key: DIKey): Boolean = false } /** @param timings How long it took to instantiate each component */ diff --git a/distage/distage-core-api/src/main/scala/izumi/distage/model/Planner.scala b/distage/distage-core-api/src/main/scala/izumi/distage/model/Planner.scala index 979b5980ca..41640337ea 100644 --- a/distage/distage-core-api/src/main/scala/izumi/distage/model/Planner.scala +++ b/distage/distage-core-api/src/main/scala/izumi/distage/model/Planner.scala @@ -1,7 +1,7 @@ package izumi.distage.model import izumi.distage.model.definition.errors.DIError -import izumi.distage.model.definition.{Activation, ModuleBase} +import izumi.distage.model.definition.{Activation, LocatorPrivacy, ModuleBase} import izumi.distage.model.plan.* import izumi.fundamentals.collections.nonempty.NEList @@ -9,12 +9,13 @@ import izumi.fundamentals.collections.nonempty.NEList trait Planner { def plan(input: PlannerInput): Either[NEList[DIError], Plan] - @inline final def plan(bindings: ModuleBase, activation: Activation, roots: Roots): Either[NEList[DIError], Plan] = { - plan(PlannerInput(bindings, activation, roots)) - } - - @inline final def plan(bindings: ModuleBase, roots: Roots): Either[NEList[DIError], Plan] = { - plan(bindings, Activation.empty, roots) + @inline final def plan( + bindings: ModuleBase, + roots: Roots, + activation: Activation = Activation.empty, + locatorPrivacy: LocatorPrivacy = LocatorPrivacy.PublicByDefault, + ): Either[NEList[DIError], Plan] = { + plan(PlannerInput(bindings, roots, activation, locatorPrivacy)) } /** diff --git a/distage/distage-core-api/src/main/scala/izumi/distage/model/PlannerInput.scala b/distage/distage-core-api/src/main/scala/izumi/distage/model/PlannerInput.scala index 4b41948795..bc7fcfe2ce 100644 --- a/distage/distage-core-api/src/main/scala/izumi/distage/model/PlannerInput.scala +++ b/distage/distage-core-api/src/main/scala/izumi/distage/model/PlannerInput.scala @@ -1,6 +1,6 @@ package izumi.distage.model -import izumi.distage.model.definition.{Activation, ModuleBase} +import izumi.distage.model.definition.{Activation, LocatorPrivacy, ModuleBase} import izumi.distage.model.plan.Roots import izumi.distage.model.reflection.DIKey import izumi.fundamentals.collections.nonempty.NESet @@ -21,48 +21,64 @@ import izumi.reflect.Tag * On [[izumi.distage.model.plan.Roots.Everything]] garbage collection will not be performed – that would be equivalent to * designating _all_ DIKeys as roots. */ -final case class PlannerInput( - bindings: ModuleBase, - activation: Activation, - roots: Roots, -) +final case class PlannerInput(bindings: ModuleBase, roots: Roots, activation: Activation, locatorPrivacy: LocatorPrivacy) object PlannerInput { - /** - * Instantiate `roots` and the dependencies of `roots`, discarding bindings that are unrelated. + private val DefaultPrivacy = LocatorPrivacy.PublicByDefault + + implicit class PlannerInputSyntax(private val input: PlannerInput) extends AnyVal { + def withLocatorPrivacy(privacy: LocatorPrivacy): PlannerInput = input.copy(locatorPrivacy = privacy) + def privateByDefault: PlannerInput = withLocatorPrivacy(LocatorPrivacy.PrivateByDefault) + def publicByDefault: PlannerInput = withLocatorPrivacy(LocatorPrivacy.PublicByDefault) + + def withActivation(activation: Activation): PlannerInput = input.copy(activation = activation) + def emptyActivation: PlannerInput = withActivation(Activation.empty) + } + + def apply(bindings: ModuleBase, roots: Roots, activation: Activation = Activation.empty, locatorPrivacy: LocatorPrivacy = DefaultPrivacy): PlannerInput = + new PlannerInput(bindings, roots, activation, locatorPrivacy) + + /** Instantiate `T` and the dependencies of `T`, discarding bindings that are unrelated. * * Effectively, this selects and creates a *sub-graph* of the largest possible object graph that can be described by `bindings` */ - def apply(bindings: ModuleBase, activation: Activation, roots: NESet[? <: DIKey]): PlannerInput = PlannerInput(bindings, activation, Roots(roots)) + def target[T: Tag](bindings: ModuleBase): PlannerInput = + PlannerInput(bindings, Roots.target[T], Activation.empty, DefaultPrivacy) - /** - * Instantiate `roots` and the dependencies of `roots`, discarding bindings that are unrelated. + /** Instantiate `T @Id(name)` and the dependencies of `T @Id(name)`, discarding bindings that are unrelated. * * Effectively, this selects and creates a *sub-graph* of the largest possible object graph that can be described by `bindings` + * + * @see [[izumi.distage.model.definition.Id @Id annotation]] */ - def apply(bindings: ModuleBase, activation: Activation, roots: Set[? <: DIKey])(implicit d: DummyImplicit): PlannerInput = - PlannerInput(bindings, activation, Roots(roots)) + def target[T: Tag](name: String)(bindings: ModuleBase): PlannerInput = + PlannerInput(bindings, Roots.target[T](name), Activation.empty, DefaultPrivacy) - /** Instantiate `root`, `roots` and their dependencies, discarding bindings that are unrelated. + /** Disable all dependency pruning. Every binding in `bindings` will be instantiated, without selection of the root components. There's almost always a better way to model things though. */ + def everything(bindings: ModuleBase, activation: Activation = Activation.empty, locatorPrivacy: LocatorPrivacy = DefaultPrivacy): PlannerInput = + PlannerInput(bindings, Roots.Everything, activation, locatorPrivacy) + + /** + * Instantiate `roots` and the dependencies of `roots`, discarding bindings that are unrelated. * * Effectively, this selects and creates a *sub-graph* of the largest possible object graph that can be described by `bindings` */ - def apply(bindings: ModuleBase, activation: Activation, root: DIKey, roots: DIKey*): PlannerInput = PlannerInput(bindings, activation, Roots(root, roots*)) + def apply(bindings: ModuleBase, roots: NESet[? <: DIKey], activation: Activation): PlannerInput = + PlannerInput(bindings, Roots(roots), activation, DefaultPrivacy) - /** Instantiate `T` and the dependencies of `T`, discarding bindings that are unrelated. + /** + * Instantiate `roots` and the dependencies of `roots`, discarding bindings that are unrelated. * * Effectively, this selects and creates a *sub-graph* of the largest possible object graph that can be described by `bindings` */ - def target[T: Tag](bindings: ModuleBase, activation: Activation): PlannerInput = PlannerInput(bindings, activation, DIKey.get[T]) + def apply(bindings: ModuleBase, roots: Set[? <: DIKey], activation: Activation)(implicit d: DummyImplicit): PlannerInput = + PlannerInput(bindings, Roots(roots), activation, DefaultPrivacy) - /** Instantiate `T @Id(name)` and the dependencies of `T @Id(name)`, discarding bindings that are unrelated. + /** Instantiate `root`, `roots` and their dependencies, discarding bindings that are unrelated. * * Effectively, this selects and creates a *sub-graph* of the largest possible object graph that can be described by `bindings` - * - * @see [[izumi.distage.model.definition.Id @Id annotation]] */ - def target[T: Tag](name: String)(bindings: ModuleBase, activation: Activation): PlannerInput = PlannerInput(bindings, activation, DIKey.get[T].named(name)) + def apply(bindings: ModuleBase, activation: Activation, root: DIKey, roots: DIKey*): PlannerInput = + PlannerInput(bindings, Roots(root, roots*), activation, DefaultPrivacy) - /** Disable all dependency pruning. Every binding in `bindings` will be instantiated, without selection of the root components. There's almost always a better way to model things though. */ - def everything(bindings: ModuleBase, activation: Activation = Activation.empty): PlannerInput = PlannerInput(bindings, activation, Roots.Everything) } diff --git a/distage/distage-core-api/src/main/scala/izumi/distage/model/definition/BindingTag.scala b/distage/distage-core-api/src/main/scala/izumi/distage/model/definition/BindingTag.scala index 6500b503ed..7025976e52 100644 --- a/distage/distage-core-api/src/main/scala/izumi/distage/model/definition/BindingTag.scala +++ b/distage/distage-core-api/src/main/scala/izumi/distage/model/definition/BindingTag.scala @@ -16,4 +16,7 @@ object BindingTag { implicit def apply(tag: AxisChoice): BindingTag = AxisTag(tag) final case class AxisTag(choice: AxisChoice) extends BindingTag + + final case object Confined extends BindingTag + final case object Exposed extends BindingTag } diff --git a/distage/distage-core-api/src/main/scala/izumi/distage/model/definition/LocatorDef.scala b/distage/distage-core-api/src/main/scala/izumi/distage/model/definition/LocatorDef.scala index 878a3eae9f..6bf1011924 100644 --- a/distage/distage-core-api/src/main/scala/izumi/distage/model/definition/LocatorDef.scala +++ b/distage/distage-core-api/src/main/scala/izumi/distage/model/definition/LocatorDef.scala @@ -35,7 +35,7 @@ trait LocatorDef extends AbstractLocator with AbstractBindingDefDSL[LocatorDef.B override private[definition] final def _bindDSLAfterFrom[T](ref: SingletonRef): LocatorDef.BindDSLUnnamedAfterFrom[T] = new LocatorDef.BindDSLUnnamedAfterFrom(ref) override private[definition] final def _setDSL[T](ref: SetRef): LocatorDef.SetDSL[T] = new LocatorDef.SetDSL[T](ref) - protected def initialState: mutable.ArrayBuffer[BindingRef] = mutable.ArrayBuffer.empty + // protected def initialState: mutable.ArrayBuffer[BindingRef] = mutable.ArrayBuffer.empty override protected def lookupLocalUnsafe(key: DIKey): Option[Any] = { frozenMap.get(key) @@ -44,6 +44,8 @@ trait LocatorDef extends AbstractLocator with AbstractBindingDefDSL[LocatorDef.B override def instances: immutable.Seq[IdentifiedRef] = frozenInstances override def index: Map[DIKey, Any] = frozenMap + override def isPrivate(key: DIKey): Boolean = confined.contains(key) + /** The plan that produced this object graph */ override def plan: Plan = { val ops = frozenInstances.map { @@ -55,13 +57,17 @@ trait LocatorDef extends AbstractLocator with AbstractBindingDefDSL[LocatorDef.B val s = IncidenceMatrix(ops.map(op => (op._1.target, Set.empty[DIKey])).toMap) val nodes = ops.map(op => (op._1.target, op._1)) - Plan(DG(s, s.transposed, GraphMeta(nodes.toMap)), PlannerInput(Module.make(ops.map(_._2).toSet), Activation.empty, Roots.Everything)) + Plan( + DG(s, s.transposed, GraphMeta(nodes.toMap)), + PlannerInput(Module.make(ops.map(_._2).toSet), Roots.Everything, Activation.empty, LocatorPrivacy.PublicByDefault), + ) } override def parent: Option[Locator] = None - private final lazy val (frozenMap, frozenInstances): (Map[DIKey, Any], immutable.Seq[IdentifiedRef]) = { + private final lazy val (frozenMap, frozenInstances, confined): (Map[DIKey, Any], immutable.Seq[IdentifiedRef], Set[DIKey]) = { val map = new mutable.LinkedHashMap[DIKey, Any] + val confined = frozenState.filter(_.tags.contains(BindingTag.Confined)).map(_.key).toSet frozenState.foreach { case SingletonBinding(key, InstanceImpl(_, instance), _, _, false) => @@ -79,7 +85,7 @@ trait LocatorDef extends AbstractLocator with AbstractBindingDefDSL[LocatorDef.B ) } - map.toMap -> map.iterator.map { case (k, v) => IdentifiedRef(k, v) }.toList + (map.toMap, map.iterator.map { case (k, v) => IdentifiedRef(k, v) }.toList, confined) } } diff --git a/distage/distage-core-api/src/main/scala/izumi/distage/model/definition/LocatorPrivacy.scala b/distage/distage-core-api/src/main/scala/izumi/distage/model/definition/LocatorPrivacy.scala new file mode 100644 index 0000000000..d709b1a951 --- /dev/null +++ b/distage/distage-core-api/src/main/scala/izumi/distage/model/definition/LocatorPrivacy.scala @@ -0,0 +1,17 @@ +package izumi.distage.model.definition + +sealed trait LocatorPrivacy + +object LocatorPrivacy { + /** All the bindings are public, unless explicitly marked as "confined" + */ + case object PublicByDefault extends LocatorPrivacy + /** All the bindings are private, unless explicitly marked as "exposed" + */ + case object PrivateByDefault extends LocatorPrivacy + + /** Only planning roots are public + */ + case object PublicRoots extends LocatorPrivacy + +} diff --git a/distage/distage-core-api/src/main/scala/izumi/distage/model/definition/dsl/AbstractBindingDefDSL.scala b/distage/distage-core-api/src/main/scala/izumi/distage/model/definition/dsl/AbstractBindingDefDSL.scala index 3777056624..24968d5e06 100644 --- a/distage/distage-core-api/src/main/scala/izumi/distage/model/definition/dsl/AbstractBindingDefDSL.scala +++ b/distage/distage-core-api/src/main/scala/izumi/distage/model/definition/dsl/AbstractBindingDefDSL.scala @@ -5,12 +5,11 @@ import izumi.distage.model.definition.* import izumi.distage.model.definition.Binding.{EmptySetBinding, ImplBinding, SetElementBinding, SingletonBinding} import izumi.distage.model.definition.dsl.AbstractBindingDefDSL.* import izumi.distage.model.definition.dsl.AbstractBindingDefDSL.SetElementInstruction.ElementAddTags -import izumi.distage.model.definition.dsl.AbstractBindingDefDSL.SetInstruction.{AddTagsAll, SetIdAll} +import izumi.distage.model.definition.dsl.AbstractBindingDefDSL.SetInstruction.{AddTagOntoSet, SetIdAll} import izumi.distage.model.definition.dsl.AbstractBindingDefDSL.SingletonInstruction.* import izumi.distage.model.exceptions.dsl.InvalidFunctoidModifier import izumi.distage.model.providers.Functoid -import izumi.distage.model.reflection.{DIKey, MultiSetImplId} -import izumi.distage.model.reflection.SetKeyMeta +import izumi.distage.model.reflection.{DIKey, MultiSetImplId, SetKeyMeta} import izumi.fundamentals.platform.language.{CodePositionMaterializer, SourceFilePosition} import izumi.reflect.Tag @@ -18,6 +17,7 @@ import scala.collection.mutable trait AbstractBindingDefDSL[BindDSL[_], BindDSLAfterFrom[_], SetDSL[_]] extends AbstractBindingDefDSLMacro[BindDSL] { self => private final val mutableState: mutable.ArrayBuffer[BindingRef] = _initialState + protected def _initialState: mutable.ArrayBuffer[BindingRef] = mutable.ArrayBuffer.empty private[definition] def _bindDSL[T](ref: SingletonRef): BindDSL[T] @@ -280,7 +280,7 @@ object AbstractBindingDefDSL { } - final class ModifyTaggingDSL[T](private val mutableState: SingletonRef) extends AnyVal with AddDependencyDSL[T, ModifyTaggingDSL[T]] { + final class ModifyTaggingDSL[T](private val mutableState: SingletonRef) extends AnyVal with AddDependencyDSL[T, ModifyTaggingDSL[T]] with Tagging[ModifyTaggingDSL[T]] { def tagged(tags: BindingTag*): ModifyTaggingDSL[T] = { new ModifyTaggingDSL(mutableState.append(AddTags(tags.toSet))) @@ -339,7 +339,7 @@ object AbstractBindingDefDSL { override protected def toSame: SubcontextRef => SubcontextNamedDSL[T] = new SubcontextNamedDSL[T](_) } - sealed abstract class SubcontextDSLBase[T, Self] { + sealed abstract class SubcontextDSLBase[T, Self] extends Tagging[Self] { protected def mutableState: SubcontextRef protected def toSame: SubcontextRef => Self @@ -447,7 +447,7 @@ object AbstractBindingDefDSL { val emptySetBinding = setOps.foldLeft(initial: EmptySetBinding[DIKey.BasicKey]) { (b, instr) => instr match { - case AddTagsAll(tags) => b.addTags(tags) + case AddTagOntoSet(tags) => b.addTags(tags) case SetIdAll(id) => b.withTarget(DIKey.TypeKey(b.key.tpe).named(id)) } } @@ -563,7 +563,7 @@ object AbstractBindingDefDSL { sealed trait SetInstruction object SetInstruction { - final case class AddTagsAll(tags: Set[BindingTag]) extends SetInstruction + final case class AddTagOntoSet(tags: Set[BindingTag]) extends SetInstruction final case class SetIdAll(id: Identifier) extends SetInstruction } diff --git a/distage/distage-core-api/src/main/scala/izumi/distage/model/definition/dsl/IncludesDSL.scala b/distage/distage-core-api/src/main/scala/izumi/distage/model/definition/dsl/IncludesDSL.scala index f3d2b43173..8243fa4a94 100644 --- a/distage/distage-core-api/src/main/scala/izumi/distage/model/definition/dsl/IncludesDSL.scala +++ b/distage/distage-core-api/src/main/scala/izumi/distage/model/definition/dsl/IncludesDSL.scala @@ -42,11 +42,13 @@ object IncludesDSL { def interpret(frozenOuterTags: Set[BindingTag]): Iterator[Binding] = { def excludeTagsOnOverlap(allTags: Set[BindingTag], excludeOnOverlap: Set[BindingTag]): Set[BindingTag] = { - val overlaps = allTags.groupBy { case BindingTag.AxisTag(choice) => choice.axis; case _ => null } + val overlaps = allTags + .collect { case a: BindingTag.AxisTag => a: BindingTag } + .groupBy { case BindingTag.AxisTag(choice) => choice.axis } + val tagsToRemove = overlaps.iterator.flatMap { - case (null, _) => Nil case (_, overlappingTags) if overlappingTags.size > 1 => overlappingTags.intersect(excludeOnOverlap) - case _ => Nil + case _ => List.empty } allTags -- tagsToRemove } diff --git a/distage/distage-core-api/src/main/scala/izumi/distage/model/definition/dsl/ModuleDefDSL.scala b/distage/distage-core-api/src/main/scala/izumi/distage/model/definition/dsl/ModuleDefDSL.scala index 8b9b4564f3..ab4771db1c 100644 --- a/distage/distage-core-api/src/main/scala/izumi/distage/model/definition/dsl/ModuleDefDSL.scala +++ b/distage/distage-core-api/src/main/scala/izumi/distage/model/definition/dsl/ModuleDefDSL.scala @@ -682,6 +682,8 @@ object ModuleDefDSL { "modifyBy", "addDependency", "addDependencies", + "exposed", + "confined", ) final class MakeDSL[T]( @@ -751,7 +753,7 @@ object ModuleDefDSL { } } - sealed trait MakeDSLMutBase[T, Self <: MakeDSLMutBase[T, Self]] extends Any with AddDependencyDSL[T, Self] { + sealed trait MakeDSLMutBase[T, Self <: MakeDSLMutBase[T, Self]] extends Any with AddDependencyDSL[T, Self] with Tagging[Self] { protected def mutableState: SingletonRef protected def toSame: SingletonRef => Self @@ -785,8 +787,11 @@ object ModuleDefDSL { final class SetDSL[T]( protected val mutableState: SetRef - ) extends SetDSLMutBase[T] { - + ) extends SetDSLMutBase[T] + with Tagging[SetDSL[T]] { + def tagged(tags: BindingTag*): SetDSL[T] = { + addOp(SetInstruction.AddTagOntoSet(tags.toSet))(new SetDSL[T](_)) + } def named(name: Identifier): SetNamedDSL[T] = { addOp(SetInstruction.SetIdAll(name))(new SetNamedDSL[T](_)) } @@ -796,11 +801,17 @@ object ModuleDefDSL { final class SetNamedDSL[T]( override protected val mutableState: SetRef ) extends SetDSLMutBase[T] + with Tagging[SetNamedDSL[T]] { + def tagged(tags: BindingTag*): SetNamedDSL[T] = { + addOp(SetInstruction.AddTagOntoSet(tags.toSet))(new SetNamedDSL[T](_)) + } + } final class SetElementDSL[T]( override protected val mutableState: SetRef, mutableCursor: SetElementRef, - ) extends SetDSLMutBase[T] { + ) extends SetDSLMutBase[T] + with Tagging[SetElementDSL[T]] { def tagged(tags: BindingTag*): SetElementDSL[T] = { addOp(ElementAddTags(tags.toSet)) @@ -815,7 +826,8 @@ object ModuleDefDSL { final class MultiSetElementDSL[T]( override protected val mutableState: SetRef, mutableCursor: MultiSetElementRef, - ) extends SetDSLMutBase[T] { + ) extends SetDSLMutBase[T] + with Tagging[MultiSetElementDSL[T]] { def tagged(tags: BindingTag*): MultiSetElementDSL[T] = addOp(MultiAddTags(tags.toSet)) diff --git a/distage/distage-core-api/src/main/scala/izumi/distage/model/definition/dsl/Tagging.scala b/distage/distage-core-api/src/main/scala/izumi/distage/model/definition/dsl/Tagging.scala new file mode 100644 index 0000000000..fa9d646fbc --- /dev/null +++ b/distage/distage-core-api/src/main/scala/izumi/distage/model/definition/dsl/Tagging.scala @@ -0,0 +1,10 @@ +package izumi.distage.model.definition.dsl + +import izumi.distage.model.definition.BindingTag + +trait Tagging[Self] extends Any { + def tagged(tags: BindingTag*): Self + + def confined: Self = tagged(BindingTag.Confined) + def exposed: Self = tagged(BindingTag.Exposed) +} diff --git a/distage/distage-core-api/src/main/scala/izumi/distage/model/plan/repr/DIPlanCompactFormatter.scala b/distage/distage-core-api/src/main/scala/izumi/distage/model/plan/repr/DIPlanCompactFormatter.scala index f2be85dfd4..1863c04f31 100644 --- a/distage/distage-core-api/src/main/scala/izumi/distage/model/plan/repr/DIPlanCompactFormatter.scala +++ b/distage/distage-core-api/src/main/scala/izumi/distage/model/plan/repr/DIPlanCompactFormatter.scala @@ -5,7 +5,7 @@ import izumi.functional.Renderable object DIPlanCompactFormatter extends Renderable[Plan] { - import izumi.fundamentals.platform.strings.IzString._ + import izumi.fundamentals.platform.strings.IzString.* override def render(plan: Plan): String = { val minimizer = KeyMinimizer(plan.plan.meta.nodes.keySet, DIRendering.colorsEnabled) @@ -13,6 +13,9 @@ object DIPlanCompactFormatter extends Renderable[Plan] { val kf = KeyFormatter.minimized(minimizer) val opFormatter = OpFormatter(kf, tf, DIRendering.colorsEnabled) + plan.toposort.map(k => opFormatter.format(plan.plan.meta.nodes(k))).mkString("\n").listing() } } + + diff --git a/distage/distage-core-api/src/main/scala/izumi/distage/model/plan/repr/LocatorFormatter.scala b/distage/distage-core-api/src/main/scala/izumi/distage/model/plan/repr/LocatorFormatter.scala new file mode 100644 index 0000000000..232893493f --- /dev/null +++ b/distage/distage-core-api/src/main/scala/izumi/distage/model/plan/repr/LocatorFormatter.scala @@ -0,0 +1,25 @@ +package izumi.distage.model.plan.repr + +import izumi.distage.model.Locator +import izumi.functional.Renderable +import izumi.fundamentals.preamble.{toRichIterable, toRichString} + +object LocatorFormatter extends Renderable[Locator] { + + override def render(value: Locator): String = { + val minimizer = KeyMinimizer(value.allInstances.map(_.key).toSet, DIRendering.colorsEnabled) + val kf = KeyFormatter.minimized(minimizer) + val (priv, pub) = value.instances + .map { + i => + (i.key, s"${kf.formatKey(i.key)}") + }.partition(v => value.isPrivate(v._1)) + + Seq( + s"Locator ${value.getClass.getName}@${Integer.toHexString(value.hashCode())} with ${value.depth} parent(s)", + s"with exposed keys:${pub.map(_._2).niceList().shift(2)}".shift(2), + s"with confined keys:${priv.map(_._2).niceList().shift(2)}".shift(2), + ).mkString("\n") + + } +} diff --git a/distage/distage-core/.jvm/src/test/scala/izumi/distage/gc/GcBasicTestsJvm.scala b/distage/distage-core/.jvm/src/test/scala/izumi/distage/gc/GcBasicTestsJvm.scala index c154fa6fec..812a698b08 100644 --- a/distage/distage-core/.jvm/src/test/scala/izumi/distage/gc/GcBasicTestsJvm.scala +++ b/distage/distage-core/.jvm/src/test/scala/izumi/distage/gc/GcBasicTestsJvm.scala @@ -16,17 +16,13 @@ class GcBasicTestsJvm extends AnyWordSpec with MkGcInjector { val injector = mkInjector() val plan = injector.planUnsafe( - PlannerInput( - new ModuleDef { - make[Circular1] - make[Circular2] - make[Circular3] - make[Circular4] - make[Trash] - }, - Activation.empty, - Roots(DIKey.get[Circular2]), - ) + PlannerInput(new ModuleDef { + make[Circular1] + make[Circular2] + make[Circular3] + make[Circular4] + make[Trash] + }, Roots(DIKey.get[Circular2]), Activation.empty) ) val result = injector.produce(plan).unsafeGet() @@ -52,15 +48,11 @@ class GcBasicTestsJvm extends AnyWordSpec with MkGcInjector { val injector = mkInjector() val plan = injector.planUnsafe( - PlannerInput( - new ModuleDef { - make[MkS3Client].from[Impl] - make[S3Component] - make[App] - }, - Activation.empty, - Roots(DIKey.get[App]), - ) + PlannerInput(new ModuleDef { + make[MkS3Client].from[Impl] + make[S3Component] + make[App] + }, Roots(DIKey.get[App]), Activation.empty) ) val result = injector.produce(plan).unsafeGet() @@ -72,18 +64,14 @@ class GcBasicTestsJvm extends AnyWordSpec with MkGcInjector { val injector = mkInjector() val plan = injector.planUnsafe( - PlannerInput( - new ModuleDef { - many[IntegrationComponent].add[S3Component] - - make[MkS3Client].from[Impl] - make[S3Upload] - make[Ctx] - make[S3Component] - }, - Activation.empty, - Roots(DIKey.get[Ctx]), - ) + PlannerInput(new ModuleDef { + many[IntegrationComponent].add[S3Component] + + make[MkS3Client].from[Impl] + make[S3Upload] + make[Ctx] + make[S3Component] + }, Roots(DIKey.get[Ctx]), Activation.empty) ) val result = injector.produce(plan).unsafeGet() @@ -98,18 +86,14 @@ class GcBasicTestsJvm extends AnyWordSpec with MkGcInjector { val injector = mkInjector() val plan = injector.planUnsafe( - PlannerInput( - new ModuleDef { - make[MkS3Client] - make[S3Upload] - make[Ctx] - make[S3Component] - many[IntegrationComponent].add[S3Component] - make[Initiator] - }, - Activation.empty, - Roots(DIKey.get[Ctx], DIKey.get[Initiator]), - ) + PlannerInput(new ModuleDef { + make[MkS3Client] + make[S3Upload] + make[Ctx] + make[S3Component] + many[IntegrationComponent].add[S3Component] + make[Initiator] + }, Roots(DIKey.get[Ctx], DIKey.get[Initiator]), Activation.empty) ) val result = injector.produce(plan).unsafeGet() @@ -121,16 +105,12 @@ class GcBasicTestsJvm extends AnyWordSpec with MkGcInjector { val injector = mkInjector() val plan = injector.planUnsafe( - PlannerInput( - new ModuleDef { - make[Circular1] - make[Circular2] - make[T1].using[Circular1] - make[T2].using[Circular2] - }, - Activation.empty, - Roots(DIKey.get[Circular2]), - ) + PlannerInput(new ModuleDef { + make[Circular1] + make[Circular2] + make[T1].using[Circular1] + make[T2].using[Circular2] + }, Roots(DIKey.get[Circular2]), Activation.empty) ) val result = injector.produce(plan).unsafeGet() @@ -145,14 +125,10 @@ class GcBasicTestsJvm extends AnyWordSpec with MkGcInjector { val injector = mkInjector() val plan = injector.planUnsafe( - PlannerInput( - new ModuleDef { - make[T1].from[Circular1] - make[T2].from[Circular2] - }, - Activation.empty, - Roots(DIKey.get[T1]), - ) + PlannerInput(new ModuleDef { + make[T1].from[Circular1] + make[T2].from[Circular2] + }, Roots(DIKey.get[T1]), Activation.empty) ) val result = injector.produce(plan).unsafeGet() @@ -165,33 +141,29 @@ class GcBasicTestsJvm extends AnyWordSpec with MkGcInjector { val injector = mkInjector() val plan = injector.planUnsafe( - PlannerInput( - new ModuleDef { - make[Circular1].from { - (t1: Circular1, t2: Circular2) => - new Circular1 { - override def c1: Circular1 = t1 - - override def c2: Circular2 = t2 - - override def nothing: Int = 1 - } - } - make[Circular2].from { - (t1: Circular1, t2: Circular2) => - new Circular2 { - - override def c1: Circular1 = t1 - - override def c2: Circular2 = t2 - - override def nothing: Int = 2 - } - } - }, - Activation.empty, - Roots(DIKey.get[Circular2]), - ) + PlannerInput(new ModuleDef { + make[Circular1].from { + (t1: Circular1, t2: Circular2) => + new Circular1 { + override def c1: Circular1 = t1 + + override def c2: Circular2 = t2 + + override def nothing: Int = 1 + } + } + make[Circular2].from { + (t1: Circular1, t2: Circular2) => + new Circular2 { + + override def c1: Circular1 = t1 + + override def c2: Circular2 = t2 + + override def nothing: Int = 2 + } + } + }, Roots(DIKey.get[Circular2]), Activation.empty) ) val result = injector.produce(plan).unsafeGet() assert(result.get[Circular1].nothing == 1) @@ -205,14 +177,10 @@ class GcBasicTestsJvm extends AnyWordSpec with MkGcInjector { val injector = mkInjector() val plan = injector.planUnsafe( - PlannerInput( - new ModuleDef { - make[Circular1] - make[Circular2] - }, - Activation.empty, - Roots(DIKey.get[Circular2]), - ) + PlannerInput(new ModuleDef { + make[Circular1] + make[Circular2] + }, Roots(DIKey.get[Circular2]), Activation.empty) ) val result = injector.produce(plan).unsafeGet() @@ -227,14 +195,10 @@ class GcBasicTestsJvm extends AnyWordSpec with MkGcInjector { val injector = mkInjector() val plan = injector.planUnsafe( - PlannerInput( - new ModuleDef { - make[Circular1] - make[Circular2] - }, - Activation.empty, - Roots(DIKey.get[Circular2]), - ) + PlannerInput(new ModuleDef { + make[Circular1] + make[Circular2] + }, Roots(DIKey.get[Circular2]), Activation.empty) ) val result = injector.produce(plan).unsafeGet() @@ -248,14 +212,10 @@ class GcBasicTestsJvm extends AnyWordSpec with MkGcInjector { val injector = mkInjector() val plan = injector.planUnsafe( - PlannerInput( - new ModuleDef { - make[Circular1] - make[Circular2] - }, - Activation.empty, - Roots(DIKey.get[Circular2], DIKey.get[Set[AutoCloseable]]), - ) + PlannerInput(new ModuleDef { + make[Circular1] + make[Circular2] + }, Roots(DIKey.get[Circular2], DIKey.get[Set[AutoCloseable]]), Activation.empty) ) val result = injector.produce(plan).unsafeGet() @@ -269,19 +229,15 @@ class GcBasicTestsJvm extends AnyWordSpec with MkGcInjector { val injector = mkInjector() val plan = injector.planUnsafe( - PlannerInput( - new ModuleDef { - make[Circular1] - make[Circular2] - make[Circular3] - make[Circular4] - many[T1] - .ref[Circular1] - .ref[Circular2] - }, - Activation.empty, - Roots(DIKey.get[Circular4], DIKey.get[immutable.Set[T1]], DIKey.get[Circular3]), - ) + PlannerInput(new ModuleDef { + make[Circular1] + make[Circular2] + make[Circular3] + make[Circular4] + many[T1] + .ref[Circular1] + .ref[Circular2] + }, Roots(DIKey.get[Circular4], DIKey.get[immutable.Set[T1]], DIKey.get[Circular3]), Activation.empty) ) val result = injector.produce(plan).unsafeGet() diff --git a/distage/distage-core/.jvm/src/test/scala/izumi/distage/injector/AnimalModelTestJvm.scala b/distage/distage-core/.jvm/src/test/scala/izumi/distage/injector/AnimalModelTestJvm.scala index 1457ccd4ba..e48e1d2eb6 100644 --- a/distage/distage-core/.jvm/src/test/scala/izumi/distage/injector/AnimalModelTestJvm.scala +++ b/distage/distage-core/.jvm/src/test/scala/izumi/distage/injector/AnimalModelTestJvm.scala @@ -11,21 +11,17 @@ class AnimalModelTestJvm extends AnyWordSpec with MkInjector { "animal model" must { "produce valid plans" in { import AnimalModelTestJvm._ - val definition = PlannerInput( - new ModuleDef { - make[Cluster] - make[UserRepo].from[UserRepoImpl] - make[AccountsRepo].from[AccountsRepoImpl] - make[UsersService].from[UserServiceImpl] - make[AccountingService].from[AccountingServiceImpl] - make[UsersApiImpl] - make[AccountsApiImpl] - make[UnrequiredDep] - make[App] - }, - Activation.empty, - Roots(DIKey.get[App]), - ) + val definition = PlannerInput(new ModuleDef { + make[Cluster] + make[UserRepo].from[UserRepoImpl] + make[AccountsRepo].from[AccountsRepoImpl] + make[UsersService].from[UserServiceImpl] + make[AccountingService].from[AccountingServiceImpl] + make[UsersApiImpl] + make[AccountsApiImpl] + make[UnrequiredDep] + make[App] + }, Roots(DIKey.get[App]), Activation.empty) val debug = false diff --git a/distage/distage-core/.jvm/src/test/scala/izumi/distage/injector/CglibProxiesTestJvm.scala b/distage/distage-core/.jvm/src/test/scala/izumi/distage/injector/CglibProxiesTestJvm.scala index e30fd2d536..62b8a61a86 100644 --- a/distage/distage-core/.jvm/src/test/scala/izumi/distage/injector/CglibProxiesTestJvm.scala +++ b/distage/distage-core/.jvm/src/test/scala/izumi/distage/injector/CglibProxiesTestJvm.scala @@ -228,8 +228,8 @@ class CglibProxiesTestJvm extends AnyWordSpec with MkInjector with ScalatestGuar make[ComponentHolder] make[Root] }, - Activation.empty, Roots(DIKey.get[Root]), + Activation.empty, ) val injector = mkInjector() @@ -368,8 +368,8 @@ class CglibProxiesTestJvm extends AnyWordSpec with MkInjector with ScalatestGuar make[S3Component].fromResource(s3ComponentResource[Fn] _) make[S3Client].fromResource(s3clientResource[Fn] _) }, - Activation.empty, Roots(DIKey.get[S3Client]), + Activation.empty, ) val injector = mkInjector() diff --git a/distage/distage-core/src/main/scala/distage/Distage.scala b/distage/distage-core/src/main/scala/distage/Distage.scala index 76476991b5..5631c5c17c 100644 --- a/distage/distage-core/src/main/scala/distage/Distage.scala +++ b/distage/distage-core/src/main/scala/distage/Distage.scala @@ -14,6 +14,9 @@ trait Distage { type Activation = model.definition.Activation val Activation: model.definition.Activation.type = model.definition.Activation + type LocatorPrivacy = model.definition.LocatorPrivacy + val LocatorPrivacy: model.definition.LocatorPrivacy.type = model.definition.LocatorPrivacy + type Roots = model.plan.Roots val Roots: model.plan.Roots.type = model.plan.Roots diff --git a/distage/distage-core/src/main/scala/distage/Injector.scala b/distage/distage-core/src/main/scala/distage/Injector.scala index 9b91d218a9..fd38f0a4d8 100644 --- a/distage/distage-core/src/main/scala/distage/Injector.scala +++ b/distage/distage-core/src/main/scala/distage/Injector.scala @@ -1,6 +1,6 @@ package distage -import izumi.distage.bootstrap.{BootstrapLocator, Cycles} +import izumi.distage.bootstrap.{BootstrapLocator, BootstrapRootsMode, Cycles} import izumi.distage.model.definition import izumi.distage.model.definition.BootstrapContextModule import izumi.functional.quasi.QuasiIO @@ -21,7 +21,7 @@ object Injector extends InjectorFactory { override def apply[F[_]: QuasiIO: TagK: DefaultModule]( overrides: BootstrapModule* ): Injector[F] = { - bootstrap(this, defaultBootstrap, defaultBootstrapActivation, None, overrides) + bootstrap(this, defaultBootstrap, defaultBootstrapActivation, None, overrides, defaultBootstrapLocatorPrivacy, defaultBootstrapRootsMode) } /** @@ -48,8 +48,10 @@ object Injector extends InjectorFactory { bootstrapActivation: Activation = defaultBootstrapActivation, parent: Option[Locator] = None, overrides: Seq[BootstrapModule] = Nil, + bootstrapLocatorPrivacy: LocatorPrivacy = defaultBootstrapLocatorPrivacy, + bootstrapRootsMode: BootstrapRootsMode = defaultBootstrapRootsMode, ): Injector[F] = { - bootstrap(this, bootstrapBase, defaultBootstrapActivation ++ bootstrapActivation, parent, overrides) + bootstrap(this, bootstrapBase, defaultBootstrapActivation ++ bootstrapActivation, parent, overrides, bootstrapLocatorPrivacy, bootstrapRootsMode) } /** @@ -119,7 +121,7 @@ object Injector extends InjectorFactory { cycleChoice: Cycles.AxisChoiceDef ) extends InjectorFactory { override final def apply[F[_]: QuasiIO: TagK: DefaultModule](overrides: BootstrapModule*): Injector[F] = { - bootstrap(this, defaultBootstrap, defaultBootstrapActivation, None, overrides) + bootstrap(this, defaultBootstrap, defaultBootstrapActivation, None, overrides, defaultBootstrapLocatorPrivacy, defaultBootstrapRootsMode) } override final def apply[F[_]: QuasiIO: TagK: DefaultModule]( @@ -127,8 +129,10 @@ object Injector extends InjectorFactory { bootstrapActivation: Activation, parent: Option[Locator], overrides: Seq[BootstrapModule], + locatorPrivacy: LocatorPrivacy, + bootstrapRootsMode: BootstrapRootsMode, ): Injector[F] = { - bootstrap(this, bootstrapBase, defaultBootstrapActivation ++ bootstrapActivation, parent, overrides) + bootstrap(this, bootstrapBase, defaultBootstrapActivation ++ bootstrapActivation, parent, overrides, locatorPrivacy, bootstrapRootsMode) } override final def apply(): Injector[Identity] = apply[Identity]() @@ -151,6 +155,8 @@ object Injector extends InjectorFactory { override protected final def defaultBootstrap: BootstrapContextModule = BootstrapLocator.defaultBootstrap override protected final def defaultBootstrapActivation: Activation = definition.Activation(Cycles -> cycleChoice) + override protected def defaultBootstrapLocatorPrivacy: LocatorPrivacy = BootstrapLocator.defaultBoostrapPrivacy + @inline override protected def defaultBootstrapRootsMode: BootstrapRootsMode = BootstrapRootsMode.UseGC } private def bootstrap[F[_]: QuasiIO: TagK: DefaultModule]( @@ -159,8 +165,10 @@ object Injector extends InjectorFactory { activation: Activation, parent: Option[Locator], overrides: Seq[BootstrapModule], + locatorPrivacy: LocatorPrivacy, + bootstrapRootsMode: BootstrapRootsMode, ): Injector[F] = { - val bootstrapLocator = BootstrapLocator.bootstrap(bootstrapBase, activation, overrides, parent) + val bootstrapLocator = BootstrapLocator.bootstrap(bootstrapBase, activation, overrides, parent, locatorPrivacy, bootstrapRootsMode) inheritWithNewDefaultModuleImpl(injectorFactory, bootstrapLocator, implicitly) } @@ -175,5 +183,6 @@ object Injector extends InjectorFactory { @inline override protected def defaultBootstrap: BootstrapContextModule = BootstrapLocator.defaultBootstrap @inline override protected def defaultBootstrapActivation: Activation = BootstrapLocator.defaultBootstrapActivation - + @inline override protected def defaultBootstrapLocatorPrivacy: LocatorPrivacy = BootstrapLocator.defaultBoostrapPrivacy + @inline override protected def defaultBootstrapRootsMode: BootstrapRootsMode = BootstrapRootsMode.UseGC } diff --git a/distage/distage-core/src/main/scala/distage/package.scala b/distage/distage-core/src/main/scala/distage/package.scala index 59c609343f..da16b16135 100644 --- a/distage/distage-core/src/main/scala/distage/package.scala +++ b/distage/distage-core/src/main/scala/distage/package.scala @@ -12,6 +12,9 @@ package object distage extends Distage { override type Activation = model.definition.Activation override val Activation: model.definition.Activation.type = model.definition.Activation + override type LocatorPrivacy = model.definition.LocatorPrivacy + override val LocatorPrivacy: model.definition.LocatorPrivacy.type = model.definition.LocatorPrivacy + override type Roots = model.plan.Roots override val Roots: model.plan.Roots.type = model.plan.Roots diff --git a/distage/distage-core/src/main/scala/izumi/distage/InjectorDefaultImpl.scala b/distage/distage-core/src/main/scala/izumi/distage/InjectorDefaultImpl.scala index 2b1ed45be0..5980432f7f 100644 --- a/distage/distage-core/src/main/scala/izumi/distage/InjectorDefaultImpl.scala +++ b/distage/distage-core/src/main/scala/izumi/distage/InjectorDefaultImpl.scala @@ -57,18 +57,16 @@ final class InjectorDefaultImpl[F[_]]( private def addSelfInfo(input: PlannerInput): PlannerInput = { val selfReflectionModule = InjectorDefaultImpl.selfReflectionModule(parentFactory, bsModule, defaultModule, input.activation, input) - input.copy( - bindings = ModuleBase.make( - ModuleBase - .overrideImpl( - ModuleBase.overrideImpl( - defaultModule.iterator, - input.bindings.iterator, - ), - selfReflectionModule.iterator, - ).toSet - ) - ) + input.copy(bindings = ModuleBase.make( + ModuleBase + .overrideImpl( + ModuleBase.overrideImpl( + defaultModule.iterator, + input.bindings.iterator, + ), + selfReflectionModule.iterator, + ).toSet + )) } override def providedEnvironment: InjectorProvidedEnv = { diff --git a/distage/distage-core/src/main/scala/izumi/distage/InjectorFactory.scala b/distage/distage-core/src/main/scala/izumi/distage/InjectorFactory.scala index ac6bcb20dc..c8f9b68418 100644 --- a/distage/distage-core/src/main/scala/izumi/distage/InjectorFactory.scala +++ b/distage/distage-core/src/main/scala/izumi/distage/InjectorFactory.scala @@ -1,5 +1,7 @@ package izumi.distage +import distage.LocatorPrivacy +import izumi.distage.bootstrap.BootstrapRootsMode import izumi.distage.model.definition.{Activation, BootstrapContextModule, BootstrapModule} import izumi.functional.quasi.QuasiIO import izumi.distage.model.recursive.Bootloader @@ -41,10 +43,12 @@ trait InjectorFactory { * They can be used to customize the Injector, e.g. by adding members to [[izumi.distage.model.planning.PlanningHook]] Set. */ def apply[F[_]: QuasiIO: TagK: DefaultModule]( - bootstrapBase: BootstrapContextModule = defaultBootstrap, - bootstrapActivation: Activation = defaultBootstrapActivation, - parent: Option[Locator] = None, - overrides: Seq[BootstrapModule] = Nil, + bootstrapBase: BootstrapContextModule = defaultBootstrap, + bootstrapActivation: Activation = defaultBootstrapActivation, + parent: Option[Locator] = None, + overrides: Seq[BootstrapModule] = Nil, + locatorPrivacy: LocatorPrivacy = defaultBootstrapLocatorPrivacy, + bootstrapRootsMode: BootstrapRootsMode = defaultBootstrapRootsMode, ): Injector[F] /** @@ -93,4 +97,6 @@ trait InjectorFactory { protected def defaultBootstrap: BootstrapContextModule protected def defaultBootstrapActivation: Activation + protected def defaultBootstrapLocatorPrivacy: LocatorPrivacy + protected def defaultBootstrapRootsMode: BootstrapRootsMode } diff --git a/distage/distage-core/src/main/scala/izumi/distage/LocatorDefaultImpl.scala b/distage/distage-core/src/main/scala/izumi/distage/LocatorDefaultImpl.scala index edcb4fa11d..72ccd91250 100644 --- a/distage/distage-core/src/main/scala/izumi/distage/LocatorDefaultImpl.scala +++ b/distage/distage-core/src/main/scala/izumi/distage/LocatorDefaultImpl.scala @@ -15,6 +15,7 @@ final class LocatorDefaultImpl[F[_]]( val parent: Option[Locator], val meta: LocatorMeta, private val dependencyMap: Provision[F], + private val privateBindings: Set[DIKey], ) extends AbstractLocator { override protected def lookupLocalUnsafe(key: DIKey): Option[Any] = @@ -31,4 +32,8 @@ final class LocatorDefaultImpl[F[_]]( override def instances: immutable.Seq[IdentifiedRef] = dependencyMap.enumerate + + override def isPrivate(key: DIKey): Boolean = { + privateBindings.contains(key) + } } diff --git a/distage/distage-core/src/main/scala/izumi/distage/bootstrap/BootstrapLocator.scala b/distage/distage-core/src/main/scala/izumi/distage/bootstrap/BootstrapLocator.scala index 7f83c26f28..fc176512ee 100644 --- a/distage/distage-core/src/main/scala/izumi/distage/bootstrap/BootstrapLocator.scala +++ b/distage/distage-core/src/main/scala/izumi/distage/bootstrap/BootstrapLocator.scala @@ -19,6 +19,7 @@ import izumi.distage.planning.solver.SemigraphSolver.SemigraphSolverImpl import izumi.distage.planning.solver.{GraphQueries, PlanSolver, SemigraphSolver} import izumi.distage.provisioning.* import izumi.distage.provisioning.strategies.* +import izumi.fundamentals.collections.nonempty.NESet import izumi.fundamentals.platform.functional.Identity object BootstrapLocator { @@ -41,15 +42,35 @@ object BootstrapLocator { bootstrapActivation: Activation, overrides: Seq[BootstrapModule], parent: Option[Locator], + locatorPrivacy: LocatorPrivacy, + rootsMode: BootstrapRootsMode, ): Locator = { val bindings0 = bootstrapBase overriddenBy overrides.merge // BootstrapModule & bootstrap plugins cannot modify `Activation` after 1.0, it's solely under control of `PlannerInput` now. // Please open an issue if you need the ability to override Activation using BootstrapModule val bindings = bindings0 ++ BootstrapLocator.selfReflectionModule(bindings0, bootstrapActivation) + val bootstrapRoots = rootsMode match { + case BootstrapRootsMode.UseGC => + val primaryRoots: NESet[DIKey] = + NESet(DIKey.get[Planner], DIKey.get[PlanInterpreter], DIKey.get[BootstrapModule], DIKey.get[Activation].named("bootstrapActivation")) + // we consider all the "exposed" bindings in bootstrap modules to be bootstrap roots + val customRoots = bindings.bindings.filter(_.tags.contains(BindingTag.Exposed)).map(_.key) + Roots(primaryRoots ++ customRoots) + case BootstrapRootsMode.Everything => + Roots.Everything + case BootstrapRootsMode.UNSAFE_Custom(keys) => + Roots.Of(keys) + } + val plan = BootstrapLocator.bootstrapPlanner - .plan(bindings, bootstrapActivation, Roots.Everything).getOrThrow() + .plan( + bindings, + bootstrapRoots, + bootstrapActivation, + locatorPrivacy, + ).getOrThrow() val resource = BootstrapLocator.bootstrapProducer @@ -151,6 +172,8 @@ object BootstrapLocator { Cycles -> Cycles.Proxy ) + final val defaultBoostrapPrivacy: LocatorPrivacy = LocatorPrivacy.PublicRoots + private def selfReflectionModule(bindings0: BootstrapContextModule, bootstrapActivation: Activation): BootstrapModuleDef = { new BootstrapModuleDef { make[Activation].named("bootstrapActivation").fromValue(bootstrapActivation) diff --git a/distage/distage-core/src/main/scala/izumi/distage/bootstrap/BootstrapRootsMode.scala b/distage/distage-core/src/main/scala/izumi/distage/bootstrap/BootstrapRootsMode.scala new file mode 100644 index 0000000000..fba3b5550f --- /dev/null +++ b/distage/distage-core/src/main/scala/izumi/distage/bootstrap/BootstrapRootsMode.scala @@ -0,0 +1,15 @@ +package izumi.distage.bootstrap + +import izumi.distage.model.reflection.DIKey +import izumi.fundamentals.collections.nonempty.NESet + +sealed trait BootstrapRootsMode + +object BootstrapRootsMode { + case object UseGC extends BootstrapRootsMode + case object Everything extends BootstrapRootsMode + + /** Never use this unless you know exactly what you are doing! + */ + case class UNSAFE_Custom(keys: NESet[DIKey]) extends BootstrapRootsMode +} diff --git a/distage/distage-core/src/main/scala/izumi/distage/model/Injector.scala b/distage/distage-core/src/main/scala/izumi/distage/model/Injector.scala index 2216690496..76713efaae 100644 --- a/distage/distage-core/src/main/scala/izumi/distage/model/Injector.scala +++ b/distage/distage-core/src/main/scala/izumi/distage/model/Injector.scala @@ -1,7 +1,7 @@ package izumi.distage.model import izumi.distage.model.definition.Axis.AxisChoice -import izumi.distage.model.definition.{Activation, Identifier, Lifecycle, ModuleBase} +import izumi.distage.model.definition.{Activation, Identifier, Lifecycle, LocatorPrivacy, ModuleBase} import izumi.functional.quasi.QuasiIO import izumi.distage.model.plan.{Plan, Roots} import izumi.distage.model.providers.Functoid @@ -60,7 +60,7 @@ trait Injector[F[_]] extends Planner with Producer { activation: Activation = Activation.empty, )(function: Functoid[F[A]] ): F[A] = { - produce(PlannerInput(bindings, activation, function.get.diKeys.toSet)) + produce(PlannerInput(bindings, function.get.diKeys.toSet, activation)) .use(_.run(function)) } @@ -109,7 +109,7 @@ trait Injector[F[_]] extends Planner with Producer { activation: Activation = Activation.empty, )(function: Functoid[F[A]] ): Lifecycle[F, A] = { - produce(PlannerInput(bindings, activation, function.get.diKeys.toSet)) + produce(PlannerInput(bindings, function.get.diKeys.toSet, activation)) .evalMap(_.run(function)) } @@ -189,8 +189,13 @@ trait Injector[F[_]] extends Planner with Producer { final def produce(input: PlannerInput): Lifecycle[F, Locator] = { produceCustomF[F](input) } - final def produce(bindings: ModuleBase, roots: Roots, activation: Activation = Activation.empty): Lifecycle[F, Locator] = { - produce(PlannerInput(bindings, activation, roots)) + final def produce( + bindings: ModuleBase, + roots: Roots, + activation: Activation = Activation.empty, + locatorPrivacy: LocatorPrivacy = LocatorPrivacy.PublicByDefault, + ): Lifecycle[F, Locator] = { + produce(PlannerInput(bindings, roots, activation, locatorPrivacy)) } /** diff --git a/distage/distage-core/src/main/scala/izumi/distage/model/recursive/Bootloader.scala b/distage/distage-core/src/main/scala/izumi/distage/model/recursive/Bootloader.scala index 151e0d579d..b0a1eccfc1 100644 --- a/distage/distage-core/src/main/scala/izumi/distage/model/recursive/Bootloader.scala +++ b/distage/distage-core/src/main/scala/izumi/distage/model/recursive/Bootloader.scala @@ -2,7 +2,7 @@ package izumi.distage.model.recursive import izumi.distage.InjectorFactory import izumi.distage.model.definition.errors.DIError -import izumi.distage.model.definition.{Activation, BootstrapModule, Id, Module, ModuleBase} +import izumi.distage.model.definition.{Activation, BootstrapModule, Id, LocatorPrivacy, Module, ModuleBase} import izumi.functional.quasi.QuasiIO import izumi.distage.model.plan.{Plan, Roots} import izumi.distage.model.{Injector, PlannerInput} @@ -23,6 +23,7 @@ final case class BootConfig( activation: Activation => Activation = identity, bootstrapActivation: Activation => Activation = identity, roots: Roots => Roots = identity, + locatorPrivacy: LocatorPrivacy => LocatorPrivacy = identity, ) class Bootloader( @@ -35,9 +36,12 @@ class Bootloader( def boot(config: BootConfig): Either[NEList[DIError], BootstrappedApp] = { val activation = config.activation(input.activation) val bootstrap = config.bootstrap(bootstrapModule) + val locatorPrivacy = config.locatorPrivacy(input.locatorPrivacy) + val injector = injectorFactory( bootstrapActivation = config.bootstrapActivation(bootstrapActivation), overrides = Seq(bootstrap), + locatorPrivacy = locatorPrivacy, )( QuasiIO[Identity], TagK[Identity], @@ -47,7 +51,7 @@ class Bootloader( val roots = config.roots(input.roots) for { - plan <- injector.plan(PlannerInput(module, activation, roots)) + plan <- injector.plan(PlannerInput(module, roots, activation, locatorPrivacy)) } yield { BootstrappedApp(injector, module, plan) } diff --git a/distage/distage-core/src/main/scala/izumi/distage/planning/AutoSetModule.scala b/distage/distage-core/src/main/scala/izumi/distage/planning/AutoSetModule.scala index 8ebe5d740f..d847007a74 100644 --- a/distage/distage-core/src/main/scala/izumi/distage/planning/AutoSetModule.scala +++ b/distage/distage-core/src/main/scala/izumi/distage/planning/AutoSetModule.scala @@ -20,11 +20,11 @@ abstract class AutoSetModule(name: Option[String]) extends BootstrapModuleDef { def registerOnly[T: Tag](filter: InclusionPredicate): AutoSetModule = { name match { case Some(id) => - many[T].named(id) + many[T].named(id).exposed many[PlanningHook].addValue(AutoSetHook[T](filter, name = id, weak = false)) case None => - many[T] + many[T].exposed many[PlanningHook].addValue(AutoSetHook[T](filter, weak = false)) } this diff --git a/distage/distage-core/src/main/scala/izumi/distage/planning/SubcontextHandler.scala b/distage/distage-core/src/main/scala/izumi/distage/planning/SubcontextHandler.scala index e4eaf45245..0b0f6e809c 100644 --- a/distage/distage-core/src/main/scala/izumi/distage/planning/SubcontextHandler.scala +++ b/distage/distage-core/src/main/scala/izumi/distage/planning/SubcontextHandler.scala @@ -24,7 +24,7 @@ object SubcontextHandler { val roots = c.extractingFunction.diKeys.toSet for { subplan <- planner - .plan(PlannerInput(c.module, input.activation, roots)) + .plan(PlannerInput(c.module, roots, input.activation)) .left.map(errors => LocalContextPlanningFailure(binding, c, errors)) } yield { val allImported = subplan.importedKeys diff --git a/distage/distage-core/src/main/scala/izumi/distage/provisioning/PlanInterpreterNonSequentialRuntimeImpl.scala b/distage/distage-core/src/main/scala/izumi/distage/provisioning/PlanInterpreterNonSequentialRuntimeImpl.scala index d621ce1a84..29833d517d 100644 --- a/distage/distage-core/src/main/scala/izumi/distage/provisioning/PlanInterpreterNonSequentialRuntimeImpl.scala +++ b/distage/distage-core/src/main/scala/izumi/distage/provisioning/PlanInterpreterNonSequentialRuntimeImpl.scala @@ -1,12 +1,13 @@ package izumi.distage.provisioning import izumi.distage.LocatorDefaultImpl -import izumi.distage.model.definition.{Id, Lifecycle} +import izumi.distage.model.definition.{Binding, BindingTag, Id, Lifecycle, LocatorPrivacy} import izumi.distage.model.definition.errors.ProvisionerIssue import izumi.distage.model.definition.errors.ProvisionerIssue.IncompatibleEffectTypes import izumi.distage.model.definition.errors.ProvisionerIssue.ProvisionerExceptionIssue.{IntegrationCheckFailure, UnexpectedIntegrationCheck} import izumi.distage.model.exceptions.runtime.IntegrationCheckException import izumi.distage.model.plan.ExecutableOp.* +import izumi.distage.model.plan.operations.OperationOrigin import izumi.distage.model.plan.{ExecutableOp, Plan, Roots} import izumi.distage.model.provisioning.* import izumi.distage.model.provisioning.PlanInterpreter.{FailedProvision, FailedProvisionInternal, FinalizerFilter} @@ -62,7 +63,9 @@ class PlanInterpreterNonSequentialRuntimeImpl( ): F[Either[FailedProvisionInternal[F], LocatorDefaultImpl[F]]] = { val integrationCheckFType = SafeType.get[IntegrationCheck[F]] - val ctx: ProvisionMutable[F] = new ProvisionMutable[F](plan, parentContext) + val privateBindings = computePrivateBindings(plan) + + val ctx: ProvisionMutable[F] = new ProvisionMutable[F](plan, parentContext, privateBindings) @nowarn("msg=Unused import") def run(state: TraversalState, integrationPaths: Set[DIKey]): F[Either[TraversalState, Either[FailedProvisionInternal[F], LocatorDefaultImpl[F]]]] = { @@ -118,6 +121,50 @@ class PlanInterpreterNonSequentialRuntimeImpl( } yield res } + private def computePrivateBindings(plan: Plan): Set[DIKey] = { + def isRoot(target: DIKey): Boolean = { + plan.input.roots match { + case Roots.Of(roots) => + roots.contains(target) + case Roots.Everything => + true + } + } + + def isPrivateBinding(target: DIKey, binding: Binding): Boolean = { + plan.input.locatorPrivacy match { + case LocatorPrivacy.PublicByDefault => + binding.tags.contains(BindingTag.Confined) + case LocatorPrivacy.PrivateByDefault => + !binding.tags.contains(BindingTag.Exposed) + case LocatorPrivacy.PublicRoots => + !isRoot(target) && !binding.tags.contains(BindingTag.Exposed) + } + } + + def isPrivate(op: ExecutableOp): Boolean = { + op.origin.value match { + case OperationOrigin.UserBinding(binding) => + isPrivateBinding(op.target, binding) + case OperationOrigin.SyntheticBinding(binding) => + isPrivateBinding(op.target, binding) + case OperationOrigin.Unknown => + plan.input.locatorPrivacy match { + case LocatorPrivacy.PublicByDefault => + false + case LocatorPrivacy.PrivateByDefault => + true + case LocatorPrivacy.PublicRoots => + isRoot(op.target) + } + } + } + + plan.stepsUnordered + .filter(isPrivate) + .map(_.target).toSet + } + private def failEarly[F[_]: TagK, A]( ctx: ProvisionMutable[F], initial: TraversalState, diff --git a/distage/distage-core/src/main/scala/izumi/distage/provisioning/ProvisionMutable.scala b/distage/distage-core/src/main/scala/izumi/distage/provisioning/ProvisionMutable.scala index 165c609314..86ec799aa9 100644 --- a/distage/distage-core/src/main/scala/izumi/distage/provisioning/ProvisionMutable.scala +++ b/distage/distage-core/src/main/scala/izumi/distage/provisioning/ProvisionMutable.scala @@ -18,9 +18,10 @@ import scala.collection.mutable final class ProvisionMutable[F[_]: TagK]( val plan: Plan, parentContext: Locator, + privateBindings: Set[DIKey], ) extends Provision[F] { - private val temporaryLocator = new LocatorDefaultImpl(plan, Option(parentContext), LocatorMeta.empty, this) + private val temporaryLocator = new LocatorDefaultImpl(plan, Option(parentContext), LocatorMeta.empty, this, privateBindings) private val locatorRef = new LocatorRef(new AtomicReference(Left(temporaryLocator))) @@ -57,7 +58,7 @@ final class ProvisionMutable[F[_]: TagK]( def finish(state: TraversalState): LocatorDefaultImpl[F] = { val meta = LocatorMeta(state.status()) val finalLocator = - new LocatorDefaultImpl(plan, Option(parentContext), meta, toImmutable) + new LocatorDefaultImpl(plan, Option(parentContext), meta, toImmutable, privateBindings) locatorRef.ref.set(Right(finalLocator)) finalLocator } diff --git a/distage/distage-core/src/test/scala-2/izumi/distage/injector/InnerClassesTest.scala b/distage/distage-core/src/test/scala-2/izumi/distage/injector/InnerClassesTest.scala index 997cc53ce6..1bc6fb8546 100644 --- a/distage/distage-core/src/test/scala-2/izumi/distage/injector/InnerClassesTest.scala +++ b/distage/distage-core/src/test/scala-2/izumi/distage/injector/InnerClassesTest.scala @@ -3,12 +3,12 @@ package izumi.distage.injector import izumi.distage.constructors.FactoryConstructor import izumi.distage.fixtures.InnerClassCases.* import izumi.distage.model.PlannerInput -import izumi.distage.model.definition.{Activation, ModuleDef} +import izumi.distage.model.definition.ModuleDef import org.scalatest.wordspec.AnyWordSpec class InnerClassesTest extends AnyWordSpec with MkInjector { "can instantiate inner classes from stable objects where the classes are inherited from a trait" in { - import InnerClassStablePathsCase._ + import InnerClassStablePathsCase.* val definition = PlannerInput.everything(new ModuleDef { make[StableObjectInheritingTrait.TestDependency] @@ -23,8 +23,8 @@ class InnerClassesTest extends AnyWordSpec with MkInjector { } "can instantiate inner classes from stable objects where the classes are inherited from a trait and depend on types defined inside trait" in { - import InnerClassStablePathsCase._ - import StableObjectInheritingTrait._ + import InnerClassStablePathsCase.* + import StableObjectInheritingTrait.* val definition = PlannerInput.everything(new ModuleDef { make[TestDependency] @@ -37,7 +37,7 @@ class InnerClassesTest extends AnyWordSpec with MkInjector { } "can support path-dependant injections with injector lookup" in { - import InnerClassUnstablePathsCase._ + import InnerClassUnstablePathsCase.* val testProviderModule = new TestModule @@ -56,7 +56,7 @@ class InnerClassesTest extends AnyWordSpec with MkInjector { "can handle function local path-dependent injections" in { def someFunction() = { - import InnerClassUnstablePathsCase._ + import InnerClassUnstablePathsCase.* val testProviderModule = new TestModule @@ -98,7 +98,7 @@ class InnerClassesTest extends AnyWordSpec with MkInjector { } "support path-dependent by-name injections" in { - import InnerClassByNameCase._ + import InnerClassByNameCase.* val testProviderModule = new TestModule @@ -149,8 +149,8 @@ class InnerClassesTest extends AnyWordSpec with MkInjector { } "can now find proper constructor for by-name circular dependencies inside stable objects that contain inner classes from inherited traits that depend on types defined inside trait" in { - import InnerClassStablePathsCase._ - import StableObjectInheritingTrait._ + import InnerClassStablePathsCase.* + import StableObjectInheritingTrait.* val definition = PlannerInput.everything(new ModuleDef { make[ByNameCircular1] @@ -164,7 +164,7 @@ class InnerClassesTest extends AnyWordSpec with MkInjector { } "can now handle path-dependent factories" in { - import InnerClassUnstablePathsCase._ + import InnerClassUnstablePathsCase.* val testProviderModule = new TestModule FactoryConstructor[testProviderModule.TestFactory] @@ -173,8 +173,7 @@ class InnerClassesTest extends AnyWordSpec with MkInjector { new ModuleDef { make[testProviderModule.type].from[testProviderModule.type](testProviderModule: testProviderModule.type) makeFactory[testProviderModule.TestFactory] - }, - Activation.empty, + } ) val context = mkInjector().produce(definition).unsafeGet() diff --git a/distage/distage-core/src/test/scala/izumi/distage/dsl/DSLTest.scala b/distage/distage-core/src/test/scala/izumi/distage/dsl/DSLTest.scala index c8fb00dfc5..32135deb2f 100644 --- a/distage/distage-core/src/test/scala/izumi/distage/dsl/DSLTest.scala +++ b/distage/distage-core/src/test/scala/izumi/distage/dsl/DSLTest.scala @@ -104,7 +104,7 @@ class DSLTest extends AnyWordSpec with MkInjector with should.Matchers { } val injector = mkInjector() - val definitionAnnotated = PlannerInput(ModuleAnnotated, Activation(), Roots.Everything) + val definitionAnnotated = PlannerInput(ModuleAnnotated, Roots.Everything, Activation()) val planAnnotated = injector.planUnsafe(definitionAnnotated) assert(planAnnotated.definition.bindings.nonEmpty) diff --git a/distage/distage-core/src/test/scala/izumi/distage/gc/GcBasicTests.scala b/distage/distage-core/src/test/scala/izumi/distage/gc/GcBasicTests.scala index 611aa49d8d..0449361e57 100644 --- a/distage/distage-core/src/test/scala/izumi/distage/gc/GcBasicTests.scala +++ b/distage/distage-core/src/test/scala/izumi/distage/gc/GcBasicTests.scala @@ -22,8 +22,8 @@ class GcBasicTests extends AnyWordSpec with MkGcInjector { make[Circular1] make[Circular2] }, - Activation.empty, Roots(DIKey.get[Circular2]), + Activation.empty, ) ) } @@ -43,8 +43,8 @@ class GcBasicTests extends AnyWordSpec with MkGcInjector { make[T1] make[Box[T1]].from(new Box(new T1)) }, - Activation.empty, Roots(DIKey.get[Circular1], DIKey.get[Circular2]), + Activation.empty, ) ) @@ -61,7 +61,7 @@ class GcBasicTests extends AnyWordSpec with MkGcInjector { val roots = Set[DIKey](DIKey.get[Set[Elem]]) - val objects = mkInjector().produce(PlannerInput(module, Activation.empty, roots)).unsafeGet() + val objects = mkInjector().produce(PlannerInput(module, roots, Activation.empty)).unsafeGet() assert(objects.find[Strong].nonEmpty) assert(objects.find[Weak].isEmpty) diff --git a/distage/distage-core/src/test/scala/izumi/distage/impl/BootstrapTest.scala b/distage/distage-core/src/test/scala/izumi/distage/impl/BootstrapTest.scala index 29df6b5dd8..48ac531ce4 100644 --- a/distage/distage-core/src/test/scala/izumi/distage/impl/BootstrapTest.scala +++ b/distage/distage-core/src/test/scala/izumi/distage/impl/BootstrapTest.scala @@ -1,7 +1,7 @@ package izumi.distage.impl -import distage.{Activation, DIKey} -import izumi.distage.bootstrap.{BootstrapLocator, Cycles} +import distage.{Activation, DIKey, LocatorPrivacy} +import izumi.distage.bootstrap.{BootstrapLocator, BootstrapRootsMode, Cycles} import izumi.distage.model.exceptions.runtime.MissingInstanceException import izumi.distage.planning.solver.PlanSolver import org.scalatest.wordspec.AnyWordSpec @@ -10,7 +10,14 @@ class BootstrapTest extends AnyWordSpec { "Bootstrap Context" should { "contain expected definitions" in { - val context = BootstrapLocator.bootstrap(BootstrapLocator.defaultBootstrap, Activation(Cycles -> Cycles.Byname), Nil, None) + val context = BootstrapLocator.bootstrap( + BootstrapLocator.defaultBootstrap, + Activation(Cycles -> Cycles.Byname), + Nil, + None, + LocatorPrivacy.PublicByDefault, + BootstrapRootsMode.UseGC, + ) val maybeRef = context.find[PlanSolver] val ref = context.lookupLocal[PlanSolver](DIKey.get[PlanSolver]) diff --git a/distage/distage-core/src/test/scala/izumi/distage/injector/AxisTest.scala b/distage/distage-core/src/test/scala/izumi/distage/injector/AxisTest.scala index 7c93d30392..03fc28915a 100644 --- a/distage/distage-core/src/test/scala/izumi/distage/injector/AxisTest.scala +++ b/distage/distage-core/src/test/scala/izumi/distage/injector/AxisTest.scala @@ -22,13 +22,13 @@ class AxisTest extends AnyWordSpec with MkInjector { } val injector1 = mkInjector() - val context1 = injector1.produce(PlannerInput(definition, Activation(Repo -> Repo.Prod), Roots(DIKey.get[JustTrait]))).unsafeGet() + val context1 = injector1.produce(PlannerInput(definition, Roots(DIKey.get[JustTrait]), Activation(Repo -> Repo.Prod))).unsafeGet() assert(context1.get[JustTrait].isInstanceOf[Impl1]) assert(!context1.get[JustTrait].isInstanceOf[Impl0]) val injector2 = mkInjector() - val context2 = injector2.produce(PlannerInput(definition, Activation(Repo -> Repo.Dummy), Roots(DIKey.get[JustTrait]))).unsafeGet() + val context2 = injector2.produce(PlannerInput(definition, Roots(DIKey.get[JustTrait]), Activation(Repo -> Repo.Dummy))).unsafeGet() assert(context2.get[JustTrait].isInstanceOf[Impl0]) assert(!context2.get[JustTrait].isInstanceOf[Impl1]) @@ -38,19 +38,19 @@ class AxisTest extends AnyWordSpec with MkInjector { import BasicCase1._ val bsDefinition = new BootstrapModuleDef { - make[JustTrait].tagged(Repo.Dummy).from[Impl0] - make[JustTrait].tagged(Repo.Prod).from[Impl1] + make[JustTrait].tagged(Repo.Dummy).from[Impl0].exposed + make[JustTrait].tagged(Repo.Prod).from[Impl1].exposed } val appDefinition = Module.empty val injector1 = Injector[Identity](bootstrapActivation = Activation(Repo -> Repo.Prod), overrides = Seq(bsDefinition)) - val context1 = injector1.produce(PlannerInput(appDefinition, Activation.empty, Roots.Everything)).unsafeGet() + val context1 = injector1.produce(PlannerInput(appDefinition, Roots.Everything, Activation.empty)).unsafeGet() assert(context1.get[JustTrait].isInstanceOf[Impl1]) assert(!context1.get[JustTrait].isInstanceOf[Impl0]) val injector2 = Injector[Identity](bootstrapActivation = Activation(Repo -> Repo.Dummy), overrides = Seq(bsDefinition)) - val context2 = injector2.produce(PlannerInput(appDefinition, Activation.empty, Roots.Everything)).unsafeGet() + val context2 = injector2.produce(PlannerInput(appDefinition, Roots.Everything, Activation.empty)).unsafeGet() assert(context2.get[JustTrait].isInstanceOf[Impl0]) assert(!context2.get[JustTrait].isInstanceOf[Impl1]) @@ -64,7 +64,7 @@ class AxisTest extends AnyWordSpec with MkInjector { } val context = mkInjector() - .produce(PlannerInput(definition, Activation(Repo -> Repo.Prod), Roots.Everything)) + .produce(PlannerInput(definition, Roots.Everything, Activation(Repo -> Repo.Prod))) .unsafeGet() assert(context.find[JustTrait].isEmpty) @@ -167,7 +167,7 @@ class AxisTest extends AnyWordSpec with MkInjector { } val instance = mkInjector() - .produce(PlannerInput(definition, Activation(Repo -> Repo.Dummy), Roots(DIKey[Set[SetTrait]]))) + .produce(PlannerInput(definition, Roots(DIKey[Set[SetTrait]]), Activation(Repo -> Repo.Dummy))) .unsafeGet() .get[Set[SetTrait]] @@ -188,7 +188,7 @@ class AxisTest extends AnyWordSpec with MkInjector { intercept[InjectorFailed] { mkInjector() - .produce(PlannerInput(definition, Activation(), Roots(DIKey[Set[SetTrait]]))) + .produce(PlannerInput(definition, Roots(DIKey[Set[SetTrait]]), Activation())) .unsafeGet() .get[Set[SetTrait]] } @@ -207,7 +207,7 @@ class AxisTest extends AnyWordSpec with MkInjector { intercept[InjectorFailed] { mkInjector() - .produce(PlannerInput(definition, Activation(), Roots(DIKey[Set[SetTrait]]))) + .produce(PlannerInput(definition, Roots(DIKey[Set[SetTrait]]), Activation())) .unsafeGet() .get[Set[SetTrait]] } @@ -223,7 +223,7 @@ class AxisTest extends AnyWordSpec with MkInjector { } val set = mkInjector() - .produce(PlannerInput(definition, Activation(Repo.Dummy), Roots(DIKey[Set[Service]]))) + .produce(PlannerInput(definition, Roots(DIKey[Set[Service]]), Activation(Repo.Dummy))) .unsafeGet() .get[Set[Service]] assert(set.size == 1) @@ -240,7 +240,7 @@ class AxisTest extends AnyWordSpec with MkInjector { intercept[InjectorFailed] { mkInjector() - .produce(PlannerInput(definition, Activation(Repo.Dummy), Roots(DIKey[Set[Service]]))) + .produce(PlannerInput(definition, Roots(DIKey[Set[Service]]), Activation(Repo.Dummy))) .unsafeGet() .get[Set[Service]] } @@ -256,7 +256,7 @@ class AxisTest extends AnyWordSpec with MkInjector { } val set = mkInjector() - .produce(PlannerInput(definition, Activation(Repo.Dummy), Roots(DIKey[Set[Service]]))) + .produce(PlannerInput(definition, Roots(DIKey[Set[Service]]), Activation(Repo.Dummy))) .unsafeGet() .get[Set[Service]] assert(set.size == 1) @@ -275,28 +275,28 @@ class AxisTest extends AnyWordSpec with MkInjector { } val instance1 = mkInjector() - .produce(PlannerInput(definitionTodo, Activation(Repo.Dummy), Roots(DIKey[Set[SetTrait]]))) + .produce(PlannerInput(definitionTodo, Roots(DIKey[Set[SetTrait]]), Activation(Repo.Dummy))) .unsafeGet() .get[Set[SetTrait]] assert(instance1.isEmpty) val instance2 = mkInjector() - .produce(PlannerInput(definitionTodo, Activation(Repo.Prod), Roots(DIKey[Set[SetTrait]]))) + .produce(PlannerInput(definitionTodo, Roots(DIKey[Set[SetTrait]]), Activation(Repo.Prod))) .unsafeGet() .get[Set[SetTrait]] assert(instance2.size == 1) val instance3 = mkInjector() - .produce(PlannerInput(baseDef, Activation(Repo.Prod), Roots(DIKey[Set[SetTrait]]))) + .produce(PlannerInput(baseDef, Roots(DIKey[Set[SetTrait]]), Activation(Repo.Prod))) .unsafeGet() .get[Set[SetTrait]] assert(instance3.size == 1) val instance4 = mkInjector() - .produce(PlannerInput(baseDef, Activation(Repo.Dummy), Roots(DIKey[Set[SetTrait]]))) + .produce(PlannerInput(baseDef, Roots(DIKey[Set[SetTrait]]), Activation(Repo.Dummy))) .unsafeGet() .get[Set[SetTrait]] @@ -313,7 +313,7 @@ class AxisTest extends AnyWordSpec with MkInjector { } val instance = mkInjector() - .produce(PlannerInput(definition, Activation(Repo -> Repo.Dummy), Roots(DIKey[X]))) + .produce(PlannerInput(definition, Roots(DIKey[X]), Activation(Repo -> Repo.Dummy))) .unsafeGet() .get[X] diff --git a/distage/distage-core/src/test/scala/izumi/distage/injector/PlanOperationsTest.scala b/distage/distage-core/src/test/scala/izumi/distage/injector/PlanOperationsTest.scala index 2d325d5d8e..f6e09c197b 100644 --- a/distage/distage-core/src/test/scala/izumi/distage/injector/PlanOperationsTest.scala +++ b/distage/distage-core/src/test/scala/izumi/distage/injector/PlanOperationsTest.scala @@ -29,8 +29,8 @@ class PlanOperationsTest extends AnyWordSpec with MkInjector { make[SharedComponent1] make[SharedComponent2] }, - Activation.empty, primary ++ sub, + Activation.empty, ) val srcPlan = injector.planUnsafe(definition) diff --git a/distage/distage-core/src/test/scala/izumi/distage/injector/PrivateBindingsTest.scala b/distage/distage-core/src/test/scala/izumi/distage/injector/PrivateBindingsTest.scala new file mode 100644 index 0000000000..a3879b0a7f --- /dev/null +++ b/distage/distage-core/src/test/scala/izumi/distage/injector/PrivateBindingsTest.scala @@ -0,0 +1,110 @@ +package izumi.distage.injector + +import distage.{DIKey, Injector, LocatorPrivacy, ModuleDef, Roots} +import izumi.distage.fixtures.BasicCases.BasicCase1.* +import izumi.distage.model.PlannerInput +import org.scalatest.wordspec.AnyWordSpec + +class PrivateBindingsTest extends AnyWordSpec with MkInjector { + "Support private bindings in public-by-default mode" in { + val def1 = PlannerInput( + new ModuleDef { + make[TestDependency0].from[TestImpl0].confined + }, + Roots(DIKey.get[TestDependency0]), + ) + .withLocatorPrivacy(LocatorPrivacy.PublicByDefault) + + val (loc1, loc2) = prepareInheritedLocator(def1) + + assert(loc1.find[TestDependency0].nonEmpty) + assert(loc2.find[JustTrait].nonEmpty) + assert(loc2.find[TestDependency0].isEmpty) + } + + "Support public bindings in public-by-default mode" in { + val def1 = PlannerInput( + new ModuleDef { + make[TestDependency0].from[TestImpl0] + }, + Roots(DIKey.get[TestDependency0]), + ) + .withLocatorPrivacy(LocatorPrivacy.PublicByDefault) + val (loc1, loc2) = prepareInheritedLocator(def1) + + assert(loc1.find[TestDependency0].nonEmpty) + assert(loc2.find[JustTrait].nonEmpty) + assert(loc2.find[TestDependency0].nonEmpty) + } + + "Support private bindings in private-by-default mode" in { + val def1 = PlannerInput( + new ModuleDef { + make[TestDependency0].from[TestImpl0] + }, + Roots(DIKey.get[TestDependency0]), + ) + .withLocatorPrivacy(LocatorPrivacy.PrivateByDefault) + + val (loc1, loc2) = prepareInheritedLocator(def1) + + assert(loc1.find[TestDependency0].nonEmpty) + assert(loc2.find[JustTrait].nonEmpty) + assert(loc2.find[TestDependency0].isEmpty) + } + + "Support public bindings in private-by-default mode" in { + val def1 = PlannerInput( + new ModuleDef { + make[TestDependency0].from[TestImpl0].exposed + }, + Roots(DIKey.get[TestDependency0]), + ) + .withLocatorPrivacy(LocatorPrivacy.PrivateByDefault) + + val (loc1, loc2) = prepareInheritedLocator(def1) + + assert(loc1.find[TestDependency0].nonEmpty) + assert(loc2.find[JustTrait].nonEmpty) + assert(loc2.find[TestDependency0].nonEmpty) + } + + "Support private bindings in public-roots mode" in { + val def1 = PlannerInput + .target[TestCaseClass2]( + new ModuleDef { + make[TestInstanceBinding].fromValue(TestInstanceBinding()) + make[TestCaseClass2] + } + ) + .withLocatorPrivacy(LocatorPrivacy.PublicRoots) + + val (loc1, loc2) = prepareInheritedLocator(def1) + + assert(loc1.find[TestCaseClass2].nonEmpty) + assert(loc1.find[TestInstanceBinding].nonEmpty) + + assert(loc2.find[TestCaseClass2].nonEmpty) + assert(loc2.find[TestInstanceBinding].isEmpty) + } + + private def prepareInheritedLocator(def1: PlannerInput) = { + val injector = mkInjector() + + val plan1 = injector.planUnsafe(def1) + val loc = injector.produce(plan1).unsafeGet() + + val injector2 = Injector.inherit(loc) + + val def2 = PlannerInput + .everything(new ModuleDef { + make[JustTrait].from[Impl0] + }) + .withLocatorPrivacy(def1.locatorPrivacy) // we don't need this at the moment, but it may change in the future + + val plan2 = injector2.planUnsafe(def2) + val loc2 = injector2.produce(plan2).unsafeGet() + (loc, loc2) + } + +} diff --git a/distage/distage-core/src/test/scala/izumi/distage/injector/ResourceEffectBindingsTest.scala b/distage/distage-core/src/test/scala/izumi/distage/injector/ResourceEffectBindingsTest.scala index ca3866ae60..1b44b4eeb3 100644 --- a/distage/distage-core/src/test/scala/izumi/distage/injector/ResourceEffectBindingsTest.scala +++ b/distage/distage-core/src/test/scala/izumi/distage/injector/ResourceEffectBindingsTest.scala @@ -34,8 +34,8 @@ class ResourceEffectBindingsTest extends AnyWordSpec with MkInjector with GivenW (i: Int @Id("2")) => 10 + i } }, - Activation.empty, Roots(DIKey.get[Int]), + Activation.empty, ) val injector = mkInjector() @@ -53,8 +53,8 @@ class ResourceEffectBindingsTest extends AnyWordSpec with MkInjector with GivenW (i: Int @Id("2")) => Suspend2(10 + i) } }, - Activation.empty, Roots(DIKey.get[Int]), + Activation.empty, ) val injector = mkInjector() @@ -95,8 +95,8 @@ class ResourceEffectBindingsTest extends AnyWordSpec with MkInjector with GivenW (i: Int @Id("2")) => 10 + i } }, - Activation.empty, Roots(DIKey.get[Int]), + Activation.empty, ) val injector = mkInjector() diff --git a/distage/distage-extension-config/.jvm/src/test/scala/izumi/distage/config/ConfigTest.scala b/distage/distage-extension-config/.jvm/src/test/scala/izumi/distage/config/ConfigTest.scala index fa53920bb2..7524000f4a 100644 --- a/distage/distage-extension-config/.jvm/src/test/scala/izumi/distage/config/ConfigTest.scala +++ b/distage/distage-extension-config/.jvm/src/test/scala/izumi/distage/config/ConfigTest.scala @@ -17,8 +17,7 @@ final class ConfigTest extends AnyWordSpec { def mkConfigModule(path: String)(p: PlannerInput): PlannerInput = { p.copy(bindings = p.bindings ++ - mkModule(ConfigFactory.load(path, ConfigParseOptions.defaults().setAllowMissing(false), ConfigResolveOptions.noSystem())) - ) + mkModule(ConfigFactory.load(path, ConfigParseOptions.defaults().setAllowMissing(false), ConfigResolveOptions.noSystem()))) } def mkModule(config: Config): AppConfigModule = { diff --git a/distage/distage-extension-config/src/main/scala/izumi/distage/config/AppConfigModule.scala b/distage/distage-extension-config/src/main/scala/izumi/distage/config/AppConfigModule.scala index 8f6bd3e44a..03202d93c4 100644 --- a/distage/distage-extension-config/src/main/scala/izumi/distage/config/AppConfigModule.scala +++ b/distage/distage-extension-config/src/main/scala/izumi/distage/config/AppConfigModule.scala @@ -4,7 +4,7 @@ import izumi.distage.config.model.AppConfig import izumi.distage.model.definition.ModuleDef class AppConfigModule(appConfig: AppConfig) extends ModuleDef { - make[AppConfig].fromValue(appConfig) + make[AppConfig].fromValue(appConfig).exposed } object AppConfigModule { diff --git a/distage/distage-extension-logstage/src/main/scala/izumi/logstage/distage/LogstageModule.scala b/distage/distage-extension-logstage/src/main/scala/izumi/logstage/distage/LogstageModule.scala index 05bf045e03..d1d4f065dc 100644 --- a/distage/distage-extension-logstage/src/main/scala/izumi/logstage/distage/LogstageModule.scala +++ b/distage/distage-extension-logstage/src/main/scala/izumi/logstage/distage/LogstageModule.scala @@ -14,6 +14,7 @@ class LogstageModule(router: LogRouter, setupStaticLogRouter: Boolean) extends B make[IzLogger] .aliased[RoutingLogger] .aliased[AbstractLogger] + .exposed make[LogRouter].fromValue(router) make[CustomContext].fromValue(CustomContext.empty) diff --git a/distage/distage-framework/.jvm/src/test/scala/com/github/pshirshov/test3/bootstrap/BootstrapFixture3.scala b/distage/distage-framework/.jvm/src/test/scala/com/github/pshirshov/test3/bootstrap/BootstrapFixture3.scala index 67cb369db5..615a0b78dc 100644 --- a/distage/distage-framework/.jvm/src/test/scala/com/github/pshirshov/test3/bootstrap/BootstrapFixture3.scala +++ b/distage/distage-framework/.jvm/src/test/scala/com/github/pshirshov/test3/bootstrap/BootstrapFixture3.scala @@ -11,8 +11,8 @@ object BootstrapFixture3 { final case class BasicConfig(a: Boolean, b: Int) object BootstrapPlugin extends BootstrapPluginDef() with ConfigModuleDef { - makeConfig[BasicConfig]("basicConfig") - make[BootstrapComponent] + makeConfig[BasicConfig]("basicConfig").exposed + make[BootstrapComponent].exposed } final class UnsatisfiedDep diff --git a/distage/distage-framework/.jvm/src/test/scala/izumi/distage/roles/test/RoleAppTest.scala b/distage/distage-framework/.jvm/src/test/scala/izumi/distage/roles/test/RoleAppTest.scala index 383d1591f9..3993c1bab4 100644 --- a/distage/distage-framework/.jvm/src/test/scala/izumi/distage/roles/test/RoleAppTest.scala +++ b/distage/distage-framework/.jvm/src/test/scala/izumi/distage/roles/test/RoleAppTest.scala @@ -176,7 +176,7 @@ class RoleAppTest extends AnyWordSpec with WithProperties { options = PlanningOptions(), activation = Activation.empty, bsModule = BootstrapModule.empty, - bootloader = Injector.bootloader[Identity](BootstrapModule.empty, Activation.empty, DefaultModule.empty, PlannerInput(definition, Activation.empty, roots)), + bootloader = Injector.bootloader[Identity](BootstrapModule.empty, Activation.empty, DefaultModule.empty, PlannerInput(definition, roots, Activation.empty)), logger = logger, ) @@ -213,7 +213,7 @@ class RoleAppTest extends AnyWordSpec with WithProperties { options = PlanningOptions(), activation = Activation.empty, bsModule = BootstrapModule.empty, - bootloader = Injector.bootloader[Identity](BootstrapModule.empty, Activation.empty, DefaultModule.empty, PlannerInput(definition, Activation.empty, roots)), + bootloader = Injector.bootloader[Identity](BootstrapModule.empty, Activation.empty, DefaultModule.empty, PlannerInput(definition, roots, Activation.empty)), logger = logger, ) @@ -254,7 +254,7 @@ class RoleAppTest extends AnyWordSpec with WithProperties { options = PlanningOptions(), activation = Activation.empty, bsModule = BootstrapModule.empty, - bootloader = Injector.bootloader[Identity](BootstrapModule.empty, Activation.empty, DefaultModule.empty, PlannerInput(definition, Activation.empty, roots)), + bootloader = Injector.bootloader[Identity](BootstrapModule.empty, Activation.empty, DefaultModule.empty, PlannerInput(definition, roots, Activation.empty)), logger = logger, ) diff --git a/distage/distage-framework/src/main/scala/izumi/distage/framework/services/ModuleProvider.scala b/distage/distage-framework/src/main/scala/izumi/distage/framework/services/ModuleProvider.scala index 288c0fba00..b029e3f57c 100644 --- a/distage/distage-framework/src/main/scala/izumi/distage/framework/services/ModuleProvider.scala +++ b/distage/distage-framework/src/main/scala/izumi/distage/framework/services/ModuleProvider.scala @@ -74,10 +74,10 @@ object ModuleProvider { def bootstrapModules(): Seq[BootstrapModule] = { val roleInfoModule = new BootstrapModuleDef { - make[RolesInfo].fromValue(roles) - make[RawAppArgs].fromValue(args) - make[ActivationInfo].fromValue(activationInfo) - make[AppShutdownInitiator].fromValue(shutdownInitiator) + make[RolesInfo].fromValue(roles).exposed + make[RawAppArgs].fromValue(args).exposed + make[ActivationInfo].fromValue(activationInfo).exposed + make[AppShutdownInitiator].fromValue(shutdownInitiator).exposed } val loggerModule = new LogstageModule(logRouter, true) diff --git a/distage/distage-framework/src/main/scala/izumi/distage/framework/services/RoleAppPlanner.scala b/distage/distage-framework/src/main/scala/izumi/distage/framework/services/RoleAppPlanner.scala index 5e0a729bba..e40a662cfd 100644 --- a/distage/distage-framework/src/main/scala/izumi/distage/framework/services/RoleAppPlanner.scala +++ b/distage/distage-framework/src/main/scala/izumi/distage/framework/services/RoleAppPlanner.scala @@ -14,8 +14,6 @@ import izumi.reflect.TagK trait RoleAppPlanner { def bootloader: Bootloader - -// def reboot(bsModule: BootstrapModule, config: Option[AppConfig]): RoleAppPlanner def makePlan(appMainRoots: Set[DIKey]): AppStartupPlans } @@ -33,11 +31,7 @@ object RoleAppPlanner { bsModule: BootstrapModule @Id("roleapp"), val bootloader: Bootloader @Id("roleapp"), logger: IzLogger, -// parser: ActivationParser, - ) /*(implicit - defaultModule: DefaultModule[F] - )*/ - extends RoleAppPlanner { self => + ) extends RoleAppPlanner { self => private val runtimeGcRoots: Set[DIKey] = Set( DIKey.get[QuasiIORunner[F]], @@ -45,17 +39,6 @@ object RoleAppPlanner { DIKey.get[QuasiAsync[F]], ) -// override def reboot(bsOverride: BootstrapModule, config: Option[AppConfig]): RoleAppPlanner = { -// val configOverride = new BootstrapModuleDef { -// config.foreach(cfg => include(AppConfigModule(cfg))) -// } -// val updatedBsModule = bsModule overriddenBy bsOverride overriddenBy configOverride -// -// val activation = config.map(parser.parseActivation).getOrElse(this.activation) -// -// new RoleAppPlanner.Impl[F](options, activation, updatedBsModule, bootloader, logger, parser) -// } - override def makePlan(appMainRoots: Set[DIKey]): AppStartupPlans = { logger.trace(s"Application will use: ${appMainRoots -> "app roots"} and $activation") @@ -76,7 +59,7 @@ object RoleAppPlanner { logger.trace(s"Bootstrap plan:\n${bootstrapped.plan.render() -> "bootstrap dump" -> null}") logger.trace(s"App module: ${(bootstrapped.module: ModuleBase) -> "app module" -> null}") } - appPlan <- bootstrapped.injector.plan(PlannerInput(bootstrapped.module.drop(runtimeKeys), activation, appMainRoots)) + appPlan <- bootstrapped.injector.plan(PlannerInput(bootstrapped.module.drop(runtimeKeys), appMainRoots, activation)) } yield { val check = new PlanCircularDependencyCheck(options, logger) diff --git a/distage/distage-framework/src/main/scala/izumi/distage/roles/RoleAppBootModule.scala b/distage/distage-framework/src/main/scala/izumi/distage/roles/RoleAppBootModule.scala index a088f92951..763c6e3d16 100644 --- a/distage/distage-framework/src/main/scala/izumi/distage/roles/RoleAppBootModule.scala +++ b/distage/distage-framework/src/main/scala/izumi/distage/roles/RoleAppBootModule.scala @@ -157,7 +157,7 @@ class RoleAppBootModule[F[_]: TagK: DefaultModule]( roots: Set[DIKey] @Id("distage.roles.roots"), defaultModule: DefaultModule[F], ) => - injectorFactory.bootloader(bsModule, bsActivation, defaultModule, PlannerInput(appModule, activation, roots)) + injectorFactory.bootloader(bsModule, bsActivation, defaultModule, PlannerInput(appModule, roots, activation)) } make[RoleAppPlanner].from[RoleAppPlanner.Impl[F]] diff --git a/distage/distage-testkit-core/src/main/scala/izumi/distage/testkit/runner/impl/TestPlanner.scala b/distage/distage-testkit-core/src/main/scala/izumi/distage/testkit/runner/impl/TestPlanner.scala index b173ee11af..6aac01ed81 100644 --- a/distage/distage-testkit-core/src/main/scala/izumi/distage/testkit/runner/impl/TestPlanner.scala +++ b/distage/distage-testkit-core/src/main/scala/izumi/distage/testkit/runner/impl/TestPlanner.scala @@ -269,8 +269,8 @@ class TestPlanner[F[_]: TagK: DefaultModule]( runtimePlan <- injector.plan( PlannerInput( appModule ++ new TestRuntimeModule(envExecutionParams), - fullActivation, runtimeGcRoots, + fullActivation, ) ) _ <- Right(planChecker.showProxyWarnings(runtimePlan)) @@ -291,7 +291,7 @@ class TestPlanner[F[_]: TagK: DefaultModule]( .map { case (testRoots, distageTests) => for { - plan <- if (testRoots.nonEmpty) injector.plan(PlannerInput(reducedAppModule, fullActivation, testRoots)) else Right(Plan.empty) + plan <- if (testRoots.nonEmpty) injector.plan(PlannerInput(reducedAppModule, testRoots, fullActivation)) else Right(Plan.empty) _ <- Right(planChecker.showProxyWarnings(plan)) } yield { distageTests.map(AlmostPreparedTest(_, reducedAppModule, plan.keys, fullActivation)) @@ -364,7 +364,7 @@ class TestPlanner[F[_]: TagK: DefaultModule]( for { plan <- if (sharedKeys.nonEmpty) { - injector.plan(PlannerInput(appModule, activation, sharedKeys)) + injector.plan(PlannerInput(appModule, sharedKeys, activation)) } else { Right(Plan.empty) } diff --git a/distage/distage-testkit-core/src/main/scala/izumi/distage/testkit/runner/impl/TestTreeBuilder.scala b/distage/distage-testkit-core/src/main/scala/izumi/distage/testkit/runner/impl/TestTreeBuilder.scala index becaab320d..21253a37a7 100644 --- a/distage/distage-testkit-core/src/main/scala/izumi/distage/testkit/runner/impl/TestTreeBuilder.scala +++ b/distage/distage-testkit-core/src/main/scala/izumi/distage/testkit/runner/impl/TestTreeBuilder.scala @@ -58,7 +58,7 @@ object TestTreeBuilder { /** (1) It's important to remember that .plan() would always return the same result regardless of the parent locator! * (2) The planner here must preserve customizations (bootstrap modules) hence be the same as instantiated in TestPlanner */ - planner.plan(PlannerInput(newAppModule, t.activation, newRoots)) + planner.plan(PlannerInput(newAppModule, newRoots, t.activation)) } else { Right(Plan.empty) } diff --git a/distage/distage-testkit-core/src/main/scala/izumi/distage/testkit/spec/DistageTestEnv.scala b/distage/distage-testkit-core/src/main/scala/izumi/distage/testkit/spec/DistageTestEnv.scala index 5dfc5f0659..a91e6a3c80 100644 --- a/distage/distage-testkit-core/src/main/scala/izumi/distage/testkit/spec/DistageTestEnv.scala +++ b/distage/distage-testkit-core/src/main/scala/izumi/distage/testkit/spec/DistageTestEnv.scala @@ -92,7 +92,7 @@ object DistageTestEnv { private[distage] def testkitBootstrapReflectiveModule(availableActivations: ActivationInfo): BootstrapModuleDef = new BootstrapModuleDef { // Update `testkitBootstrapReflectiveKeys` if you add anything here - make[ActivationInfo].fromValue(availableActivations) + make[ActivationInfo].fromValue(availableActivations).exposed } lazy val testkitBootstrapReflectiveKeys: Set[DIKey] = { diff --git a/doc/microsite/src/main/tut/distage/advanced-features.md b/doc/microsite/src/main/tut/distage/advanced-features.md index c6fc9d215f..0335687b9f 100644 --- a/doc/microsite/src/main/tut/distage/advanced-features.md +++ b/doc/microsite/src/main/tut/distage/advanced-features.md @@ -394,7 +394,7 @@ def module = new ModuleDef { make[InjectionInfo] } -val input = PlannerInput(module, Activation.empty, Roots.target[InjectionInfo]) +val input = PlannerInput(module, Roots.target[InjectionInfo], Activation.empty) val injectionInfo = Injector().produce(input).unsafeGet().get[InjectionInfo] diff --git a/doc/microsite/src/main/tut/distage/basics.md b/doc/microsite/src/main/tut/distage/basics.md index c8012c433b..b43fca7075 100644 --- a/doc/microsite/src/main/tut/distage/basics.md +++ b/doc/microsite/src/main/tut/distage/basics.md @@ -159,7 +159,7 @@ import distage.{Activation, Injector, Roots} val injector = Injector[Task]() -val plan = injector.plan(HelloByeModule, Activation.empty, Roots.target[HelloByeApp]).getOrThrow() +val plan = injector.plan(HelloByeModule, Roots.target[HelloByeApp], Activation.empty).getOrThrow() ``` The series of steps must be executed to produce the object graph. diff --git a/project/plugins.sbt b/project/plugins.sbt index 3a02af7b95..a23d56b833 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,17 +1,6 @@ // DO NOT EDIT THIS FILE // IT IS AUTOGENERATED BY `sbtgen.sc` SCRIPT // ALL CHANGES WILL BE LOST -// https://www.scala-js.org/ -addSbtPlugin("org.scala-js" % "sbt-scalajs" % PV.scala_js_version) - -// https://github.com/portable-scala/sbt-crossproject -addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.3.2") - -// https://scalacenter.github.io/scalajs-bundler/ -addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.21.1") - -// https://github.com/scala-js/jsdependencies -addSbtPlugin("org.scala-js" % "sbt-jsdependencies" % "1.0.2") ////////////////////////////////////////////////////////////////////////////////