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
Explain compiler options needed for Jackson deserialization (#381)
* Explain compiler options needed for Jackson deserialization
* Update docs/authoring-recipes/recipe-development-environment.md
Co-authored-by: Tim te Beek <timtebeek@gmail.com>
* Update docs/authoring-recipes/recipe-development-environment.md
---------
Co-authored-by: Tim te Beek <timtebeek@gmail.com>
Co-authored-by: Mike Solomon <mikesol@hey.com>
If you are using Gradle, it is highly-recommended that you apply the [`org.openrewrite.build.recipe-library-base` plugin](https://plugins.gradle.org/plugin/org.openrewrite.build.recipe-library-base). The plugin automatically configures the project with meaningful conventions like necessary compiler options.
60
+
:::
61
+
58
62
### Dependencies & dependency management
59
63
60
64
Rewrite provides a bill of materials (BOM) that, when imported into your build, will manage the versions of any rewrite dependencies that are included within a project.
<!-- Jackson deserialization requires named parameters -->
223
-
<compilerArgs>
224
-
<arg>-parameters</arg>
225
-
</compilerArgs>
226
222
<!-- lombok is optional, but recommended for authoring recipes -->
227
223
<annotationProcessorPaths>
228
224
<path>
@@ -283,6 +279,43 @@ tasks.compileJava {
283
279
</TabItem>
284
280
</Tabs>
285
281
282
+
### Jackson deserialization
283
+
284
+
Some recipe implementations may use [Jackson deserialization](https://github.com/FasterXML/jackson-annotations) by defining annotations such as `@JsonCreator` and `@JsonProperty`.
285
+
286
+
In order to deserialize Java classes, you need to add the `-parameters` compiler argument. This is necessary for Jackson to be able to deserialize the constructor parameters of a class.
287
+
288
+
<TabsgroupId="projectType">
289
+
<TabItemvalue="gradle"label="Gradle">
290
+
291
+
```groovy title="build.gradle"
292
+
tasks.withType(JavaCompile).configureEach {
293
+
options.compilerArgs.add('-parameters')
294
+
}
295
+
```
296
+
</TabItem>
297
+
298
+
<TabItemvalue="maven"label="Maven">
299
+
300
+
```xml title="pom.xml"
301
+
<build>
302
+
<plugins>
303
+
<plugin>
304
+
<groupId>org.apache.maven.plugins</groupId>
305
+
<artifactId>maven-compiler-plugin</artifactId>
306
+
<version>3.14.0</version>
307
+
<configuration>
308
+
<compilerArgs>
309
+
<arg>-parameters</arg>
310
+
</compilerArgs>
311
+
</configuration>
312
+
</plugin>
313
+
</plugins>
314
+
</build>
315
+
```
316
+
</TabItem>
317
+
</Tabs>
318
+
286
319
### Project layout
287
320
288
321
Having configured the project per these recommendations, you're now able to begin Recipe development. With Gradle and Maven's default project layout, you'll want to put your files in these directories:
0 commit comments