mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-22 06:07:55 -04:00
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.
35 lines
No EOL
1.4 KiB
YAML
35 lines
No EOL
1.4 KiB
YAML
type: specs.openrewrite.org/v1beta/recipe
|
|
name: org.elasticsearch.java.backport.ListOfBackport
|
|
displayName: Use `org.elasticsearch.core.Lists#of(..)` not java.util.List.of#(..)
|
|
description: Java 8 does not support the `java.util.List#of(..)`.
|
|
tags:
|
|
- backport
|
|
recipeList:
|
|
- org.elasticsearch.gradle.internal.rewrite.rules.ChangeMethodOwnerRecipe:
|
|
originFullQualifiedClassname: java.util.List
|
|
targetFullQualifiedClassname: org.elasticsearch.core.List
|
|
methodName: of
|
|
---
|
|
type: specs.openrewrite.org/v1beta/recipe
|
|
name: org.elasticsearch.java.backport.MapOfBackport
|
|
displayName: Use `org.elasticsearch.core.Maps#of(..)` not java.util.Map.of#(..)
|
|
description: Java 8 does not support the `java.util.Map#of(..)`.
|
|
tags:
|
|
- backport
|
|
recipeList:
|
|
- org.elasticsearch.gradle.internal.rewrite.rules.ChangeMethodOwnerRecipe:
|
|
originFullQualifiedClassname: java.util.Map
|
|
targetFullQualifiedClassname: org.elasticsearch.core.Map
|
|
methodName: of
|
|
---
|
|
type: specs.openrewrite.org/v1beta/recipe
|
|
name: org.elasticsearch.java.backport.SetOfBackport
|
|
displayName: Use `org.elasticsearch.core.Sets#of(..)` not java.util.Set.of#(..)
|
|
description: Java 8 does not support the `java.util.Set#of(..)`.
|
|
tags:
|
|
- backport
|
|
recipeList:
|
|
- org.elasticsearch.gradle.internal.rewrite.rules.ChangeMethodOwnerRecipe:
|
|
originFullQualifiedClassname: java.util.Set
|
|
targetFullQualifiedClassname: org.elasticsearch.core.Set
|
|
methodName: of |