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

smithy4s-protocol not being written to smithy4sUpdateLSPConfig #1517

Closed
kubukoz opened this issue May 13, 2024 · 5 comments
Closed

smithy4s-protocol not being written to smithy4sUpdateLSPConfig #1517

kubukoz opened this issue May 13, 2024 · 5 comments
Labels
good first issue Good for newcomers

Comments

@kubukoz
Copy link
Member

kubukoz commented May 13, 2024

With a standard smithy4s setup, the smithy-build.json file looks like this:

{
    "version" : "1.0",
    "imports" : [
        "src/main/smithy",
        "target/scala-3.3.3/src_managed/main/smithy"
    ],
    "maven" : {
        "dependencies" : [
            "com.disneystreaming.alloy:alloy-core:0.3.6"
        ],
        "repositories" : [
        ]
    }
}

There's #1459, of course, but another problem is that maven.dependencies doesn't contain the artifact with traits form smithy4s.meta - namely com.disneystreaming.smithy4s:smithy4s-protocol.

I'm not sure if Alloy is special-cased in any way here, but if so, we should also special-case smithy4s-protocol. If it's not special-cased, something may be wrong in how we collect dependencies.

@kubukoz
Copy link
Member Author

kubukoz commented May 13, 2024

@daddykotex off the top of your head, do you have any hunch on why alloy is being written but smithy4s-protocol isn't?

@kubukoz
Copy link
Member Author

kubukoz commented May 13, 2024

looks like alloy-core is a libraryDependencies entry (% Smithy4s-scoped), but smithy4s-protocol isn't.

smithy4s-protocol is a dependency of the codegen / build plugin itself, being added to the model in ModelLoader via an explicit mention of the smithy4s.meta.smithy file:

val smithy4sResources = List(
"META-INF/smithy/smithy4s.meta.smithy"
).map(classLoader.getResource)
if (discoverModels) {
assembler.discoverModels(classLoader)
} else addImports(smithy4sResources)

unless we want to change how all that works, it'd probably be the easiest if we hardcode the protocol dependency in the smithy-build writing code

@daddykotex
Copy link
Contributor

yes, I'm guessing it happens like that because the dependency comes in via dependsOn in the sbt project structure?

really not sure about that, and I can't remember more

@kubukoz
Copy link
Member Author

kubukoz commented May 23, 2024

I think we're gonna just want to hardcode the addition of this module (com.disneystreaming.smithy4s:smithy4s-protocol) in the LSP config codegen:

for starters, we could go with

SmithyBuild.Serializable(
version = "1.0",
sources,
SmithyBuildMaven(
dependencies,
repositories.map(SmithyBuildMavenRepository.apply)
)
)
, but maybe there's a better place.

@kubukoz kubukoz added the good first issue Good for newcomers label May 23, 2024
@kubukoz
Copy link
Member Author

kubukoz commented Oct 2, 2024

Tests for this can be added in: https://github.com/disneystreaming/smithy4s/blob/89e88c972174fa0a3b2853901a52a5a6a4662c6d/modules/codegen/test/src/smithy4s/codegen/internals/SmithyBuildSpec.scala

The expectation is that you'll always have a Maven dependency written for com.disneystreaming.smithy4s:smithy4s-protocol:${BuildInfo.version} (where BuildInfo is smithy4s.codegen.BuildInfo).

As for manual testing, I suggest:

  1. sbt publishLocal_2_12_jvm
  2. setting up a sample smithy4s project with Scala 2.12
  3. running smithy4sUpdateLSPConfig
  4. Looking at the generated smithy-build.json in the project.

dwalend added a commit to dwalend/smithy4s that referenced this issue Oct 10, 2024
dwalend added a commit to dwalend/smithy4s that referenced this issue Oct 10, 2024
dwalend added a commit to dwalend/smithy4s that referenced this issue Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants