eclipsegradleauto-value

How to configure Auto-Value with Eclipse and Gradle?


I want to use Google’s Auto-Value in a Gradle java-library project in Eclipse.

My class:

@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 says: To use Auto-Value in Gradle, simply use:

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"
}

I did this, and it didn’t work:

> 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;

Then i googled and found a Gradle APT plugin that should solve all problems. But the documentation of the plugin says: it is unnecessary for Gradle >= 4.6, and since i’m using gradle 5.4, i should be fine without that plugin.

How get i Auto-Value integrated?


Solution

  • Ok, you should never code after midnight. And you should solve problems by discarding any code written after midnight.

    The source code simply was wrong. Private fields instead of abstract methods, false name of the autoValue autogenerated class.

    Sorry for inconvenience. No further reply necessary. All docs found with google are valid.