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

Protocol in update lsp config #1610

Merged
merged 17 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from 12 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Thank you!
* Fixes an issue in which union members targetting Unit would fail to compile when used as traits (see [#1600](https://github.com/disneystreaming/smithy4s/pull/1600)).
* Make the `transform` method in generated `*Gen` algebras final. This should make it possible to derive e.g. `FunctorK` instances in cats-tagless automatically (see [#1588](https://github.com/disneystreaming/smithy4s/pull/1588)).
* Fixes commons.toKebabCase() sometimes drops the first letter (see [#1603](https://github.com/disneystreaming/smithy4s/pull/1603)).
* 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.24

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" -> "com.disneystreaming.smithy4s",
kubukoz marked this conversation as resolved.
Show resolved Hide resolved
"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(
kubukoz marked this conversation as resolved.
Show resolved Hide resolved
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