JetBrains / intellij-platform-gradle-plugin

Gradle plugin for building plugins for JetBrains IDEs
https://plugins.jetbrains.com/docs/intellij/gradle-prerequisites.html
Apache License 2.0
1.44k stars 272 forks source link

plugin: 'org.jetbrains.intellij' conflict with plugin: "com.google.protobuf" #226

Closed conanchen closed 7 years ago

conanchen commented 7 years ago

I try to develop an IDEA plugin using protobuf 3 + grpc. if I apply the plugin : "com.google.protobuf" , I will always get the compile error: /Users/admin/git/live-sexyeditor/build/generated/source/proto/main/java/net/intellij/plugins/sexyeditor/greeter/GreeterOuterClass.java:403: 错误: 找不到符号 com.google.protobuf.Descriptors.OneofDescriptor oneof) { ^ 符号: 类 OneofDescriptor 位置: 类 Descriptors

found that com.google.protobuf.Descriptors.OneofDescriptor comes from protobuf-java V3 but the compiler always compile using the provided protobuf-java 2.5.0 ,

How can i disable my plugin using the provided V2.5.0 protobuf but using V3 protobuf defined in dependencies?

for details , please refer to below links https://github.com/conanchen/live-sexyeditor/tree/with-protobuf3-notwork https://github.com/conanchen/live-sexyeditor/tree/without-protobuf3-works

zolotov commented 7 years ago

please try this:

project.afterEvaluate {
    sourceSets {
        main {
            compileClasspath -= files(new File(intellij.ideaDependency.classes, "lib/protobuf-2.5.0.jar").getAbsolutePath(),
                                      new File(intellij.ideaDependency.classes, "lib/studio-profiler-grpc-1.0-jarjar.jar").getAbsolutePath())
        }
    }
}
conanchen commented 7 years ago

Thanks, it works. now the compiler can fall into protobuf V3 when I add your script with additional "force true" for the dependencies:

dependencies { compile ('io.grpc:grpc-netty:1.6.1') compile('io.grpc:grpc-protobuf:1.6.1') { force true } compile ('io.grpc:grpc-stub:1.6.1'){ force true } compile('com.google.protobuf:protobuf-java:3.3.1') { force true } compile('io.grpc:grpc-core:1.6.1') { force true } }

zolotov commented 7 years ago

Yes, it will be in external libraries anyway, I don't think it's possible to remove it right now. But the compilation works fine for me on repos you attached. Do you really use gradle for compilation?

hweigel528 commented 4 years ago

I am encountering a similar issue: installing the plugin forces the use of protobuf-java:3.5.1, which is not compatible with the .toString() method of protos compiled using protoc:3.12.2

I'm fairly new to Gradle, but I thought diamond dependencies were resolved using the highest version. Why is 3.5.1 being used even after I explicitly depend on protobuf-java:3.12.2 ? I tried using gradle's --dependency tools to debug, but it does not tell me anything about the dependencies of com.jetbrains:ideaIC:LATEST-EAP-SNAPSHOT

The "project.afterEvaluate" and "force true" workarounds described above doesn't seem to work for me, are there any other ways to resolve this issue?