3

Eclipse の Gradle Java ライブラリ プロジェクトで 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 を使用しているため、そのプラグインがなくても問題ないと書かれています。

Auto-Value を統合するにはどうすればよいですか?

4

1 に答える 1