Gradle 渐变:无法存储任务输入属性。财产';myInput';具有值';[null]';无法序列化

Gradle 渐变:无法存储任务输入属性。财产';myInput';具有值';[null]';无法序列化,gradle,gradle-plugin,Gradle,Gradle Plugin,如何使Gradle@Input适用于列表?我已经尝试添加toString()方法,这很有帮助,但仍然以奇怪的方式失败。使其可序列化的正确方法是什么?这是Gradle的2.4版 失败:列表 成功:列表 @输入 列表getMyInput(){ List simpleList=new ArrayList() 添加(新字符串('ignore')) 返回单纯形 } 创建异常的位置的Gradle源代码参考: 该类需要实现“可序列化”接口。这是为了允许Gradle完全序列化对象,以便可以在构建之间比较二进制

如何使Gradle@Input适用于
列表
?我已经尝试添加
toString()
方法,这很有帮助,但仍然以奇怪的方式失败。使其可序列化的正确方法是什么?这是Gradle的2.4版

失败:
列表

成功:
列表

@输入
列表getMyInput(){
List simpleList=new ArrayList()
添加(新字符串('ignore'))
返回单纯形
}
创建异常的位置的Gradle源代码参考:

该类需要实现“可序列化”接口。这是为了允许Gradle完全序列化对象,以便可以在构建之间比较二进制格式,以查看是否有任何更改。一旦CustomClass是可序列化的,
List
也将是可序列化的,只要它使用标准实现,如
ArrayList

下面是一个例子:

@EqualsAndHashCode
static class CustomClass implements Serializable {
    // Increment this when the serialization output changes
    private static final long serialVersionUID = 1L;

    String projectName

    @SuppressWarnings('unused')
    private static void writeObject(ObjectOutputStream s) throws IOException {
        s.defaultWriteObject();
    }

    // Gradle only needs to serialize objects, so this isn't strictly needed
    @SuppressWarnings('unused')
    private static void readObject(ObjectInputStream s) throws IOException {
        s.defaultReadObject();
    }
}

增加了关于Gradle 2.4的注释。我基本上错过了Serializable的正确实现。见下面的答案。
"Unable to store task input properties. Property 'myInput' with value '[null]' cannot be serialized."
@Input
List<String> getMyInput() {
    List<String> simpleList = new ArrayList<>()
    simpleList.add(new String('ignore'))
    return simpleList
}
@EqualsAndHashCode
static class CustomClass implements Serializable {
    // Increment this when the serialization output changes
    private static final long serialVersionUID = 1L;

    String projectName

    @SuppressWarnings('unused')
    private static void writeObject(ObjectOutputStream s) throws IOException {
        s.defaultWriteObject();
    }

    // Gradle only needs to serialize objects, so this isn't strictly needed
    @SuppressWarnings('unused')
    private static void readObject(ObjectInputStream s) throws IOException {
        s.defaultReadObject();
    }
}