gsonvalue
gsonvalue copied to clipboard
Support gradle's incremental java compiler
https://docs.gradle.org/4.7-rc-1/userguide/java_plugin.html#sec:incremental_annotation_processing
Note: this breaks builders that aren't nested in their parent class. Is this worth it? Should there be a flag? Or just remove support for this?
Actually, it looks like I'll have to rethink how the annotations work for it to be processed correctly. The processor needs to process an annotation on the target class in all cases.
Proposal: have a single top-level @GsonValue annotation on the class. This will support all methods of construction as long as it's not ambiguous how the class should be created. Have an optional @GsonValue.Creator annotation to disambiguate multiple methods of creation.
@GsonValue
public class MyClass {
public final int arg;
public MyClass(int arg) {
this.arg = arg;
}
}
@GsonValue
public class MyClass {
public final int arg;
private MyClass(int arg) {
this.arg = arg;
}
public static class Builder {
...
public MyClass build();
}
}
@GsonValue
public class MyClass {
public final int arg;
MyClass(int arg) {
this.arg = arg;
}
@GsonValue.Creator
public static MyClass create(int arg) {
return new MyClass(arg);
}
}
Builders outside the class won't be supported.