You can configure and maintain specific sets of configuration files for each environment in different folders under your project root. You can then extend the build process with a parameter to determine which environment it will be created for, so that it can copy the necessary configuration files to the deployment package. Then the deployed application sees the configuration files always in one place and has only one sequential set of files, which minimizes the likelihood of errors.
The disadvantage of this approach is potentially a lot of duplication between your configuration sets. This can be solved by creating specific configuration files as part of the build process. Extract all the configuration parameter variables into separate configuration properties files, one for each environment, and create a set of template configuration files that will contain placeholders instead, if the real parameters are in each applicable place. Then all you need is a preprocessor in your assembly, which creates a set of configuration files from the temples, replacing the placeholders with the corresponding specific values. (For example, Maven has built-in support for properties and profiles, as well as for generating resources at build time.)
source share