如何让 Gradle @Input 工作List<CustomClass>
?我已经尝试添加该toString()
方法,这有帮助,但它仍然以奇怪的方式失败。使其可序列化的正确方法是什么?这是 Gradle 的 2.4 版。
失败:List<CustomClass>
@Input
List<CustomClass> getMyInput() {
List<CustomClass> simpleList = new ArrayList<>()
simpleList.add(new CustomClass())
return simpleList
}
static class CustomClass {
String str
}
这失败并显示以下消息:
"Unable to store task input properties. Property 'myInput' with value '[null]' cannot be serialized."
成功:List<String>
@Input
List<String> getMyInput() {
List<String> simpleList = new ArrayList<>()
simpleList.add(new String('ignore'))
return simpleList
}
异常创建位置的 Gradle 源代码参考: https ://github.com/gradle/gradle/blob/master/subprojects/core/src/main/groovy/org/gradle/api/internal/changedetection/state/InputPropertiesSerializer .java#L42