Search code examples
kotlingradleavro

Gradle with Kotlin DSL expecting Property<String> error


I need to set this

avro {
    templateDirectory = "/path/to/velocity/templates"
}

But getting error stating that's it's expecting Property<String> not a String.

Not clear on how to set this value as Property<String>?


Solution

  • If you're using the gradle-avro-plugin, do note that the configuration should be set as below for Kotlin DSL

    avro {
        templateDirectory.set("/path/to/velocity/templates" as String?)
    }
    

    The syntax for all the configurations are as below:

    avro {
        isCreateSetters.set(true)
        isCreateOptionalGetters.set(false)
        isGettersReturnOptional.set(false)
        fieldVisibility.set("PUBLIC_DEPRECATED")
        outputCharacterEncoding.set("UTF-8")
        stringType.set("String")
        templateDirectory.set(null as String?)
        isEnableDecimalLogicalType.set(true)
        dateTimeLogicalType.set("JSR310")
    }
    

    The reference is here.