Grpc protoc configuration cannot upgrade to latest version with gradle 7.0 but possible in gradle 4.2

Viewed 134

This is my protoc setup in build.gradle which works in gradle 4.2

protobuf {
    protoc { artifact = 'com.google.protobuf:protoc:3.10.0' }
    plugins {
        javalite { artifact = "com.google.protobuf:protoc-gen-javalite:3.0.0" }
        grpc { artifact = 'io.grpc:protoc-gen-grpc-java:1.25.0' // CURRENT_GRPC_VERSION
        }
    }
    generateProtoTasks {
        all().each { task ->
            task.plugins {
                javalite {}
                grpc { // Options added to --grpc_out
                    option 'lite' }
            }
        }
    }
}

How is it not building in only gradle 7.0?

1 Answers

The protoc setup for as described in the current documentation is:

protobuf {
    protoc { artifact = 'com.google.protobuf:protoc:3.12.0' }
    plugins {
        grpc { artifact = 'io.grpc:protoc-gen-grpc-java:1.36.0' // CURRENT_GRPC_VERSION
        }
    }
    generateProtoTasks {
        all().each { task ->
            task.builtins {
                java { option 'lite' }
            }
            task.plugins {
                grpc { // Options added to --grpc_out
                    option 'lite' }
            }
        }
    }
}

The main difference from what you have is the lack of definition in task.plugins and setting mode 'lite' and using the grpc-java library and not the java-lite.

Related