gpt4 book ai didi

kotlin - 未解析的引用 : protoc - when using Gradle + Protocol Buffers

转载 作者:行者123 更新时间:2023-12-04 14:32:42 27 4
gpt4 key购买 nike

我有一个使用 Kotlin DSL 的 gradle 项目
build.gradle.kts

plugins {
kotlin("jvm") version "1.4.21"
id("com.google.protobuf") version "0.8.10"
}

group = "schema"
version = "0.0.1-SNAPSHOT"

repositories {
mavenCentral()
}
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:3.0.0"
}
}
schema.proto
syntax = "proto3";
package schema;

message Message {
string content = 1;
string date_time = 2;
}
和项目结构
schema
-src/main/proto/schema.proto
-build.gradle.kts
每当我跑 gradle build我得到错误:
FAILURE: Build failed with an exception.

* Where:
Build file '/Users/x/schema/build.gradle.kts' line: 13

* What went wrong:
Script compilation errors:

Line 15: protoc {
^ Unresolved reference: protoc

Line 16: artifact = "com.google.protobuf:protoc:3.0.0"
^ Unresolved reference: artifact

* 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 8s
我所做的与各种教程不同的唯一一件事是使用 Gradle Kotlin DSL。我究竟做错了什么?

最佳答案

我认为这是因为您在 protobuf gradle 插件中引用了单个任务。尝试导入整个包以根据需要使用类型安全访问器。

import com.google.protobuf.gradle.*

关于kotlin - 未解析的引用 : protoc - when using Gradle + Protocol Buffers,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65390807/

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