ImFlog/schema-registry-plugin

Unable to pass configuration as parameters

Closed this issue · 5 comments

Hi,

I would like to pass configuration for task testSchemasTask from the command line:

./gradlew :testSchemasTask -Purl='localhost:8081' -Pusername=user -Ppassword=password

Or maybe there already exists any other mechanism for injecting the configuration?
I also tried to decorate task with sth like that:

testSchemasTask.doFirst { environment 'SCHEMA_REGISTRY_URL', project.property("url") }

schemaRegistry {
    url = System.env['SCHEMA_REGISTRY_URL']
    credentials {
        username = System.env['SCHEMA_REGISTRY_USERNAME']
        password = System.env['SCHEMA_REGISTRY_PASSWORD']
    }
    ...
}

But it also doesn't work. Gradle cannot resolve testSchemasTask. Could you give some advice?

Hello, thank you for the interest in this plugin.

I tried very quickly locally and it seems that there is indeed something not working.
In a way I think it is related to the task #34 because the task is created to early and thus parameter can't be used (just a quick thought).
The mentioned task will require some big refactoring I need to find some time soon.

Forget what I just said, I found a way to add this behavior using LazyConfiguration.
I successfully passed the url using a system property, I will do the same for the other properties and check that everything is still working well.

I just pushed a branch named feature/lazy_configuration, can you try if it works for you on it ?
For example you can use something like this:

schemaRegistry {
    url = theUrl
    register {
        subject('mytopic', 'src/main/avro/mysample.avsc')
    }
    compatibility{
        subject('mytopic', 'src/main/avro/mysample.avsc')
    }
    download {
        subject('mytopic', 'src/main/download')
    }
}

And then pass the variable like this ./gradlew -PtheUrl="http://localhost:8082/" registerSchemasTask.

Thank you for engagement. I will try build plugin locally and test it.

I've just released the version 0.9.0 on the plugin portal, as it seems to work for you I'll close this issue.
Do not hesitate to recreate an issue in case of trouble.
Thanks