Non-deterministic ordering for annotations in generated AutoValue_ classes
ZacSweers opened this issue · 1 comments
ZacSweers commented
A sporadic issue we're encountering in our project is that generated AutoValue_
classes appear to have non-deterministic annotations ordering. This results in recompilations in Gradle builds.
Here's an example based on the screenshot above, from our codebase. This uses autovalue + the auto-value-moshi extension. It doesn't seem annotation-specific, both @Nullable
and @Json
appear in different orders at times
public interface SearchFilters {
@Nullable
@Json(name = "from")
List<String> getFromFilters();
@Nullable
@Json(name = "after")
String getAfterFilter();
@Nullable
@Json(name = "before")
String getBeforeFilter();
@Nullable
@Json(name = "rxn")
List<String> getReactionsFilters();
}
@JsonClass(generateAdapter = true, generator = "avm")
@AutoValue
abstract class SearchFiltersAV implements SearchFilters {}
It seems like the appropriate solution would be to sort annotations in generation, since order doesn't matter for functionality but does confuse systems using file watching for incremental compilation.
ZacSweers commented
Thanks for the quick turnaround!