This introduces the infrastructure for auto backporting source to java 8 compatibility code by using the rewrite library (https://github.com/openrewrite/). We introduce a custom rewrite plugin as the original rewrite plugin uses tons of deprecated api and non efficient gradle api. Also we introduce a rewrite task per project rewrite task makes error analysis easier IMO.
We have the configuration of the backporting in a rewrite.yml file that contains three types of backports
java.util.Map.of(...) to org.elasticsearch.core.Map(...)
java.util.List.of(...) to org.elasticsearch.core.List(...)
java.util.Set.of(...) to org.elasticsearch.core.Set(...)
The configuration uses custom rules I wrote (https://github.com/breskeby/java-recipes) as the build-in rewrite rules shipped or provided with rewrite do not provide proper handling of dealing with classes of the same name but different package. These rules are resolved from maven central.
An example of how all this backporting works in action can be seen in the functional test provided as part of this PR.