disneystreaming / smithy4s

https://disneystreaming.github.io/smithy4s/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

smithy4s-protocol not being written to smithy4sUpdateLSPConfig

kubukoz opened this issue · comments

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.

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

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

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

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.