gpt4 book ai didi

gradle - 在 Gradle (6.2) 中,我们可以将自定义任务的构造函数参数注释为 "input"吗?

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

假设我有一个自定义 gradle 任务:

open class CustomTask @Inject constructor(
private val inputFile: File,
private val outputFile: File
) : DefaultTask()

(基于 https://docs.gradle.org/current/userguide/more_about_tasks.html#sec:passing_arguments_to_a_task_constructor )
.

到目前为止,在 gradle 中,定义输入或输出的常用方法是使用注释,如 InputFile。 .

从 Kotlin 的角度来看,在构造函数中注入(inject)所有这些输入/输出值会很好,但我想知道,
是否可以?就像是:
open class CustomTask @Inject constructor(
private @InputFile val inputFile: File,
private @OutputFile val outputFile: File

) : 默认任务()

最佳答案

两个注释状态的javadocs(强调我的):

@InputFile

This annotation should be attached to the getter method in Java or the property in Groovy. Annotations on setters or just the field in Java are ignored.



@OutputFile

This annotation should be attached to the getter method in Java or the property in Groovy. Annotations on setters or just the field in Java are ignored.



回答你的问题:没有。

Kotlin、Java 或 Groovy 中的构造函数参数既不是 getter 也不是属性,因此它们被忽略。

关于gradle - 在 Gradle (6.2) 中,我们可以将自定义任务的构造函数参数注释为 "input"吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60346932/

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