Skip to main content

Migrates to Apache Commons Collections 4.x

org.openrewrite.apache.commons.collections.UpgradeApacheCommonsCollections_3_4

Migrate applications to the latest Apache Commons Collections 4.x release. This recipe modifies application's build files, make changes to deprecated/preferred APIs, and migrates configuration settings that have changes between versions.

Tags​

Recipe source​

GitHub: apache-commons-collections-3-4.yml, Issue Tracker, Code Genome Project

Info

This recipe is composed of more than one recipe. If you want to customize the set of recipes this is composed of, you can find and copy the GitHub source for the recipe from the link above.

This recipe is available under the Moderne Source Available License. Moderne customers can download precompiled artifacts from The Code Genome Project. For non-commercial use you can build the artifact from source locally.

Definition​

  • Change Gradle or Maven dependency
    • oldGroupId: commons-collections
    • oldArtifactId: commons-collections
    • newGroupId: org.apache.commons
    • newArtifactId: commons-collections4
    • newVersion: 4.x
  • Add Gradle or Maven dependency
    • groupId: org.apache.commons
    • artifactId: commons-collections4
    • version: 4.x
    • onlyIfUsing: org.apache.commons.collections..*
    • acceptTransitive: true
  • Change type
    • oldFullyQualifiedTypeName: org.apache.commons.collections.map.IdentityMap
    • newFullyQualifiedTypeName: java.util.IdentityHashMap
  • Delete method argument
    • methodPattern: org.apache.commons.collections.FastArrayList <constructor>(int)
    • argumentIndex: 0
  • Remove method invocations
    • methodPattern: org.apache.commons.collections.FastArrayList setFast(boolean)
  • Change type
    • oldFullyQualifiedTypeName: org.apache.commons.collections.FastArrayList
    • newFullyQualifiedTypeName: java.util.concurrent.CopyOnWriteArrayList
  • Change static field access to static method access
    • oldClassName: org.apache.commons.collections.MapUtils
    • oldFieldName: EMPTY_MAP
    • newClassName: java.util.Collections
    • newMethodName: emptyMap
  • Change static field access to static method access
    • oldClassName: org.apache.commons.collections.ListUtils
    • oldFieldName: EMPTY_LIST
    • newClassName: java.util.Collections
    • newMethodName: emptyList
  • Change static field access to static method access
    • oldClassName: org.apache.commons.collections.SetUtils
    • oldFieldName: EMPTY_SET
    • newClassName: java.util.Collections
    • newMethodName: emptySet
  • Change method name
    • methodPattern: org.apache.commons.collections.OrderedMap orderedMapIterator()
    • newMethodName: mapIterator
    • matchOverrides: true
  • Change method name
    • methodPattern: org.apache.commons.collections.OrderedBidiMap inverseOrderedBidiMap()
    • newMethodName: inverseBidiMap
    • matchOverrides: true
  • Replace constant with another constant
    • existingFullyQualifiedConstantName: org.apache.commons.collections.map.AbstractReferenceMap.HARD
    • fullyQualifiedConstantName: org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceStrength.HARD
  • Replace constant with another constant
    • existingFullyQualifiedConstantName: org.apache.commons.collections.map.AbstractReferenceMap.SOFT
    • fullyQualifiedConstantName: org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceStrength.SOFT
  • Replace constant with another constant
    • existingFullyQualifiedConstantName: org.apache.commons.collections.map.AbstractReferenceMap.WEAK
    • fullyQualifiedConstantName: org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceStrength.WEAK
  • Replace constant with another constant
    • existingFullyQualifiedConstantName: org.apache.commons.collections.ReferenceMap.HARD
    • fullyQualifiedConstantName: org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceStrength.HARD
  • Replace constant with another constant
    • existingFullyQualifiedConstantName: org.apache.commons.collections.ReferenceMap.SOFT
    • fullyQualifiedConstantName: org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceStrength.SOFT
  • Replace constant with another constant
    • existingFullyQualifiedConstantName: org.apache.commons.collections.ReferenceMap.WEAK
    • fullyQualifiedConstantName: org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceStrength.WEAK
  • Change method name
    • methodPattern: org.apache.commons.collections.set.SynchronizedSet decorate(java.util.Set)
    • newMethodName: synchronizedSet
  • Change method target to static
    • methodPattern: org.apache.commons.collections.set.SynchronizedSet synchronizedSet(java.util.Set)
    • fullyQualifiedTargetTypeName: java.util.Collections
  • Change method name
    • methodPattern: org.apache.commons.collections.set.SynchronizedSortedSet decorate(java.util.SortedSet)
    • newMethodName: synchronizedSortedSet
  • Change method target to static
    • methodPattern: org.apache.commons.collections.set.SynchronizedSortedSet synchronizedSortedSet(java.util.SortedSet)
    • fullyQualifiedTargetTypeName: java.util.Collections
  • Change method name
    • methodPattern: org.apache.commons.collections.list.SynchronizedList decorate(java.util.List)
    • newMethodName: synchronizedList
  • Change method target to static
    • methodPattern: org.apache.commons.collections.list.SynchronizedList synchronizedList(java.util.List)
    • fullyQualifiedTargetTypeName: java.util.Collections
  • Change method name
    • methodPattern: org.apache.commons.collections.bag.PredicatedBag decorate(..)
    • newMethodName: predicatedBag
  • Change method name
    • methodPattern: org.apache.commons.collections.bag.PredicatedSortedBag decorate(..)
    • newMethodName: predicatedSortedBag
  • Change method name
    • methodPattern: org.apache.commons.collections.bag.SynchronizedBag decorate(..)
    • newMethodName: synchronizedBag
  • Change method name
    • methodPattern: org.apache.commons.collections.bag.SynchronizedSortedBag decorate(..)
    • newMethodName: synchronizedSortedBag
  • Change method name
    • methodPattern: org.apache.commons.collections.bag.TransformedBag decorate(..)
    • newMethodName: transformingBag
  • Change method name
    • methodPattern: org.apache.commons.collections.bag.TransformedSortedBag decorate(..)
    • newMethodName: transformingSortedBag
  • Change method name
    • methodPattern: org.apache.commons.collections.bag.UnmodifiableBag decorate(..)
    • newMethodName: unmodifiableBag
  • Change method name
    • methodPattern: org.apache.commons.collections.bag.UnmodifiableSortedBag decorate(..)
    • newMethodName: unmodifiableSortedBag
  • Change method name
    • methodPattern: org.apache.commons.collections.bidimap.UnmodifiableBidiMap decorate(..)
    • newMethodName: unmodifiableBidiMap
  • Change method name
    • methodPattern: org.apache.commons.collections.bidimap.UnmodifiableOrderedBidiMap decorate(..)
    • newMethodName: unmodifiableOrderedBidiMap
  • Change method name
    • methodPattern: org.apache.commons.collections.bidimap.UnmodifiableSortedBidiMap decorate(..)
    • newMethodName: unmodifiableSortedBidiMap
  • Change method name
    • methodPattern: org.apache.commons.collections.collection.PredicatedCollection decorate(..)
    • newMethodName: predicatedCollection
  • Change method name
    • methodPattern: org.apache.commons.collections.collection.SynchronizedCollection decorate(..)
    • newMethodName: synchronizedCollection
  • Change method name
    • methodPattern: org.apache.commons.collections.collection.TransformedCollection decorate(..)
    • newMethodName: transformingCollection
  • Change method name
    • methodPattern: org.apache.commons.collections.collection.UnmodifiableBoundedCollection decorate(..)
    • newMethodName: unmodifiableBoundedCollection
  • Change method name
    • methodPattern: org.apache.commons.collections.collection.UnmodifiableCollection decorate(..)
    • newMethodName: unmodifiableCollection
  • Change method name
    • methodPattern: org.apache.commons.collections.comparators.ComparableComparator getInstance(..)
    • newMethodName: comparableComparator
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.AllPredicate getInstance(..)
    • newMethodName: allPredicate
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.AndPredicate getInstance(..)
    • newMethodName: andPredicate
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.AnyPredicate getInstance(..)
    • newMethodName: anyPredicate
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.ChainedClosure getInstance(..)
    • newMethodName: chainedClosure
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.ChainedTransformer getInstance(..)
    • newMethodName: chainedTransformer
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.CloneTransformer getInstance(..)
    • newMethodName: cloneTransformer
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.ClosureTransformer getInstance(..)
    • newMethodName: closureTransformer
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.ConstantFactory getInstance(..)
    • newMethodName: constantFactory
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.ConstantTransformer getInstance(..)
    • newMethodName: constantTransformer
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.EqualPredicate getInstance(..)
    • newMethodName: equalPredicate
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.ExceptionClosure getInstance(..)
    • newMethodName: exceptionClosure
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.ExceptionFactory getInstance(..)
    • newMethodName: exceptionFactory
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.ExceptionPredicate getInstance(..)
    • newMethodName: exceptionPredicate
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.ExceptionTransformer getInstance(..)
    • newMethodName: exceptionTransformer
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.FactoryTransformer getInstance(..)
    • newMethodName: factoryTransformer
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.FalsePredicate getInstance(..)
    • newMethodName: falsePredicate
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.ForClosure getInstance(..)
    • newMethodName: forClosure
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.IdentityPredicate getInstance(..)
    • newMethodName: identityPredicate
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.IfClosure getInstance(..)
    • newMethodName: ifClosure
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.InstanceofPredicate getInstance(..)
    • newMethodName: instanceOfPredicate
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.InstantiateFactory getInstance(..)
    • newMethodName: instantiateFactory
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.InstantiateTransformer getInstance(..)
    • newMethodName: instantiateTransformer
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.InvokerTransformer getInstance(..)
    • newMethodName: invokerTransformer
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.MapTransformer getInstance(..)
    • newMethodName: mapTransformer
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.NOPClosure getInstance(..)
    • newMethodName: nopClosure
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.NOPTransformer getInstance(..)
    • newMethodName: nopTransformer
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.NonePredicate getInstance(..)
    • newMethodName: nonePredicate
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.NotNullPredicate getInstance(..)
    • newMethodName: notNullPredicate
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.NotPredicate getInstance(..)
    • newMethodName: notPredicate
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.NullIsExceptionPredicate getInstance(..)
    • newMethodName: nullIsExceptionPredicate
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.NullIsFalsePredicate getInstance(..)
    • newMethodName: nullIsFalsePredicate
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.NullIsTruePredicate getInstance(..)
    • newMethodName: nullIsTruePredicate
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.NullPredicate getInstance(..)
    • newMethodName: nullPredicate
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.OnePredicate getInstance(..)
    • newMethodName: onePredicate
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.OrPredicate getInstance(..)
    • newMethodName: orPredicate
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.PredicateTransformer getInstance(..)
    • newMethodName: predicateTransformer
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.PrototypeFactory getInstance(..)
    • newMethodName: prototypeFactory
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.StringValueTransformer getInstance(..)
    • newMethodName: stringValueTransformer
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.SwitchClosure getInstance(..)
    • newMethodName: switchClosure
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.SwitchTransformer getInstance(..)
    • newMethodName: switchTransformer
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.TransformedPredicate getInstance(..)
    • newMethodName: transformedPredicate
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.TransformerClosure getInstance(..)
    • newMethodName: transformerClosure
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.TransformerPredicate getInstance(..)
    • newMethodName: transformerPredicate
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.TruePredicate getInstance(..)
    • newMethodName: truePredicate
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.UniquePredicate getInstance(..)
    • newMethodName: uniquePredicate
  • Change method name
    • methodPattern: org.apache.commons.collections.functors.WhileClosure getInstance(..)
    • newMethodName: whileClosure
  • Change method name
    • methodPattern: org.apache.commons.collections.iterators.UnmodifiableIterator decorate(..)
    • newMethodName: unmodifiableIterator
  • Change method name
    • methodPattern: org.apache.commons.collections.iterators.UnmodifiableListIterator decorate(..)
    • newMethodName: unmodifiableListIterator
  • Change method name
    • methodPattern: org.apache.commons.collections.iterators.UnmodifiableMapIterator decorate(..)
    • newMethodName: unmodifiableMapIterator
  • Change method name
    • methodPattern: org.apache.commons.collections.iterators.UnmodifiableOrderedMapIterator decorate(..)
    • newMethodName: unmodifiableOrderedMapIterator
  • Change method name
    • methodPattern: org.apache.commons.collections.list.FixedSizeList decorate(..)
    • newMethodName: fixedSizeList
  • Change method name
    • methodPattern: org.apache.commons.collections.list.GrowthList decorate(..)
    • newMethodName: growthList
  • Change method name
    • methodPattern: org.apache.commons.collections.list.LazyList decorate(..)
    • newMethodName: lazyList
  • Change method name
    • methodPattern: org.apache.commons.collections.list.PredicatedList decorate(..)
    • newMethodName: predicatedList
  • Change method name
    • methodPattern: org.apache.commons.collections.list.SetUniqueList decorate(..)
    • newMethodName: setUniqueList
  • Change method name
    • methodPattern: org.apache.commons.collections.list.TransformedList decorate(..)
    • newMethodName: transformingList
  • Change method name
    • methodPattern: org.apache.commons.collections.list.UnmodifiableList decorate(..)
    • newMethodName: unmodifiableList
  • Change method name
    • methodPattern: org.apache.commons.collections.map.DefaultedMap decorate(..)
    • newMethodName: defaultedMap
  • Change method name
    • methodPattern: org.apache.commons.collections.map.FixedSizeMap decorate(..)
    • newMethodName: fixedSizeMap
  • Change method name
    • methodPattern: org.apache.commons.collections.map.FixedSizeSortedMap decorate(..)
    • newMethodName: fixedSizeSortedMap
  • Change method name
    • methodPattern: org.apache.commons.collections.map.LazyMap decorate(..)
    • newMethodName: lazyMap
  • Change method name
    • methodPattern: org.apache.commons.collections.map.LazySortedMap decorate(..)
    • newMethodName: lazySortedMap
  • Change method name
    • methodPattern: org.apache.commons.collections.map.ListOrderedMap decorate(..)
    • newMethodName: listOrderedMap
  • Change method name
    • methodPattern: org.apache.commons.collections.map.MultiKeyMap decorate(..)
    • newMethodName: multiKeyMap
  • Change method name
    • methodPattern: org.apache.commons.collections.map.MultiValueMap decorate(..)
    • newMethodName: multiValueMap
  • Change method name
    • methodPattern: org.apache.commons.collections.map.PredicatedMap decorate(..)
    • newMethodName: predicatedMap
  • Change method name
    • methodPattern: org.apache.commons.collections.map.PredicatedSortedMap decorate(..)
    • newMethodName: predicatedSortedMap
  • Change method name
    • methodPattern: org.apache.commons.collections.map.TransformedMap decorate(..)
    • newMethodName: transformingMap
  • Change method name
    • methodPattern: org.apache.commons.collections.map.TransformedMap decorateTransform(..)
    • newMethodName: transformedMap
  • Change method name
    • methodPattern: org.apache.commons.collections.map.TransformedSortedMap decorate(..)
    • newMethodName: transformingSortedMap
  • Change method name
    • methodPattern: org.apache.commons.collections.map.TransformedSortedMap decorateTransform(..)
    • newMethodName: transformedSortedMap
  • Change method name
    • methodPattern: org.apache.commons.collections.map.UnmodifiableEntrySet decorate(..)
    • newMethodName: unmodifiableEntrySet
  • Change method name
    • methodPattern: org.apache.commons.collections.map.UnmodifiableMap decorate(..)
    • newMethodName: unmodifiableMap
  • Change method name
    • methodPattern: org.apache.commons.collections.map.UnmodifiableOrderedMap decorate(..)
    • newMethodName: unmodifiableOrderedMap
  • Change method name
    • methodPattern: org.apache.commons.collections.map.UnmodifiableSortedMap decorate(..)
    • newMethodName: unmodifiableSortedMap
  • Change method name
    • methodPattern: org.apache.commons.collections.set.ListOrderedSet decorate(..)
    • newMethodName: listOrderedSet
  • Change method name
    • methodPattern: org.apache.commons.collections.set.MapBackedSet decorate(..)
    • newMethodName: mapBackedSet
  • Change method name
    • methodPattern: org.apache.commons.collections.set.PredicatedSet decorate(..)
    • newMethodName: predicatedSet
  • Change method name
    • methodPattern: org.apache.commons.collections.set.PredicatedSortedSet decorate(..)
    • newMethodName: predicatedSortedSet
  • Change method name
    • methodPattern: org.apache.commons.collections.set.TransformedSet decorate(..)
    • newMethodName: transformingSet
  • Change method name
    • methodPattern: org.apache.commons.collections.set.TransformedSortedSet decorate(..)
    • newMethodName: transformingSortedSet
  • Change method name
    • methodPattern: org.apache.commons.collections.set.UnmodifiableSet decorate(..)
    • newMethodName: unmodifiableSet
  • Change method name
    • methodPattern: org.apache.commons.collections.set.UnmodifiableSortedSet decorate(..)
    • newMethodName: unmodifiableSortedSet
  • Change type
    • oldFullyQualifiedTypeName: org.apache.commons.collections.DefaultMapEntry
    • newFullyQualifiedTypeName: org.apache.commons.collections4.keyvalue.DefaultMapEntry
  • Change type
    • oldFullyQualifiedTypeName: org.apache.commons.collections.HashBag
    • newFullyQualifiedTypeName: org.apache.commons.collections4.bag.HashBag
  • Change type
    • oldFullyQualifiedTypeName: org.apache.commons.collections.ReferenceMap
    • newFullyQualifiedTypeName: org.apache.commons.collections4.map.ReferenceMap
  • Change type
    • oldFullyQualifiedTypeName: org.apache.commons.collections.StaticBucketMap
    • newFullyQualifiedTypeName: org.apache.commons.collections4.map.StaticBucketMap
  • Change type
    • oldFullyQualifiedTypeName: org.apache.commons.collections.TreeBag
    • newFullyQualifiedTypeName: org.apache.commons.collections4.bag.TreeBag
  • Rename package name
    • oldPackageName: org.apache.commons.collections
    • newPackageName: org.apache.commons.collections4
    • recursive: true

