protop Gradle Plugin
The protop Gradle plugin makes it easier to use protop in Gradle projects. You still need protop installed and a valid protop.json
, but the Gradle plugin simplifies the rest of your project's integration with protop.
Install
The Gradle plugin is added as a buildscript dependency:
buildscript { repositories { mavenCentral() } dependencies { classpath "io.protop:protop-gradle-plugin:<current version>" }}
Apply the plugin, and customize the options:
apply plugin: "io.protop"protop { useLinks = true refreshGitSources = true}
Add the protop path to your sources. Without this plugin, you'd do the same but with the raw path. Here, the plugin provides that value as a variable:
sourceSets { main { proto { srcDirs += protop.path } }}
Finally, have the Protobuf plugin depend on the protopSync
task:
protobuf { // ... generateProtoTasks { all().each { task -> task.dependsOn { protopSync } } }}
You can find an example of this in the Java implementation of a simple service from this tutorial.