Can we change import in java class, ex:
import org.springframework.security.oauth2.client.OAuth2RestTemplate;
to
import org.springframework.web.client.RestTemplate;
We have one ChangePackage
recipe but it is only working with user predefine packages and ChangeText recipe is not sufficient to make all change related to any import change.
Do we have any dedicated recipe to change import statements ?
You'll want to use the Change Type recipe for such a change
type: specs.openrewrite.org/v1beta/recipe
name: com.yourorg.ChangeTypeExample
displayName: Change type example
recipeList:
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: org.springframework.security.oauth2.client.OAuth2RestTemplate
newFullyQualifiedTypeName: org.springframework.web.client.RestTemplate