Used by​

This recipe is used as part of the following composite recipes:

Examples​

Example 1​

UpgradeApacheCommonsCollections_3_4Test#apacheCommonsCollections

Before​
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.map.IdentityMap;
import org.apache.commons.collections.ListUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.collections.FastArrayList;

import java.util.List;
import java.util.Map;

class Test {
static void helloApacheCollections() {
Object[] input = new Object[] { "one", "two" };
CollectionUtils.reverseArray(input);
IdentityMap identityMap = new IdentityMap();
Map emptyMap = MapUtils.EMPTY_MAP;
FastArrayList fastList = new FastArrayList(100);
List emptyList = ListUtils.EMPTY_LIST;
}
}
After​
import org.apache.commons.collections4.CollectionUtils;

import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;

class Test {
static void helloApacheCollections() {
Object[] input = new Object[] { "one", "two" };
CollectionUtils.reverseArray(input);
IdentityHashMap identityMap = new IdentityHashMap();
Map emptyMap = Collections.emptyMap();
CopyOnWriteArrayList fastList = new CopyOnWriteArrayList(100);
List emptyList = Collections.emptyList();
}
}

Example 2​

UpgradeApacheCommonsCollections_3_4Test#apacheCommonsCollections

Before​
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.map.IdentityMap;
import org.apache.commons.collections.ListUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.collections.FastArrayList;

