gpt4 book ai didi

gradle - 插件中出现奇怪的关闭错误

转载 作者:行者123 更新时间:2023-12-03 06:03:16 28 4
gpt4 key购买 nike

我不明白为什么我通过这个插件收到关闭错误。对此申请:

class MetadataPlugin implements Plugin<Project> {
Project project
MetadataExtension extension

static final METADATA_REPORT = 'metadataReport'
static final METADATA_REPORT_TASK = ':' + METADATA_REPORT

@Override
void apply(Project project) {
this.project = project

// Create and install the extension object
extension = project.extensions.create('metadata', MetadataExtension)


// *** create the tasks ***
def ignore = project.tasks.create(METADATA_REPORT, MetadataReportTask)
ignore.group = PLUGIN_GROUP
ignore.description = 'Gets the detailed information for this project and formats it into a user readable report'

// *** validate the build file ***
project.afterEvaluate {

def String ext_hash = project.extensions.metadata.project_hash

def String hash = {
if (ext_hash == null) {
throw new InvalidUserDataException(
"You must configure the metadata:project_hash value before running any form of build"
)
}
return ext_hash
}
throw new InvalidUserDataException(hash)
}
}
}

添加到它这个build.gradle
plugins {
id 'metadata'
}
metadata {
project_hash '123123123'
}

并产生此错误。
19:44:49.934 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
19:44:49.935 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
19:44:49.935 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
19:44:49.935 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] A problem occurred configuring root project 'junit9025097301225311002'.
19:44:49.935 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > com.devops.gradle.metadata.MetadataPlugin$_apply_closure1$_closure2@5bff38f7
19:44:49.935 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]

我不明白为什么错误不是123123123,为什么它会给我应用闭包错误?扩展名不过是一个简单的pojo。

最佳答案

project_hash是变量,因此您必须直接分配值:

metadata {
project_hash = '123123123'
}

您当前正在使用此功能(例如 project_hash('xyz'))在此处不适用

关于gradle - 插件中出现奇怪的关闭错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40274050/

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