Migrate Commons Configuration 1.x file handling to 2.x
MSALConfiguration 2 creates a file-based configuration with a FileBasedConfigurationBuilder, and loads, saves and locates it with a FileHandler, where 1.x did all of that in the configuration. This replaces the 1.x constructors that took a file name, File or URL with a builder, and the load, save and file location methods with those of a FileHandler. A local variable that is saved or asked for its file keeps the builder or FileHandler in a variable of its own, so that it is saved where it was loaded from. A subclass constructor that had its superclass load a file loads it with a FileHandler of its own. Configurations created from a file, or created empty in a statement of their own, are given a DefaultListDelimiterHandler(','), as 1.x split values at commas by default and 2.x does not. The location of a configuration held in a field is not known where it is used, so a save() without arguments, or a question for its file, on a field is left to be migrated by hand, and so is the list delimiter of one created empty in a field's initializer. This recipe matches the 1.x API by the names the move to the org.apache.commons.configuration2 package gives it, and is meant to run as part of UpgradeApacheCommonsConfiguration_1_2.
org. openrewrite. apache. commons. configuration. MigrateFileBasedConfigurationsmod run . --recipe= org. openrewrite. apache. commons. configuration. MigrateFileBasedConfigurationsInstall it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.