smithy4s icon indicating copy to clipboard operation
smithy4s copied to clipboard

Use smithy-trait-codegen for Java Trait representations

Open kubukoz opened this issue 1 year ago • 3 comments

https://github.com/smithy-lang/smithy/blob/1805e515bc3877a02aa8351da1a7ea62e92a2c8f/smithy-trait-codegen/src/main/java/software/amazon/smithy/traitcodegen/TraitCodegen.java

Doing this is likely to cause bincompat breakage in the protocol module, but it'll save us some boilerplate.

Should probably be attempted in Alloy first.

kubukoz avatar May 23 '24 21:05 kubukoz

The protocol module should not be considered "library code", so bin breakage is okay.

Assuming we went ahead, what would the set-up even look like ?

Baccata avatar May 24 '24 08:05 Baccata

The trait codegen can be set up as a source generator in the build tool. The trait classes are generated with builders and getters, and your validators / services can use those. I can't exactly share a snippet but we've done this at work so it's doable

kubukoz avatar May 24 '24 10:05 kubukoz

I'm adding an initial setup for new traits in #1737, but doing this on a larger scale will require a few more changes.

And I don't agree that bin breakage is okay here.

kubukoz avatar Jun 20 '25 15:06 kubukoz