sabomichal / avro-compiler-extension

Avro IDL to Java SpecificCompiler extension
MIT License
5 stars 0 forks source link

using the extension with the gradle-avro-plugin #8

Open SingingBush opened 1 year ago

SingingBush commented 1 year ago

I didn't see anything maven specific in the code so expected this to also work with the gradle-avro-plugin.

I have a config like:

apply plugin: "com.github.davidmc24.gradle.plugin.avro-base"

avro {
    dependencies {
        compileOnly 'com.github.sabomichal:avro-compiler-extension:0.1'
    }
}
...

tasks.register("generate", GenerateAvroJavaTask) {
    dependsOn generateSchema
    source file("../dist")
    include("**/*.avsc")
    outputCharacterEncoding = 'UTF-8'
    additionalVelocityToolClasses = ['com.github.sabomichal.avroextensions.AvroGeneratorExtensions']
    optionalGettersForNullableFieldsOnly = true

    outputDir = file("build/generated/java")
}

but I get the following error:

unable to load velocity tool class com.github.sabomichal.avroextensions.AvroGeneratorExtensions

It's probably that I'm not adding avro-compiler-extension to the build.gradle correctly. Any idea how to get this working in a gradle build?

sabomichal commented 1 year ago

I haven't tried it, but this might work


plugins {
    id "com.github.davidmc24.gradle.plugin.avro" version "1.7.1"
}

dependencies {
    avro 'com.github.sabomichal:avro-compiler-extension:0.1'
}
...

But just looking at the plugin implementation, it probably won't, since the plugin do not define custom configuration set as described here https://docs.gradle.org/current/userguide/implementing_gradle_plugins.html#providing_default_dependencies_for_plugins You need to find a way to workaround it or just file an issue for the plugin itself.