I am trying to use gradle to compile proto files into python, a task that appears trivial for java, but for some reason does not work for python using anything I've tried so far.
previously I've compiled .proto files into java using this tutorial: https://github.com/google/protobuf-gradle-plugin but for some reason there seems to be no similar solution for compiling python. I can still compile it manually using the CLI, but I would really like to create a solution which does not requite doing anything manually, nor the installation of protoc on the user's computer. I have found a lead in this thread: https://github.com/google/protobuf-gradle-plugin/issues/52 but it does not seem to be working for me.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.9'
}
}
plugins {
id 'java'
id "com.google.protobuf" version "0.8.8"
id 'application'
}
group 'foo.bar'
mainClassName = 'some.class.name'
version '1.0.2'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
apply plugin: 'java'
apply plugin: 'com.google.protobuf'
apply plugin: 'idea'
repositories {
mavenCentral()
}
dependencies {
compile "com.google.protobuf:protobuf-java:3.6.0"
compile("io.grpc:grpc-netty:1.7.0")
compile("io.grpc:grpc-protobuf:1.7.0")
compile("io.grpc:grpc-stub:1.7.0")
}
buildDir = "$rootProject.buildDir"
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:3.6.0"
}
plugins {
grpc_java {
artifact = "io.grpc:protoc-gen-grpc-java:1.17.1"
}
grpc_python {
path = "python -m grpc_tools.protoc"
}
}
generateProtoTasks {
all()*.builtins {
java {}
python {}
}
all()*.plugins {
grpc_java {
outputSubDir = "java"
}
grpc_python {
outputSubDir = "python"
}
}
}
generatedFilesBaseDir = "$buildDir/generated/src"
}