Skip to content

Commit cb4e88c

Browse files
committed
Address comments
1 parent 6cb9854 commit cb4e88c

1 file changed

Lines changed: 26 additions & 15 deletions

File tree

smithy-trait-codegen/README.md

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
# Smithy Trait CodeGen
22

3-
Smithy build plugin that generates Java trait classes from customized Smithy trait defined with [`@trait`](https://smithy.io/2.0/spec/model.html#trait-trait).
3+
This package contains a Smithy build plugin that generates Java trait classes from customized Smithy traits defined with [`@trait`](https://smithy.io/2.0/spec/model.html#trait-trait).
44

55
## Supported Trait Types
6-
- [**Simple Types**](https://smithy.io/2.0/spec/simple-types.html) (Excluding `Blob` and `Boolean`)
7-
- **Structure**
6+
7+
- [**Simple Types**](https://smithy.io/2.0/spec/simple-types.html), excluding `Blob` and `Boolean`
8+
- **Structure**, including [annotation traits](https://smithy.io/2.0/spec/model.html#annotation-traits)
89
- **List**
910
- **Set**
1011
- **Map**
1112

1213
> [!NOTE]
13-
> [Annotation Trait](https://smithy.io/2.0/spec/model.html#annotation-traits) is recommended rather than Boolean trait
14+
> [Annotation traits](https://smithy.io/2.0/spec/model.html#annotation-traits) are recommended instead of Boolean traits.
1415
1516
## Supported Smithy Prelude Traits
17+
1618
- [@required](https://smithy.io/2.0/spec/type-refinement-traits.html#required-trait)
1719
- [@enumValue](https://smithy.io/2.0/spec/type-refinement-traits.html#enumvalue-trait)
1820
- [@mixin](https://smithy.io/2.0/spec/type-refinement-traits.html#mixin-trait)
@@ -51,7 +53,9 @@ An example for `smithy-build.json`:
5153
```
5254

5355
## Getting Started
56+
5457
### Configure `smithy-build.json`
58+
5559
To generate Java code for your customized traits, you will add the `trait-codegen` plugin to the
5660
[plugin configuration](https://smithy.io/2.0/guides/smithy-build-json.html) in `smithy-build.json`:
5761

@@ -67,11 +71,13 @@ To generate Java code for your customized traits, you will add the `trait-codege
6771
}
6872
}
6973
```
74+
7075
### Add dependency
7176

7277
#### **Using Smithy CLI**
7378

74-
If you are using Smithy CLI, you will add dependency in `smithy-build.json`:
79+
If you are using the Smithy CLI, declare a dependency in `smithy-build.json`:
80+
7581
```json
7682
{
7783
"version": "1.0",
@@ -84,9 +90,13 @@ If you are using Smithy CLI, you will add dependency in `smithy-build.json`:
8490
"...": "..."
8591
}
8692
```
87-
Then you can run `smithy build` to build the model and generate Java code for your customized traits.
93+
94+
Then, running `smithy build` will build the model and generate Java code for your customized traits.
95+
8896
#### **Using Gradle**
89-
If you are using Gradle, you will add dependency `id("software.amazon.smithy.gradle.smithy-trait-package").version("1.3.0")` to the `plugin` section in `build.gradle.kts`:
97+
98+
If you are using Gradle, declare a dependency in the `plugin` section in `build.gradle.kts`:
99+
90100
```kotlin
91101
plugins {
92102
id("software.amazon.smithy.gradle.smithy-trait-package").version("1.3.0")
@@ -102,12 +112,15 @@ repositories {
102112
mavenCentral()
103113
}
104114
```
105-
Then you can run `gradle build` to build the model and generate Java code for your customized traits.
115+
116+
Then, running `gradle build` will build the model and generate Java code for your customized traits.
106117

107118
### Check the Generated Code
108-
Finally you can find the the generated Java classes under `/build/smithyprojections/trait-codegen/`
109119

110-
The generated Java class for `annotationTrait` from `custom-trait` template would be:
120+
Finally, you can find the generated Java classes under `/build/smithyprojections/trait-codegen/`
121+
122+
The generated Java class for `annotationTrait` from `custom-trait` [template](https://github.com/smithy-lang/smithy-examples/tree/main/custom-trait-examples/custom-trait) would be:
123+
111124
```java
112125
@SmithyGenerated
113126
public final class AnnotationTrait extends AbstractTrait implements ToSmithyBuilder<AnnotationTrait> {
@@ -135,7 +148,9 @@ public final class AnnotationTrait extends AbstractTrait implements ToSmithyBuil
135148
// Service Provider Implementation
136149
}
137150
```
138-
The generated Java class for `JsonNameTrait` from `custom-trait` template would be:
151+
152+
The generated Java class for `JsonNameTrait` from `custom-trait` [template](https://github.com/smithy-lang/smithy-examples/tree/main/custom-trait-examples/custom-trait) would be:
153+
139154
```java
140155
@SmithyGenerated
141156
public final class JsonNameTrait extends StringTrait {
@@ -154,7 +169,3 @@ public final class JsonNameTrait extends StringTrait {
154169
// Service Provider Implementation
155170
}
156171
```
157-
158-
## License
159-
160-
Licensed under the Apache 2.0 License.

0 commit comments

Comments
 (0)