This plugin is aiming to take raw JSON or YAML raw files or schemas and convert definitions to Java POJOs (Plain Old Java Object).
At the moment of writing documentation, it uses jsonschema2pojo 1.2.1 library to generate classes.
The org.jsonschema2dataclass
plugin feature highlight:
-
Full support and testing for wide version range of versions of Java, Gradle and AGP including task caching, proper hooking and other features.
Currently, it’s Java 1.8 to 19, Gradle 6.0 to 7.6 and AGP 3, 4 and 7. Additionally, plugin has beta support for Gradle 8.0 and AGP 8.
-
Possibility natively write Gradle scripts in Groovy and Kotlin DSLs.
-
Support for projects written in Kotlin and Groovy and which are using Lombok.
-
Possibility to run multiple executions withing a single project.
This is important for some use cases to generate different sets of models within a single project.
-
Some parameters are more human-writable and using native features provided by Gradle.
Few examples-
propertyWordDelimiters
is array of chars injsonschema2pojo
, which is not easy to write and support. -
org.jsonschema2dataclass
uses Gradle-provided structures for all configuration parameters.
-
-
Plugin is not tied to the library interface and could provide more maintainable configuration presentation and wider feature range when needed.
Please note, that JSON schema constrains can be quite poorly translated to JSR305 and in most cases can’t replace Json Schema Validation. I suggest to use a Json Schema Validation library when possible like one by NetworkNT.
Usage and migration documentation is located in separate documents.
Usage and migration documentation is located in separate documents.