question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

run gradle generateProto failed in intellij

See original GitHub issue

hey 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:open
  • Created 3 years ago
  • Comments:14

github_iconTop GitHub Comments

7reactions
debopcommented, Oct 7, 2020

@jamesward Thanks your solution. It’s work.

use

  1. com.google.protobuf plugin 0.8.13
  2. io.grpc:protoc-gen-grpc-kotlin:0.2.0:jdk7@jar
1reaction
keith-millercommented, Apr 11, 2021

My issue was fixed by updating to latest version of com.google.protobuf:protobuf-gradle-plugin.

Came here from a Google search, this fixed it for me as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

When using the Gradle plugin to run the `generateProto` task ...
When using the Gradle plugin to run the `generateProto` task for a gRPC project (which generates Java files), "Refresh all Gradle projects" must...
Read more >
gRPC gradle :generateProto fails with directory not found ...
I'm trying to compile some protobuf definitions as a gradle task, but get the following error with no source ...
Read more >
Unit test fail when I run "gradle test" but run in Intellij successfully
When I open this project in Intellij, and switch to each single unit test file. All the test can be passed. But when...
Read more >
Config Gradle to generate Java code from Protobuf
Open IntelliJ IDEA and create a new project. We will use Gradle because Google has an official Gradle plugin for protocol buffer.
Read more >
Building Service With gRPC - Callibrity
Now, open the project in Intellij Idea. We have to add some protobuf & grpc plugins into this gradle file and configure them....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found