gpt4 book ai didi

java - 使用 protobuf for java 时使用 gradle 重复处理策略错误

转载 作者:行者123 更新时间:2023-12-02 01:55:18 35 4
gpt4 key购买 nike

我正在使用下面的配置 build.gradle

plugins {
id "com.google.protobuf" version "0.8.17"
id "java"
}

group "de.prerna.aws.tests"
version "1.0-SNAPSHOT"

repositories {
mavenCentral()
}

ext {

protobufVersion = "3.18.1"
}


dependencies {

implementation "com.google.protobuf:protobuf-java:$protobufVersion"


sourceSets {
main {
proto {
srcDir 'src/main/proto'
}
java {
// include self written and generated code
srcDirs 'src/main/java'
}
}
}

protobuf {
protoc {

artifact = 'com.google.protobuf:protoc:4.0.0-rc-2'
}

plugins {
grpc {
artifact = "io.grpc:protoc-gen-grpc-java:1.39.0"
}
}
generateProtoTasks.generatedFilesBaseDir = 'generated-sources'

generateProtoTasks {
all().each { task ->
task.plugins { grpc{} }
}
ofSourceSet('main')

}
}

错误


* What went wrong:
Execution failed for task ':processResources'.
> Entry Person.proto is a duplicate but no duplicate handling strategy has been set. Please refer to https://docs.gradle.org/7.2/dsl/org.gradle.api.tasks.Copy.html#org.gradle.api.tasks.Copy:duplicatesStrategy for details.

最佳答案

BParolini 的变体对于 build.gradle (Groovy DSL)

tasks.withType(Copy) {
filesMatching("**/*.proto") {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
}

关于java - 使用 protobuf for java 时使用 gradle 重复处理策略错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69676587/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com