gradle - 如何在gradle kotlin dsl上配置jsonschema2pojo插件

标签 gradle gradle-plugin gradle-kotlin-dsl

我在我的kotlin dsl jsonschema2pojo文件中使用build gradle插件。
现在,我需要按照here所述更改插件的默认配置

    jsonSchema2Pojo {
      source = files("${sourceSets.main.output.resourcesDir}/json")
    } 
当我添加此时,我得到以下错误-

$ 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


我的构建文件在github here上。
任何想法如何为jsonschema2pojo插件配置我的构建文件?

最佳答案

尝试在gradle.build.kts中使用这种配置

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

    // etc.
}

关于gradle - 如何在gradle kotlin dsl上配置jsonschema2pojo插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59776834/

相关文章:

android - 构建 Gradle + Proguard + APKLib

spring-boot - Spring-boot BOM不包含tomcat-dbcp的依赖项

java - 在gradle应用中找不到ant-javafx

android - 在根项目 buildscript 中使用复合构建中的 Gradle 插件

android - Android 项目中带有 Gradle 插件的模块

spring - org.springframework.boot hotdeploy在gradle中不起作用

java - 如何防止 jacoco 检测生产代码?

gradle - Fat Jar 使用 Gradle Kotlin DSL 扩展依赖关系

android - Android Gradle Kotlin Dsl 中 Unresolved reference 问题

gradle - 如何将 testOptions.unitTests.all 转换为 gradle Kotlin dsl