Skip to content

Latest commit

 

History

History
151 lines (124 loc) · 4.49 KB

basic_6.adoc

File metadata and controls

151 lines (124 loc) · 4.49 KB

Basic plugin usage and support

Plugin requirements and compatibility

Plugin requires to work one of these plugins: java, java library, Android application or Android library. These plugins can be applied directly or indirectly.

Additionally, plugin is compatible with org.freefair.lombok.

Apply the plugin and basic settings

One should follow an official Gradle guide to apply the plugin.

Examples are provided in a table below to showcase org.jsonschema2dataclass plugin minimal configuration. This way, extension jsonSchema2Pojo will be configured with an execution example in the executions container.

More detailed usage is documented in parameters section.

DSL language DSL example

Groovy

plugins {
    id "java"
    id "org.jsonschema2dataclass" version "x.y.z"
}

jsonSchema2Pojo {
    executions {
        example {}
    }
}

Kotlin

plugins {
    java
    id("org.jsonschema2dataclass") version "x.y.z"
}

jsonSchema2Pojo {
    executions {
        create("example") {
        }
    }
}

Processor dependencies

In some cases it is required to specify dependencies for a processor to reference some JSON files via classpath or define plugin classes for a processor.

To achieve this, it is required to add these dependencies to jsonschema2dataclassPlugins configuration.

Note
It’s impossible to add a dependency from an output from an execution.

Hooks and task dependencies

By default, plugin generates tasks to be run after process resources task, so the output from this task can be used. Additionally, plugin tasks are configured to run before execution of compilation and lombok (from org.freefair.lombok) processor.

SDK and build tools support

Table 1. Demos and statuses
SDK/Tool Minimal Version Maximum version Notes

Java compiler

8

19

Gradle

6.0

7.x

8.0 support is currently in beta.

Android Gradle Plugin

3

7

Demos and their statuses

Project contains various minimal org.jsonschema2dataclass plugin usage demos. These minimal applications doesn’t represent a normal full-featured applications for a given platform. These application are included for a showcase plugin features and capabilities.

Note
Any additional ideas and contributions are welcome.
Table 2. Demos and statuses
Platform Demo Status Notes

JVM

Groovy DSL example

Maintained and healthy

Demonstrates compatibility with Groovy DSL

Kotlin DSL example

Maintained and healthy

Demonstrates compatibility with Kotlin DSL and Kotlin language

Model publishing example

Maintained and healthy

Demonstrates a way to publish jars with sources and schemas along with classes

Plugin’s processor classpath examples

Maintained and healthy

Demonstrates usage for plugin’s processor classpath manipulation to apply schemas and custom RuleFactory

Android

AGP 7 example

Maintained and healthy

Demonstrates usage in an android application

AGP 4

⚠️ Demo has been removed since 6.0

  • AGP 4 API is used to bind to the Android project, so it’s still technically supported.

  • PR and support for a demo is welcome