Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure jsonschema2pojo plugin on gradle kotlin dsl

I'm using jsonschema2pojo gradle plugin in my kotlin dsl build file.

Now I need to change the default configurations of the plugin as described here

    jsonSchema2Pojo {
      source = files("${sourceSets.main.output.resourcesDir}/json")
    } 

When I add this I get below error -

$ gradle generateJsonSchema2Pojo

Configure project : e: /Users/rajkumar.natarajan/Documents/Coding/misc/jsonschema2pojo-enum-demo/build.gradle.kts:20:1: Unresolved reference: jsonSchema2Pojo e: /Users/rajkumar.natarajan/Documents/Coding/misc/jsonschema2pojo-enum-demo/build.gradle.kts:21:3: Unresolved reference: source e: /Users/rajkumar.natarajan/Documents/Coding/misc/jsonschema2pojo-enum-demo/build.gradle.kts:21:21: Unresolved reference: sourceSets

FAILURE: Build failed with an exception.

  • Where: Build file '/Users/rajkumar.natarajan/Documents/Coding/misc/jsonschema2pojo-enum-demo/build.gradle.kts' line: 20

  • What went wrong: Script compilation errors:

Line 20: jsonSchema2Pojo { ^ Unresolved reference: jsonSchema2Pojo

Line 21: source = files("${sourceSets.main.output.resourcesDir}/json") ^ Unresolved reference: source

Line 21: source = files("${sourceSets.main.output.resourcesDir}/json") ^ Unresolved reference: sourceSets

3 errors

my build file is on github here.

Any idea how to configure my build file for jsonschema2pojo plugin?

like image 959
Rajkumar Natarajan Avatar asked Nov 25 '25 11:11

Rajkumar Natarajan


1 Answers

try to use this kind of configuration in your gradle.build.kts

configure <org.jsonschema2pojo.gradle.JsonSchemaExtension> {
    dateTimeType = "java.time.ZonedDateTime"
    includeAdditionalProperties = false
    includeConstructors = true

    // etc.
}
like image 66
pedro_cze Avatar answered Nov 27 '25 04:11

pedro_cze



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!