marcoferrer / kroto-plus

gRPC Kotlin Coroutines, Protobuf DSL, Scripting for Protoc
Apache License 2.0
493 stars 28 forks source link

Provide a gradle plugin dsl for easier configuration of the protoc plugin #8

Open marcoferrer opened 5 years ago

marcoferrer commented 5 years ago

Using a gradle plugin we can remove to need to provide a configuration file to protoc-gen-kroto-plus. This would make it a lot easier to configure options and allow the configuration to use variables from the build logic.

Since all of the plugins configuration is based on a proto definition, we may be able to just write a generator script to create the needed gradle dsl. This would allow the gradle plugin to automatically stay up to date with changes to configuration options.

Fleshgrinder commented 4 years ago

It would be great if there is a possibility to retrieve the Kroto+ version of the plugin in the build script otherwise we are forced to have the version at two places in our build scripts. Gradle has no easy built-in way to achieve this. The Kotlin Gradle plugin for instance simply auto-aligns all Kotlin dependencies. This would obviously be nice but having a version property on the plugin itself is still good, just in case someone ever needs it for something else.

plugins.findPlugin(KrotoPlusGradlePlugin::class)?.version
marcoferrer commented 4 years ago

@Fleshgrinder Thanks for the feedback. This is a great suggestion! Ill need to do some investigation as to how the Kotlin plugin manages dependency version. My initial guess is that it scans all the existing configurations in a project and any artifact missing a version that uses their group gets updated.

We should also check not just the artifact dependencies but the tools locator configuration dynamically created by the gradle protobuf plugin.

Thoughts?

marcoferrer commented 4 years ago

It looks like it can be accomplished with a simple dependency resolution rule. The proposed implementation also works for artifacts defined in the protobuf plugin. This is targeted for the v0.6.1 release

Fleshgrinder commented 4 years ago

Awesome work!