@@ -7,7 +7,7 @@ ThisBuild / commands ++= createBuildCommands(allModules)
7
7
ThisBuild / scalafixDependencies += " com.github.liancheng" %% " organize-imports" % " 0.5.0"
8
8
ThisBuild / dynverSeparator := " -"
9
9
ThisBuild / versionScheme := Some (" early-semver" )
10
- ThisBuild / mimaBaseVersion := " 0.16"
10
+ ThisBuild / mimaBaseVersion := " 0.16.1 "
11
11
ThisBuild / testFrameworks += new TestFramework (" weaver.framework.CatsEffect" )
12
12
import Smithy4sPlugin ._
13
13
@@ -27,7 +27,7 @@ Global / licenses := Seq(
27
27
sonatypeCredentialHost := " s01.oss.sonatype.org"
28
28
29
29
ThisBuild / version := {
30
- if (! sys.env.contains(" CI" )) " dev"
30
+ if (! sys.env.contains(" CI" )) " dev-SNAPSHOT "
31
31
else (ThisBuild / version).value
32
32
}
33
33
@@ -46,6 +46,7 @@ lazy val root = project
46
46
lazy val allModules = Seq (
47
47
core.projectRefs,
48
48
codegen.projectRefs,
49
+ millCodegenPlugin.projectRefs,
49
50
json.projectRefs,
50
51
example.projectRefs,
51
52
tests.projectRefs,
@@ -74,6 +75,7 @@ lazy val docs =
74
75
`codegen-cli`,
75
76
http4s,
76
77
`http4s-swagger`,
78
+ decline,
77
79
`aws-http4s` % " compile -> compile,test"
78
80
)
79
81
.settings(
@@ -92,7 +94,8 @@ lazy val docs =
92
94
isCE3 := true ,
93
95
libraryDependencies ++= Seq (
94
96
Dependencies .Http4s .emberClient.value,
95
- Dependencies .Http4s .emberServer.value
97
+ Dependencies .Http4s .emberServer.value,
98
+ Dependencies .Decline .effect.value
96
99
),
97
100
Compile / sourceGenerators := Seq (genSmithyScala(Compile ).taskValue),
98
101
Compile / smithySpecs := Seq (
@@ -383,13 +386,58 @@ lazy val codegenPlugin = (projectMatrix in file("modules/codegen-plugin"))
383
386
scriptedBufferLog := false
384
387
)
385
388
389
+ /**
390
+ * Mill plugin to run codegen
391
+ */
392
+ lazy val millCodegenPlugin = projectMatrix
393
+ .in(file(" modules/mill-codegen-plugin" ))
394
+ .enablePlugins(BuildInfoPlugin )
395
+ .jvmPlatform(
396
+ scalaVersions = List (Scala213 ),
397
+ simpleJVMLayout
398
+ )
399
+ .settings(
400
+ name := " mill-codegen-plugin" ,
401
+ crossVersion := CrossVersion
402
+ .binaryWith(s " mill ${millPlatform(Dependencies .Mill .millVersion)}_ " , " " ),
403
+ buildInfoKeys := Seq [BuildInfoKey ](version),
404
+ buildInfoPackage := " smithy4s.codegen.mill" ,
405
+ libraryDependencies ++= Seq (
406
+ Dependencies .Mill .main,
407
+ Dependencies .Mill .mainApi,
408
+ Dependencies .Mill .scalalib,
409
+ Dependencies .Mill .mainTestkit
410
+ ),
411
+ publishLocal := {
412
+ // make sure that core and codegen are published before the
413
+ // plugin is published
414
+ // this allows running `scripted` alone
415
+ val _ = List (
416
+ // for the code being built
417
+ (core.jvm(Scala213 ) / publishLocal).value,
418
+ (dynamic.jvm(Scala213 ) / publishLocal).value,
419
+ (codegen.jvm(Scala213 ) / publishLocal).value,
420
+ // dependency of codegen
421
+ (openapi.jvm(Scala213 ) / publishLocal).value,
422
+
423
+ // for mill
424
+ (protocol.jvm(autoScalaLibrary = false ) / publishLocal).value
425
+ )
426
+ publishLocal.value
427
+ },
428
+ Test / test := (Test / test).dependsOn(publishLocal).value,
429
+ libraryDependencies ++= munitDeps.value
430
+ )
431
+ .dependsOn(codegen)
432
+
386
433
lazy val decline = (projectMatrix in file(" modules/decline" ))
387
434
.settings(
388
435
name := " decline" ,
389
436
isCE3 := true ,
390
437
libraryDependencies ++= List (
391
438
Dependencies .Cats .core.value,
392
- Dependencies .Decline .effect.value,
439
+ Dependencies .CatsEffect3 .value,
440
+ Dependencies .Decline .core.value,
393
441
Dependencies .Weaver .cats.value % Test
394
442
)
395
443
)
@@ -665,7 +713,8 @@ lazy val example = projectMatrix
665
713
genSmithyResources(Compile ).taskValue
666
714
),
667
715
genSmithyOutput := ((ThisBuild / baseDirectory).value / " modules" / " example" / " src" ),
668
- genSmithyOpenapiOutput := (Compile / resourceDirectory).value
716
+ genSmithyResourcesOutput := (Compile / resourceDirectory).value,
717
+ smithy4sSkip := List (" resource" )
669
718
)
670
719
.jvmPlatform(List (Scala213 ), jvmDimSettings)
671
720
.settings(Smithy4sPlugin .doNotPublishArtifact)
@@ -723,14 +772,23 @@ lazy val Dependencies = new {
723
772
}
724
773
725
774
object Decline {
726
- val core = Def .setting(" com.monovore" %%% " decline-effect " % " 2.3.0" )
775
+ val core = Def .setting(" com.monovore" %%% " decline" % " 2.3.0" )
727
776
val effect = Def .setting(" com.monovore" %%% " decline-effect" % " 2.3.0" )
728
777
}
729
778
object Fs2 {
730
779
val core : Def .Initialize [ModuleID ] =
731
780
Def .setting(" co.fs2" %%% " fs2-core" % " 3.2.14" )
732
781
}
733
782
783
+ object Mill {
784
+ val millVersion = " 0.10.7"
785
+
786
+ val scalalib = " com.lihaoyi" %% " mill-scalalib" % millVersion
787
+ val main = " com.lihaoyi" %% " mill-main" % millVersion
788
+ val mainApi = " com.lihaoyi" %% " mill-main-api" % millVersion
789
+ val mainTestkit = " com.lihaoyi" %% " mill-main-testkit" % millVersion % Test
790
+ }
791
+
734
792
val Circe = new {
735
793
val generic : Def .Initialize [ModuleID ] =
736
794
Def .setting(" io.circe" %%% " circe-generic" % " 0.14.2" )
@@ -803,11 +861,12 @@ lazy val Dependencies = new {
803
861
804
862
lazy val smithySpecs = SettingKey [Seq [File ]](" smithySpecs" )
805
863
lazy val genSmithyOutput = SettingKey [File ](" genSmithyOutput" )
806
- lazy val genSmithyOpenapiOutput = SettingKey [File ](" genSmithyOpenapiOutput " )
864
+ lazy val genSmithyResourcesOutput = SettingKey [File ](" genSmithyResourcesOutput " )
807
865
lazy val allowedNamespaces = SettingKey [Seq [String ]](" allowedNamespaces" )
808
866
lazy val genSmithyDependencies =
809
867
SettingKey [Seq [String ]](" genSmithyDependencies" )
810
868
lazy val genDiscoverModels = SettingKey [Boolean ](" genDiscoverModels" )
869
+ lazy val smithy4sSkip = SettingKey [Seq [String ]](" smithy4sSkip" )
811
870
812
871
(ThisBuild / smithySpecs) := Seq .empty
813
872
@@ -823,15 +882,16 @@ def genSmithyImpl(config: Configuration) = Def.task {
823
882
val outputDir = (config / genSmithyOutput).? .value
824
883
.getOrElse((config / sourceManaged).value)
825
884
.getAbsolutePath()
826
- val openapiOutputDir =
827
- (config / genSmithyOpenapiOutput ).? .value
885
+ val resourceOutputDir =
886
+ (config / genSmithyResourcesOutput ).? .value
828
887
.getOrElse((config / resourceManaged).value)
829
888
.getAbsolutePath()
830
889
val allowedNS = (config / allowedNamespaces).? .value.filterNot(_.isEmpty)
831
890
val smithyDeps =
832
891
(config / genSmithyDependencies).? .value.getOrElse(List .empty)
833
892
val discoverModels =
834
893
(config / genDiscoverModels).? .value.getOrElse(false )
894
+ val skip = (config / smithy4sSkip).? .value.getOrElse(Seq .empty)
835
895
836
896
val codegenCp =
837
897
(`codegen-cli`.jvm(Smithy4sPlugin .Scala213 ) / Compile / fullClasspath).value
@@ -855,11 +915,13 @@ def genSmithyImpl(config: Configuration) = Def.task {
855
915
val inputs = inputFiles.map(_.getAbsolutePath()).toList
856
916
val args =
857
917
List (" --output" , outputDir) ++
858
- List (" --openapi -output" , openapiOutputDir ) ++
918
+ List (" --resource -output" , resourceOutputDir ) ++
859
919
(if (discoverModels) List (" --discover-models" ) else Nil ) ++
860
920
(if (allowedNS.isDefined)
861
921
List (" --allowed-ns" , allowedNS.get.mkString(" ," ))
862
- else Nil ) ++ inputs
922
+ else Nil ) ++
923
+ inputs ++
924
+ skip.flatMap(s => List (" --skip" , s))
863
925
864
926
val cp = codegenCp
865
927
.map(_.getAbsolutePath())
0 commit comments