public Settings getSettings()
{
try
{
SettingsBuilder settingsBuilder = new DefaultSettingsBuilderFactory().newInstance();
SettingsBuildingRequest settingsRequest = new DefaultSettingsBuildingRequest();
String userSettingsLocation = System.getProperty(ALT_USER_SETTINGS_XML_LOCATION);
// TeamCity sets the settings.xml in a different system property
String teamCitySettingsLocation = System.getProperty("teamcity.maven.userSettings.path");
if (userSettingsLocation != null)
{
settingsRequest.setUserSettingsFile(new File(userSettingsLocation));
}
else if (teamCitySettingsLocation != null)
{
settingsRequest.setUserSettingsFile(new File(teamCitySettingsLocation));
}
else
{
settingsRequest.setUserSettingsFile(new File(getUserHomeDir(), "/.m2/settings.xml"));
}
String globalSettingsLocation = System.getProperty(ALT_GLOBAL_SETTINGS_XML_LOCATION);
if (globalSettingsLocation != null)
{
settingsRequest.setGlobalSettingsFile(new File(globalSettingsLocation));
}
else
{
if (M2_HOME != null)
{
settingsRequest.setGlobalSettingsFile(new File(M2_HOME, "/conf/settings.xml"));
}
}
SettingsBuildingResult settingsBuildingResult = settingsBuilder.build(settingsRequest);
Settings effectiveSettings = settingsBuildingResult.getEffectiveSettings();
if (effectiveSettings.getLocalRepository() == null)
{
String userRepositoryLocation = System.getProperty(ALT_LOCAL_REPOSITORY_LOCATION);