我想在 Eclipse 的 Gradle java-library 项目中使用 Google 的 Auto-Value。
我的课:
@AutoValue
public abstract class Pairing implements Comparable<Pairing> {
static Pairing create(final Participant white, final Participant black) {
return new AutoValue_Participant(white, black);
}
private final transient Participant white;
private final transient Participant black;
}
https://github.com/google/auto/blob/master/value/userguide/index.md说:要在 Gradle 中使用 Auto-Value,只需使用:
dependencies {
// Use 'api' rather than 'compile' for Android or java-library projects.
compile "com.google.auto.value:auto-value-annotations:1.6.2"
annotationProcessor "com.google.auto.value:auto-value:1.6.2"
}
我这样做了,但没有用:
> Task :compileJava FAILED
D:\QNo_Dokumente\Java\workspace\SwissCoffee\src\main\java\de\qno\swisscoffee\Pairing.java:20: error: cannot find symbol
return new AutoValue_Participant(white, black);
^
symbol: class AutoValue_Participant
location: class Pairing
D:\QNo_Dokumente\Java\workspace\SwissCoffee\build\classes\java\main\de\qno\swisscoffee\AutoValue_Pairing.java:11: error: constructor Pairing in class Pairing cannot be applied to given types;
然后我用谷歌搜索并找到了一个可以解决所有问题的 Gradle APT 插件。但是插件的文档说:Gradle >= 4.6 是不必要的,因为我使用的是 gradle 5.4,没有那个插件我应该没问题。
如何整合 i Auto-Value?