Apache Commons best practices

MSAL

Apply best practices to code that uses Apache Commons libraries: migrate off the end-of-life Commons Lang 2.x, Commons Collections 3.x and Commons Math 2.x major versions, correct the commons-io coordinates, replace deprecated APIs with their supported replacements, make character encodings explicit, and prefer the Java standard library where it now offers an equivalent.

org.openrewrite.apache.commons.ApacheCommonsBestPractices
mod run . --recipe=org.openrewrite.apache.commons.ApacheCommonsBestPractices

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.

Recipe list

It runs these recipes, in this order.

  1. Migrates to Apache Commons Collections 4.x
  2. Replace CollectionUtils.cardinality with IterableUtils.frequency
  3. Migrates to Apache Commons Lang 3.x
  4. Migrates to Apache Commons Math 3.x
  5. Relocate org.apache.commons:commons-io to commons-io:commons-io
  6. Use IOUtils method that include their charset encoding
  7. Migrate deprecated SystemUtils constants
  8. Prefer the Java standard library instead of Apache Commons