Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a failing sbt scripted test to demonstrate #1589 #1590

Draft
wants to merge 3 commits into
base: series/0.18
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
lazy val root = (project in file("."))
.enablePlugins(Smithy4sCodegenPlugin)
.settings(
crossScalaVersions := Seq("2.13.15", "3.3.3"),
libraryDependencies ++= Seq(
"com.disneystreaming.smithy4s" %% "smithy4s-core" % smithy4sVersion.value
)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sbt.version=1.8.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
sys.props.get("plugin.version") match {
case Some(x) =>
addSbtPlugin("com.disneystreaming.smithy4s" % "smithy4s-sbt-codegen" % x)
case _ =>
sys.error(
"""|The system property 'plugin.version' is not defined.
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
namespace smithy4s.example

structure Simple {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# generate for Scala 2.13
> ++ 2.13
> compile

$ exists target/scala-2.13/src_managed/main/smithy/generated-metadata.smithy
$ exists target/scala-2.13/src_managed/main/smithy4s/smithy4s/example/Simple.scala

> ++ 3
> compile

$ exists target/scala-3.3.3/src_managed/main/smithy/generated-metadata.smithy
$ exists target/scala-3.3.3/src_managed/main/smithy4s/smithy4s/example/Simple.scala

# switch back to Scala 2.13 and compile again; codegen should not happen a second time
> ++ 2.13
> compile

$ newer target/scala-3.3.3/src_managed/main/smithy/generated-metadata.smithy target/scala-2.13/src_managed/main/smithy/generated-metadata.smithy
$ newer target/scala-3.3.3/src_managed/main/smithy4s/smithy4s/example/Simple.scala target/scala-2.13/src_managed/main/smithy4s/smithy4s/example/Simple.scala
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ object Smithy4sCodegenPlugin extends AutoPlugin {
(config / sourceManaged).value / "smithy" / "generated-metadata.smithy"
},
config / smithy4sGeneratedSmithyFiles := {
val cacheFactory = (config / streams).value.cacheStoreFactory
val cacheFactory =
(config / streams).value.cacheStoreFactory.sub(scalaVersion.value)
val cached = Tracked.inputChanged[(String, Boolean), Seq[File]](
cacheFactory.make("smithy4sGeneratedSmithyFilesInput")
) { case (changed, (wildcardArg, shouldGenerateOptics)) =>
Expand Down Expand Up @@ -454,14 +455,15 @@ object Smithy4sCodegenPlugin extends AutoPlugin {
smithyBuild = smithyBuildValue
)

val cacheStoreFactory = s.cacheStoreFactory.sub(scalaVersion.value)
val cached =
CachedTask.inputChanged[CodegenArgs, Seq[File]](
s.cacheStoreFactory.make("input"),
cacheStoreFactory.make("input"),
s.log
) {
Function.untupled {
Tracked.lastOutput[(Boolean, CodegenArgs), Seq[File]](
s.cacheStoreFactory.make("output")
cacheStoreFactory.make("output")
) { case ((inputChanged, args), outputs) =>
if (inputChanged || outputs.isEmpty) {
s.log.debug(s"[smithy4s] Input changed: $inputChanged")
Expand Down