Plugin with id 'com.google.protobuf' not found

plugins

(欧小川) #1

gradle version : 3.3

subprojects{
    apply plugin: 'java'
    repositories {
        mavenCentral()
    }
    
    buildscript {
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath "gradle.plugin.com.google.protobuf:protobuf-gradle-plugin:0.8.0"
        }
    }
    apply plugin: "com.google.protobuf"

    protobuf {
        protoc { artifact = 'com.google.protobuf:protoc:3.0.2' }
        plugins {
            grpc { artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}" }
        }
        generateProtoTasks {
            all()*.plugins {
                grpc { option 'enable_deprecated=false' }
            }
        }
    }
}

I have a root project, two sub-projects A and B.
I want to write a common configuration of A and B in the root project build.gradle file, but I always get the following error:
Plugin with id ‘com.google.protobuf’ not found.

When I write the same configuration in the A project build.gradle file, the compiler can be passed correctly.

I have been stuck here for a long time, who can help me.


(Benjamin Muschko) #2

You are using incorrect coordinates for the plugin. It should be com.google.protobuf:protobuf-gradle-plugin:0.8.0. For more information please see the GitHub page of the plugin.


(欧小川) #3

I do not quite understand your answer,
I have already said that when I write the same configuration in the build.gradle file of the subproject A, the compilation can pass normally.
But when I move the configuration to the root project, subprojects{ }, compile error, see the code I gave above.
I’ve learned some usage from the links you gave, but I still have not found the cause of the error.
You can help me find out where the wrong configuration? Thank you. :grin:


(Benjamin Muschko) #4

The buildscript block needs to go on the top level of the build script (outside of subprojects).


(欧小川) #5

Thank you so much. I’m too sloppy. :wink:
Where can I learn about the use of gradle buildscript?


(欧小川) #6

It 's too late for me to go to bed. Goodbye. :wave: Thanks again for your help.


(Benjamin Muschko) #7

You can learn about it in the user guide. However, I’d like to mention that we could do a better job in being more detailed about limitation and gotchas.