Quick Script for Switching Maven Settings,
Or Any Settings
Sometimes I’m on several projects with differing and complicated configs for Maven, and use a few different Eclipse/IDE installs to manage all the preferences between the projects. With many different leads can be different Check Style files, PMD rules sets, formatting rules, naming conventions etc. Why not just the same standards universally? Well, different projects need different things and have different people.
For just the Maven environments, here is a simple Windows batch script I use to switch up the settings. Assuming there are two complicated settings.xml files, it prompts for either and copies onto the file name “settings.xml” in your .M2 directory.
@echo off &setlocal :COMMANDLOOP echo. echo 1 = Maven settings for Project 1 echo 2 = Maven settings for Project 2 set "TEMPCMD=%CD%" set /P "TEMPCMD=%CD% :" IF "%TEMPCMD%"=="1" ( del settings.xml copy settings-1.xml settings.xml ECHO "settings for Project 1 complete" ) ELSE If "%TEMPCMD%"=="2" ( del settings.xml copy settings-2.xml settings.xml ECHO "settings for Project 2 complete" ) ELSE ( echo "Please enter 1 or 2. Try again." GOTO COMMANDLOOP ) pause