openrewrite / rewrite-apache

OpenRewrite recipes for Apache projects.
Apache License 2.0
2 stars 5 forks source link

Migrate from Apache commons lang2 to lang3 #6

Open yeikel opened 2 years ago

yeikel commented 2 years ago

See https://commons.apache.org/proper/commons-lang/article3_0.html

I have seen this example in my projects :

import org.apache.commons.lang.StringUtils -> import org.apache.commons.lang3.StringUtils

But I am sure that there are many others

pway99 commented 2 years ago

from openrewrite/rewrite#1909

Teams often are using org.apache.commons.lang.StringUtils instead of org.apache.commons.lang3.StringUtils so I would like a recipe that migrates to commons-lang3.

I see the recipe as:

org.apache.commons.lang -> org.apache.commons.lang3
If commons-lang is present in the pom file, remove it.
If commons-lang3 is NOT present in the pom and/or dependency tree add it.
rdifrango commented 2 years ago

One note that StringEscapeUtils has been deprecated as of Lang 3.6 see:

https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/StringEscapeUtils.html

rdifrango commented 2 years ago

And a similar situation with org.apache.commons.lang3.text

https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/text/package-summary.html

timtebeek commented 1 year ago

Weekend-Tim has been having some fun and progress with migrating other/older StringUtils classes to Commons-Lang3; that work is currently at https://github.com/timtebeek/maven-rewrite/blob/main/src/main/resources/META-INF/rewrite/string-utils.yml Welcome to lift anything that you find valuable over to this project.