Skip to content

Commit

Permalink
Protocol in update lsp config (#1610)
Browse files Browse the repository at this point in the history
* Plan for fixing #1517

* Fix for #1517 - smithy4s-protocol always included.

* Fixed #1517 mill build test check the new dependency.

* scalafmt

* Updated CHANGELOG.md

* Fixed the scripted test

* Update CHANGELOG.md

Co-authored-by: Jakub Kozłowski <[email protected]>

* Moved smithy4s org and protocol artifact name to build.sbt

* Stray comment

* Change log typo

* Test cleanup

* Update CHANGELOG.md

* Update CHANGELOG.md

* Use the organization value from sbt's publishSettings .

---------

Co-authored-by: Jakub Kozłowski <[email protected]>
  • Loading branch information
dwalend and kubukoz authored Oct 25, 2024
1 parent ae8ce3d commit 07efa38
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Thank you!

* Optimises the conversion of empty smithy4s.Blob to fs2.Stream, to avoid performance degradation in Ember (see [#1609](https://github.com/disneystreaming/smithy4s/pull/1609))
* Adds utility types for working with endpoint handlers (see [#1612](https://github.com/disneystreaming/smithy4s/pull/1612))
* Adds `com.disneystreaming.smithy4s:smithy4s-protocol` dependency to the generation of `smithy-build.json` in the `smithy4sUpdateLSPConfig` tasks of the codegen plugins (see [#1610](https://github.com/disneystreaming/smithy4s/pull/1610)).

# 0.18.25

Expand Down
4 changes: 3 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,9 @@ lazy val codegen = projectMatrix
"smithyOrg" -> Dependencies.Smithy.org,
"smithyVersion" -> Dependencies.Smithy.smithyVersion,
"alloyOrg" -> Dependencies.Alloy.org,
"alloyVersion" -> Dependencies.Alloy.alloyVersion
"alloyVersion" -> Dependencies.Alloy.alloyVersion,
"smithy4sOrg" -> organization.value,
"protocolArtifactName" -> "smithy4s-protocol",
),
buildInfoPackage := "smithy4s.codegen",
libraryDependencies ++= Seq(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ val root = project
.aggregate(subproj, subproj2)
.settings(
TaskKey[Unit]("checkSmithyBuild") := {
val generated = IO.readLines(file(".") / "smithy-build.json")
val expected = IO.readLines(file(".") / "expected.json")
val generated = IO.readLines(file(".") / "smithy-build.json").mkString("\n")
val expected = IO.readLines(file(".") / "expected.json").mkString("\n").replace("${SMITHY4S_VERSION}", smithy4sVersion.value)
val compare = s"""|generated:
|${generated.mkString("\n")}
|$generated
|===================================
|expected:
|${expected.mkString("\n")}
|$expected
|===================================
|""".stripMargin

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
],
"maven" : {
"dependencies" : [
"com.disneystreaming.alloy:alloy-core:0.3.13"
"com.disneystreaming.alloy:alloy-core:0.3.13",
"com.disneystreaming.smithy4s:smithy4s-protocol:${SMITHY4S_VERSION}"
],
"repositories" : [
{
Expand Down
6 changes: 5 additions & 1 deletion modules/codegen/src/smithy4s/codegen/SmithyBuildJson.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ import smithy4s.codegen.internals.SmithyBuildMavenRepository
import scala.collection.immutable.ListSet

private[codegen] object SmithyBuildJson {

val protocolDependency =
s"${BuildInfo.smithy4sOrg}:${BuildInfo.protocolArtifactName}:${BuildInfo.version}"

def toJson(
sources: ListSet[String],
dependencies: ListSet[String],
Expand All @@ -35,7 +39,7 @@ private[codegen] object SmithyBuildJson {
version = "1.0",
sources,
SmithyBuildMaven(
dependencies,
dependencies + protocolDependency,
repositories.map(SmithyBuildMavenRepository.apply)
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@

package smithy4s.codegen.internals

import smithy4s.codegen.SmithyBuildJson
import smithy4s.codegen.{SmithyBuildJson, BuildInfo}
import software.amazon.smithy.model.shapes.ShapeId
import software.amazon.smithy.openapi.OpenApiVersion

import scala.collection.immutable.ListSet

final class SmithyBuildSpec extends munit.FunSuite {
test("generate json") {
test("generate json with SmithyBuild.writeJson") {
val actual = SmithyBuild.writeJson(
SmithyBuild.Serializable(
"1.0",
Expand Down Expand Up @@ -201,4 +201,32 @@ final class SmithyBuildSpec extends munit.FunSuite {
assertEquals(Set.empty[os.FilePath], actual.sources.toSet)
assertEquals(Set.empty[SmithyBuildPlugin], actual.plugins.toSet)
}

test("generate json with SmithyBuildJson.toJson") {
val actual = SmithyBuildJson.toJson(
ListSet("src/"),
ListSet("dep"),
ListSet("repo")
)
assertEquals(
actual,
s"""|{
| "version" : "1.0",
| "sources" : [
| "src/"
| ],
| "maven" : {
| "dependencies" : [
| "dep",
| "com.disneystreaming.smithy4s:smithy4s-protocol:${BuildInfo.version}"
| ],
| "repositories" : [
| {
| "url" : "repo"
| }
| ]
| }
|}""".stripMargin
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ class SmithyLSPConfigSpec extends munit.FunSuite {
| "maven": {
| "dependencies": [
| "com.disneystreaming.alloy:alloy-core:${smithy4s.codegen.BuildInfo.alloyVersion}",
| "software.amazon.smithy:smithy-aws-iam-traits:${smithy4s.codegen.BuildInfo.smithyVersion}"
| "software.amazon.smithy:smithy-aws-iam-traits:${smithy4s.codegen.BuildInfo.smithyVersion}",
| "com.disneystreaming.smithy4s:smithy4s-protocol:${smithy4s.codegen.BuildInfo.version}"
| ],
| "repositories": [
| { "url": "https://some.corpo.example.com/artifactory" }
Expand Down

0 comments on commit 07efa38

Please sign in to comment.