Protobuf配置Intellij Idea Plugin Gradle-kotlin-dsl kotlin
Protobuf configuration Intellij Idea Plugin Gradle-kotlin-dsl kotlin
嘿,我想在 intellij idea 插件中设置 protobuf 作为其他 protobuf 服务器(用 golang 编写)的客户端。这将是我对 grpc 的第一个 java 方法。我尝试使用 kotlin classess 生成器,但我比使用这种方法更不成功。
我的目标是:
最佳情况:插件将允许将 proto 编译为 kt 文件
非常好的案例场景:插件将输出 java 个文件到 src/main/proto
现有代码结构:
└───src
├───main
│ ├───kotlin
│ │ └───pl
│ │ └───dominikw
│ │ ├───configuration
│ │ ├───model
│ │ ├───service
│ │ │ └───impl
│ │ └───ui
│ ├───proto
│ └───resources
│ ├───icons
│ └───META-INF
└───test
├───kotlin
└───resources
和Gradle kotlin dsl 文件:
import com.google.protobuf.gradle.*
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
group = "pl.dominikw"
version = "0.1.1"
val protobufVersion = "3.9.1"
buildscript {
repositories {
mavenCentral()
maven("https://oss.sonatype.org/content/repositories/snapshots/")
maven("https://dl.bintray.com/jetbrains/intellij-plugin-service")
}
dependencies {
classpath("org.jetbrains.intellij.plugins:gradle-intellij-plugin:0.5.0-SNAPSHOT")
}
}
plugins {
id("org.jetbrains.intellij") version "0.4.10"
id("com.google.protobuf") version "0.8.10"
kotlin("jvm") version "1.3.50"
java
idea
}
repositories {
mavenCentral()
maven("https://dl.bintray.com/kittinunf/maven")
}
dependencies {
implementation(kotlin("stdlib-jdk8"))
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.1")
implementation("com.github.kittinunf.fuel", "fuel", "2.2.0")
compile("com.google.protobuf:protobuf-java:$protobufVersion")
compile("io.grpc:grpc-stub:1.15.1")
compile("io.grpc:grpc-protobuf:1.15.1")
if (JavaVersion.current().isJava9Compatible) {
compile("javax.annotation:javax.annotation-api:1.3.2")
}
// protobuf(files("src/main/proto"))
// "mainProto"(files("src/main/proto"))
runtime("io.grpc:grpc-netty:1.14.0")
}
sourceSets {
main {
java.srcDir("src/main/kotlin")
resources.srcDir("src/main/resources")
proto.srcDir("src/main/proto")
}
}
// See https://github.com/JetBrains/gradle-intellij-plugin/
intellij {
version = "2019.2"
}
tasks.getByName<org.jetbrains.intellij.tasks.PatchPluginXmlTask>("patchPluginXml") {
changeNotes(
"""
Add change notes here.<br>
<em>most HTML tags may be used</em>"""
)
}
configure<org.jetbrains.intellij.IntelliJPluginExtension> {
version = "2019.2"
updateSinceUntilBuild = true
pluginName = "Windchill-Plugin"
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:$protobufVersion"
}
plugins {
id("grpc") {
artifact = "io.grpc:protoc-gen-grpc-java:1.15.1"
}
}
generateProtoTasks {
ofSourceSet("main").forEach {
it.plugins {
id("grpc")
}
}
}
}
错误代码如下:
7:17:20 PM: Executing task 'generateProto'...
> Task :extractIncludeProto UP-TO-DATE
> Task :extractProto UP-TO-DATE
> Task :generateProto FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':generateProto'.
> protoc: stdout: . stderr: C:\Users\XXX\IdeaProjects\Windchill-Intellij-Plugin\build\extracted-protos\main\service.proto: Input is shadowed in the --proto_path by "C:/Users/XXX/IdeaProjects/Windchill-Intellij-Plugin/src/main/proto/service.proto". Either use the latter file as your input or reorder the --proto_path so that the former file's location comes first.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 0s
3 actionable tasks: 1 executed, 2 up-to-date
7:17:20 PM: Task execution finished 'generateProto'.
您的错误信息是:
...Input is shadowed in the --proto_path by "C:/Users/XXX/IdeaProjects/Windchill-Intellij-Plugin/src/main/proto/service.proto".
您的 proto 文件夹中的 .proto 文件有一些无效的定义。
嘿,我想在 intellij idea 插件中设置 protobuf 作为其他 protobuf 服务器(用 golang 编写)的客户端。这将是我对 grpc 的第一个 java 方法。我尝试使用 kotlin classess 生成器,但我比使用这种方法更不成功。
我的目标是: 最佳情况:插件将允许将 proto 编译为 kt 文件 非常好的案例场景:插件将输出 java 个文件到 src/main/proto
现有代码结构:
└───src
├───main
│ ├───kotlin
│ │ └───pl
│ │ └───dominikw
│ │ ├───configuration
│ │ ├───model
│ │ ├───service
│ │ │ └───impl
│ │ └───ui
│ ├───proto
│ └───resources
│ ├───icons
│ └───META-INF
└───test
├───kotlin
└───resources
和Gradle kotlin dsl 文件:
import com.google.protobuf.gradle.*
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
group = "pl.dominikw"
version = "0.1.1"
val protobufVersion = "3.9.1"
buildscript {
repositories {
mavenCentral()
maven("https://oss.sonatype.org/content/repositories/snapshots/")
maven("https://dl.bintray.com/jetbrains/intellij-plugin-service")
}
dependencies {
classpath("org.jetbrains.intellij.plugins:gradle-intellij-plugin:0.5.0-SNAPSHOT")
}
}
plugins {
id("org.jetbrains.intellij") version "0.4.10"
id("com.google.protobuf") version "0.8.10"
kotlin("jvm") version "1.3.50"
java
idea
}
repositories {
mavenCentral()
maven("https://dl.bintray.com/kittinunf/maven")
}
dependencies {
implementation(kotlin("stdlib-jdk8"))
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.1")
implementation("com.github.kittinunf.fuel", "fuel", "2.2.0")
compile("com.google.protobuf:protobuf-java:$protobufVersion")
compile("io.grpc:grpc-stub:1.15.1")
compile("io.grpc:grpc-protobuf:1.15.1")
if (JavaVersion.current().isJava9Compatible) {
compile("javax.annotation:javax.annotation-api:1.3.2")
}
// protobuf(files("src/main/proto"))
// "mainProto"(files("src/main/proto"))
runtime("io.grpc:grpc-netty:1.14.0")
}
sourceSets {
main {
java.srcDir("src/main/kotlin")
resources.srcDir("src/main/resources")
proto.srcDir("src/main/proto")
}
}
// See https://github.com/JetBrains/gradle-intellij-plugin/
intellij {
version = "2019.2"
}
tasks.getByName<org.jetbrains.intellij.tasks.PatchPluginXmlTask>("patchPluginXml") {
changeNotes(
"""
Add change notes here.<br>
<em>most HTML tags may be used</em>"""
)
}
configure<org.jetbrains.intellij.IntelliJPluginExtension> {
version = "2019.2"
updateSinceUntilBuild = true
pluginName = "Windchill-Plugin"
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:$protobufVersion"
}
plugins {
id("grpc") {
artifact = "io.grpc:protoc-gen-grpc-java:1.15.1"
}
}
generateProtoTasks {
ofSourceSet("main").forEach {
it.plugins {
id("grpc")
}
}
}
}
错误代码如下:
7:17:20 PM: Executing task 'generateProto'...
> Task :extractIncludeProto UP-TO-DATE
> Task :extractProto UP-TO-DATE
> Task :generateProto FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':generateProto'.
> protoc: stdout: . stderr: C:\Users\XXX\IdeaProjects\Windchill-Intellij-Plugin\build\extracted-protos\main\service.proto: Input is shadowed in the --proto_path by "C:/Users/XXX/IdeaProjects/Windchill-Intellij-Plugin/src/main/proto/service.proto". Either use the latter file as your input or reorder the --proto_path so that the former file's location comes first.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 0s
3 actionable tasks: 1 executed, 2 up-to-date
7:17:20 PM: Task execution finished 'generateProto'.
您的错误信息是:
...Input is shadowed in the --proto_path by "C:/Users/XXX/IdeaProjects/Windchill-Intellij-Plugin/src/main/proto/service.proto".
您的 proto 文件夹中的 .proto 文件有一些无效的定义。