import java.util.List;
import java.util.Map;

class Test {
static void helloApacheCollections() {
Object[] input = new Object[] { "one", "two" };
CollectionUtils.reverseArray(input);
IdentityMap identityMap = new IdentityMap();
Map emptyMap = MapUtils.EMPTY_MAP;
FastArrayList fastList = new FastArrayList(100);
List emptyList = ListUtils.EMPTY_LIST;
}
}
After​
import org.apache.commons.collections4.CollectionUtils;

import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;

class Test {
static void helloApacheCollections() {
Object[] input = new Object[] { "one", "two" };
CollectionUtils.reverseArray(input);
IdentityHashMap identityMap = new IdentityHashMap();
Map emptyMap = Collections.emptyMap();
CopyOnWriteArrayList fastList = new CopyOnWriteArrayList(100);
List emptyList = Collections.emptyList();
}
}

Usage​

This recipe has no required configuration options. It can be activated by adding a dependency on `org.openrewrite.recipe:rewrite-apache` in your build file or by running a shell command (in which case no build changes are needed):

OpenRewrite artifacts, including the Maven and Gradle plugins themselves, are distributed through the Code Genome Project repository (https://artifacts.codegenomeproject.org/maven), which requires authentication. Sign in to the Code Genome Project to create a download token; your build authenticates with the email or username you signed in with, plus that token as the password. See the quickstart guide for details.

  1. Put your Code Genome Project credentials in ~/.gradle/gradle.properties, so that they are not committed alongside your build:
    ~/.gradle/gradle.properties
    codegenomeUsername=you@example.com
    codegenomePassword=your-download-token
  2. Add the Code Genome Project repository to your settings.gradle file, so that the plugin itself can be resolved:
    settings.gradle
    pluginManagement {
    repositories {
    maven {
    url = "https://artifacts.codegenomeproject.org/maven"
    credentials {
    username = providers.gradleProperty("codegenomeUsername").get()
    password = providers.gradleProperty("codegenomePassword").get()
    }
    }
    // Keep the portal for any other plugins your build applies
    gradlePluginPortal()
    }
    }
  3. Add the following to your build.gradle file:
    build.gradle
    plugins {
    id("org.openrewrite.rewrite") version("latest.release")
    }

    rewrite {
    activeRecipe("org.openrewrite.apache.commons.collections.UpgradeApacheCommonsCollections_3_4")
    setExportDatatables(true)
    }

    repositories {
    mavenCentral()
    maven {
    url = "https://artifacts.codegenomeproject.org/maven"
    credentials {
    username = providers.gradleProperty("codegenomeUsername").get()
    password = providers.gradleProperty("codegenomePassword").get()
    }
    }
    }

    dependencies {
    rewrite("org.openrewrite.recipe:rewrite-apache:2.34.0")
    }
  4. Run gradle rewriteRun to run the recipe.

See how this recipe works across multiple open-source repositories​

Run this recipe on OSS repos at scale with the Moderne SaaS.

The community edition of the Moderne platform enables you to easily run recipes across thousands of open-source repositories.

Please contact Moderne for more information about safely running the recipes on your own codebase in a private SaaS.

Data Tables​

Source files that had results​

org.openrewrite.table.SourcesFileResults

Source files that were modified by the recipe run.

Column NameDescription
Source path before the runThe source path of the file before the run. null when a source file was created during the run.
Source path after the runA recipe may modify the source path. This is the path after the run. null when a source file was deleted during the run.
Parent of the recipe that made changesIn a hierarchical recipe, the parent of the recipe that made a change. Empty if this is the root of a hierarchy or if the recipe is not hierarchical at all.
Recipe that made changesThe specific recipe that made a change.
Estimated time savingAn estimated effort that a developer to fix manually instead of using this recipe, in unit of seconds.
CycleThe recipe cycle in which the change was made.