To generate JSON schemas from Avro IDL (.avdl) files, you must follow a two-step process:
- Use
GenerateAvroProtocolTask to convert .avdl to .avpr (JSON protocol). - Use
GenerateAvroSchemaTask to convert .avpr to .avsc (JSON schema).
For existing .avpr files, you can use GenerateAvroSchemaTask directly.
import com.github.davidmc24.gradle.plugin.avro.GenerateAvroProtocolTask
import com.github.davidmc24.gradle.plugin.avro.GenerateAvroSchemaTask
apply plugin: "com.github.davidmc24.gradle.plugin.avro-base"
def generateProtocol = tasks.register("generateProtocol", GenerateAvroProtocolTask) {
source file("src/main/avro")
include("**/*.avdl")
outputDir = file("build/generated-avro-main-avpr")
}
tasks.register("generateSchema", GenerateAvroSchemaTask) {
dependsOn generateProtocol
source file("src/main/avro")
source file("build/generated-avro-main-avpr")
include("**/*.avpr")
outputDir = file("build/generated-main-avro-avsc")
}