You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: smithy-trait-codegen/README.md
+47-28Lines changed: 47 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,7 @@ Smithy build plugin that generates Java trait classes from customized Smithy tra
25
25
26
26
## Configuration
27
27
28
-
The generator supports the following configuration options:
28
+
The generator supports the following configuration options:
29
29
30
30
| Option | Description | Required |
31
31
|--------|-------------|----------|
@@ -38,26 +38,55 @@ An example for `smithy-build.json`:
38
38
39
39
```json
40
40
{
41
-
"version": "1.0",
42
-
"plugins": {
43
-
"trait-codegen": {
44
-
"package": "com.example.traits",
45
-
"namespace": "com.example.traits",
46
-
"header": ["Copyright Example Corp"],
47
-
"excludeTags": ["internal"]
48
-
}
41
+
"version": "1.0",
42
+
"plugins": {
43
+
"trait-codegen": {
44
+
"package": "com.example.traits",
45
+
"namespace": "com.example.traits",
46
+
"header": ["Copyright Example Corp"],
47
+
"excludeTags": ["internal"]
49
48
}
49
+
}
50
50
}
51
51
```
52
52
53
53
## Getting Started
54
+
### Configure `smithy-build.json`
55
+
To generate Java code for your customized traits, you will add the `trait-codegen` plugin to the
56
+
[plugin configuration](https://smithy.io/2.0/guides/smithy-build-json.html) in `smithy-build.json`:
54
57
55
-
First, create a gradle-based Smithy model project. You can also use Smithy CLI to generate a [complete custom trait example](https://github.com/smithy-lang/smithy-examples/tree/main/custom-trait-examples/custom-trait): `smithy init -o custom-trait -t custom-trait`.
58
+
```json
59
+
{
60
+
"version": "1.0",
61
+
"sources": ["model"],
62
+
"plugins": {
63
+
"trait-codegen": {
64
+
"package": "io.examples.traits",
65
+
"namespace": "example.traits"
66
+
}
67
+
}
68
+
}
69
+
```
70
+
### Add dependency
56
71
57
-
> [!NOTE]
58
-
> The generator currently cannot be run with non-gradle-based projects.
72
+
#### **Using Smithy CLI**
59
73
60
-
In `build.gradle.kts`, add `id("software.amazon.smithy.gradle.smithy-trait-package").version("1.3.0")` to the `plugin` section.
74
+
If you are using Smithy CLI, you will add dependency in `smithy-build.json`:
Then you can run `smithy build` to build the model and generate Java code for your customized traits.
88
+
#### **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`:
0 commit comments