Skip to content

Commit f0ecffb

Browse files
authoredSep 16, 2022
Merge pull request #457 from disneystreaming/0.16.0
0.16.0 feature branch
2 parents 11a764d + bb0d73c commit f0ecffb

File tree

59 files changed

+1473
-536
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1473
-536
lines changed
 

‎build.sbt

+73-11
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ThisBuild / commands ++= createBuildCommands(allModules)
77
ThisBuild / scalafixDependencies += "com.github.liancheng" %% "organize-imports" % "0.5.0"
88
ThisBuild / dynverSeparator := "-"
99
ThisBuild / versionScheme := Some("early-semver")
10-
ThisBuild / mimaBaseVersion := "0.16"
10+
ThisBuild / mimaBaseVersion := "0.16.1"
1111
ThisBuild / testFrameworks += new TestFramework("weaver.framework.CatsEffect")
1212
import Smithy4sPlugin._
1313

@@ -27,7 +27,7 @@ Global / licenses := Seq(
2727
sonatypeCredentialHost := "s01.oss.sonatype.org"
2828

2929
ThisBuild / version := {
30-
if (!sys.env.contains("CI")) "dev"
30+
if (!sys.env.contains("CI")) "dev-SNAPSHOT"
3131
else (ThisBuild / version).value
3232
}
3333

@@ -46,6 +46,7 @@ lazy val root = project
4646
lazy val allModules = Seq(
4747
core.projectRefs,
4848
codegen.projectRefs,
49+
millCodegenPlugin.projectRefs,
4950
json.projectRefs,
5051
example.projectRefs,
5152
tests.projectRefs,
@@ -74,6 +75,7 @@ lazy val docs =
7475
`codegen-cli`,
7576
http4s,
7677
`http4s-swagger`,
78+
decline,
7779
`aws-http4s` % "compile -> compile,test"
7880
)
7981
.settings(
@@ -92,7 +94,8 @@ lazy val docs =
9294
isCE3 := true,
9395
libraryDependencies ++= Seq(
9496
Dependencies.Http4s.emberClient.value,
95-
Dependencies.Http4s.emberServer.value
97+
Dependencies.Http4s.emberServer.value,
98+
Dependencies.Decline.effect.value
9699
),
97100
Compile / sourceGenerators := Seq(genSmithyScala(Compile).taskValue),
98101
Compile / smithySpecs := Seq(
@@ -383,13 +386,58 @@ lazy val codegenPlugin = (projectMatrix in file("modules/codegen-plugin"))
383386
scriptedBufferLog := false
384387
)
385388

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+
386433
lazy val decline = (projectMatrix in file("modules/decline"))
387434
.settings(
388435
name := "decline",
389436
isCE3 := true,
390437
libraryDependencies ++= List(
391438
Dependencies.Cats.core.value,
392-
Dependencies.Decline.effect.value,
439+
Dependencies.CatsEffect3.value,
440+
Dependencies.Decline.core.value,
393441
Dependencies.Weaver.cats.value % Test
394442
)
395443
)
@@ -665,7 +713,8 @@ lazy val example = projectMatrix
665713
genSmithyResources(Compile).taskValue
666714
),
667715
genSmithyOutput := ((ThisBuild / baseDirectory).value / "modules" / "example" / "src"),
668-
genSmithyOpenapiOutput := (Compile / resourceDirectory).value
716+
genSmithyResourcesOutput := (Compile / resourceDirectory).value,
717+
smithy4sSkip := List("resource")
669718
)
670719
.jvmPlatform(List(Scala213), jvmDimSettings)
671720
.settings(Smithy4sPlugin.doNotPublishArtifact)
@@ -723,14 +772,23 @@ lazy val Dependencies = new {
723772
}
724773

725774
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")
727776
val effect = Def.setting("com.monovore" %%% "decline-effect" % "2.3.0")
728777
}
729778
object Fs2 {
730779
val core: Def.Initialize[ModuleID] =
731780
Def.setting("co.fs2" %%% "fs2-core" % "3.2.14")
732781
}
733782

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+
734792
val Circe = new {
735793
val generic: Def.Initialize[ModuleID] =
736794
Def.setting("io.circe" %%% "circe-generic" % "0.14.2")
@@ -803,11 +861,12 @@ lazy val Dependencies = new {
803861

804862
lazy val smithySpecs = SettingKey[Seq[File]]("smithySpecs")
805863
lazy val genSmithyOutput = SettingKey[File]("genSmithyOutput")
806-
lazy val genSmithyOpenapiOutput = SettingKey[File]("genSmithyOpenapiOutput")
864+
lazy val genSmithyResourcesOutput = SettingKey[File]("genSmithyResourcesOutput")
807865
lazy val allowedNamespaces = SettingKey[Seq[String]]("allowedNamespaces")
808866
lazy val genSmithyDependencies =
809867
SettingKey[Seq[String]]("genSmithyDependencies")
810868
lazy val genDiscoverModels = SettingKey[Boolean]("genDiscoverModels")
869+
lazy val smithy4sSkip = SettingKey[Seq[String]]("smithy4sSkip")
811870

812871
(ThisBuild / smithySpecs) := Seq.empty
813872

@@ -823,15 +882,16 @@ def genSmithyImpl(config: Configuration) = Def.task {
823882
val outputDir = (config / genSmithyOutput).?.value
824883
.getOrElse((config / sourceManaged).value)
825884
.getAbsolutePath()
826-
val openapiOutputDir =
827-
(config / genSmithyOpenapiOutput).?.value
885+
val resourceOutputDir =
886+
(config / genSmithyResourcesOutput).?.value
828887
.getOrElse((config / resourceManaged).value)
829888
.getAbsolutePath()
830889
val allowedNS = (config / allowedNamespaces).?.value.filterNot(_.isEmpty)
831890
val smithyDeps =
832891
(config / genSmithyDependencies).?.value.getOrElse(List.empty)
833892
val discoverModels =
834893
(config / genDiscoverModels).?.value.getOrElse(false)
894+
val skip = (config / smithy4sSkip).?.value.getOrElse(Seq.empty)
835895

836896
val codegenCp =
837897
(`codegen-cli`.jvm(Smithy4sPlugin.Scala213) / Compile / fullClasspath).value
@@ -855,11 +915,13 @@ def genSmithyImpl(config: Configuration) = Def.task {
855915
val inputs = inputFiles.map(_.getAbsolutePath()).toList
856916
val args =
857917
List("--output", outputDir) ++
858-
List("--openapi-output", openapiOutputDir) ++
918+
List("--resource-output", resourceOutputDir) ++
859919
(if (discoverModels) List("--discover-models") else Nil) ++
860920
(if (allowedNS.isDefined)
861921
List("--allowed-ns", allowedNS.get.mkString(","))
862-
else Nil) ++ inputs
922+
else Nil) ++
923+
inputs ++
924+
skip.flatMap(s => List("--skip", s))
863925

864926
val cp = codegenCp
865927
.map(_.getAbsolutePath())

‎flake.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
shellPackages = [
1010
"jre"
1111
"sbt"
12-
"nodejs"
12+
"nodejs-16_x"
1313
"yarn"
1414
];
1515
in

0 commit comments

Comments
 (0)
Please sign in to comment.