使用protobuf插件,Gradle会抛出一个错误,表示proto-2.4.1不存在。在URL之后,protoc-2.4.1就在那里。 什么是Gradle或插件寻找我不理解?
* What went wrong:
Could not resolve all files for configuration ':src:protobufToolsLocator_protoc'.
> Could not find com.google.protobuf:protoc:2.4.1.
Searched in the following locations:
file:/root/.m2/repository/com/google/protobuf/protoc/2.4.1/protoc-2.4.1.pom
file:/root/.m2/repository/com/google/protobuf/protoc/2.4.1/protoc-2.4.1-linux-x86_64.exe
https://repo.maven.apache.org/maven2/com/google/protobuf/protoc/2.4.1/protoc-2.4.1.pom
https://repo.maven.apache.org/maven2/com/google/protobuf/protoc/2.4.1/protoc-2.4.1-linux-x86_64.exe
https://mvnrepository.com/artifact/com.google.protobuf/protoc/com/google/protobuf/protoc/2.4.1/protoc-2.4.1.pom
https://mvnrepository.com/artifact/com.google.protobuf/protoc/com/google/protobuf/protoc/2.4.1/protoc-2.4.1-linux-x86_64.exe
Required by:
project :src
我的 build.gradle 文件非常简单:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.5'
}
}
apply plugin: 'c'
apply plugin: 'cpp'
apply plugin: 'java'
apply plugin: 'com.google.protobuf'
repositories {
mavenLocal()
mavenCentral()
maven {
url "https://mvnrepository.com/artifact/com.google.protobuf/protoc"
}
}
dependencies {
compile group: 'com.google.protobuf', name: 'protoc', version: '2.4.1'
}
sourceSets {
fs {
proto {
srcDir '.'
}
}
}
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:2.4.1'
}
generateProtoTasks {
all().each { task ->
task.builtins {
remove java
cpp {
}
}
}
}
}
我的Gradle信息:
Gradle 4.7
建造时间:2018-04-18 09:09:12 UTC
修订:b9a962bf70638332300e7f810689cb2febbd4a6c
Groovy:2.4.12
Ant:Apache Ant(TM)版本1.9.9于2017年2月2日编译
JVM:1.8.0_144(Oracle Corporation 25.144-b01)
操作系统:Linux 3.10.0-514.el7.x86_64 amd64