run gradle generateProto failed in intellij
See original GitHub issuehey guys, I am trying to use gralde generateProtol to generate grpc kotlin code in intellij and it has been unsuccessful. the error message as below:
Caching disabled for task ‘:generateProto’ because: Build cache is disabled Task ‘:generateProto’ is not up-to-date because: Task has failed previously. Resolving artifact: [group:io.grpc, name:protoc-gen-grpc-kotlin, version:0.1.5, classifier:osx-x86_64, ext:exe] Resolved artifact: /usr/local/bin/gradle /caches/modules-2/files-2.1/io.grpc/protoc-gen-grpc-kotlin/0.1.5/343b3d6ab1e9252ce02fed047a8bdf446b563dd2/protoc-gen-grpc-kotlin-0.1.5-osx-x86_64.exe Resolving artifact: [group:io.grpc, name:protoc-gen-grpc-java, version:1.30.0, classifier:osx-x86_64, ext:exe] Resolved artifact: /usr/local/bin/gradle /caches/modules-2/files-2.1/io.grpc/protoc-gen-grpc-java/1.30.0/451d2960539797da3100b64261873a5d96033b67/protoc-gen-grpc-java-1.30.0-osx-x86_64.exe Resolving artifact: [group:com.google.protobuf, name:protoc, version:3.12.2, classifier:osx-x86_64, ext:exe] Resolved artifact: /usr/local/bin/gradle /caches/modules-2/files-2.1/com.google.protobuf/protoc/3.12.2/7799ef10b53f4020275b835020d590199a99d142/protoc-3.12.2-osx-x86_64.exe
FAILURE: Build failed with an exception.
- What went wrong: Execution failed for task ‘:generateProto’.
protoc: stdout: . stderr: Error: Invalid or corrupt jarfile /usr/local/bin/gradle –grpckt_out: protoc-gen-grpckt: Plugin failed with status code 1.
I don’t know what happened, the weird thing is that it is ok to run in the terminal。It seems that the two of them are incompatible. And I can successfully generate grpc java code in Intellij, which does not seem to be a problem with Intellij
my environment configuration:
os.detected.name=osx os.detected.arch=x86_64 os.detected.version=10.15 os.detected.version.major=10 os.detected.version.minor=15 os.detected.classifier=osx-x86_64
gradle: stable 6.6.1 Open-source build automation tool based on the Groovy and Kotlin DSL https://www.gradle.org/ /usr/local/Cellar/gradle/6.5.1 (11,644 files, 249.4MB) *
gradle configurations
val grpcVersion = "1.30.0"
val grpcKotlinVersion = "0.1.5"
val protobufVersion = "3.12.2"
val coroutinesVersion = "1.3.7"
implementation("javax.annotation:javax.annotation-api:1.2")
implementation("com.google.protobuf:protobuf-java-util:$protobufVersion")
implementation("io.grpc:grpc-protobuf:$grpcVersion")
implementation("io.grpc:grpc-stub:$grpcVersion")
implementation("io.grpc:grpc-kotlin-stub:$grpcKotlinVersion")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
runtimeOnly("io.grpc:grpc-netty-shaded:$grpcVersion")
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:$protobufVersion"
}
plugins {
id("grpc") {
artifact = "io.grpc:protoc-gen-grpc-java:$grpcVersion"
}
id("grpckt") {
artifact = "io.grpc:protoc-gen-grpc-kotlin:$grpcKotlinVersion"
}
}
generateProtoTasks {
ofSourceSet("main").forEach {
it.plugins {
id("grpc")
id("grpckt")
}
}
}
}
sourceSets {
main {
java {
setSrcDirs(
listOf(
"build/generated/source/proto/main/grpc",
"build/generated/source/proto/main/java",
"build/generated/source/proto/main/grpckt"
)
)
}
}
}
java {
sourceCompatibility = JavaVersion.VERSION_11
}
hopefully someone can help me with it.
Issue Analytics
- State:
- Created 3 years ago
- Comments:14
Top GitHub Comments
@jamesward Thanks your solution. It’s work.
use
com.google.protobuf
plugin 0.8.13io.grpc:protoc-gen-grpc-kotlin:0.2.0:jdk7@jar
Came here from a Google search, this fixed it for me as well.