use of org.apache.maven.settings.building.SettingsBuildingRequest in project che by eclipse.
the class MavenServerImpl method getSettings.
private Settings getSettings(SettingsBuilder builder, MavenSettings settings, Properties systemProperties, Properties userProperties) throws RemoteException {
SettingsBuildingRequest request = new DefaultSettingsBuildingRequest();
request.setGlobalSettingsFile(settings.getGlobalSettings());
request.setUserSettingsFile(settings.getUserSettings());
request.setSystemProperties(systemProperties);
request.setUserProperties(userProperties);
Settings result = new Settings();
try {
result = builder.build(request).getEffectiveSettings();
} catch (SettingsBuildingException e) {
MavenServerContext.getLogger().info(e);
}
result.setOffline(settings.isOffline());
if (settings.getLocalRepository() != null) {
result.setLocalRepository(settings.getLocalRepository().getPath());
}
if (result.getLocalRepository() == null) {
result.setLocalRepository(new File(System.getProperty("user.home"), ".m2/repository").getPath());
}
return result;
}
use of org.apache.maven.settings.building.SettingsBuildingRequest in project intellij-community by JetBrains.
the class Maven30ServerEmbedderImpl method buildSettings.
private static Settings buildSettings(SettingsBuilder builder, MavenServerSettings settings, Properties systemProperties, Properties userProperties) throws RemoteException {
SettingsBuildingRequest settingsRequest = new DefaultSettingsBuildingRequest();
settingsRequest.setGlobalSettingsFile(settings.getGlobalSettingsFile());
settingsRequest.setUserSettingsFile(settings.getUserSettingsFile());
settingsRequest.setSystemProperties(systemProperties);
settingsRequest.setUserProperties(userProperties);
Settings result = new Settings();
try {
result = builder.build(settingsRequest).getEffectiveSettings();
} catch (SettingsBuildingException e) {
Maven3ServerGlobals.getLogger().info(e);
}
result.setOffline(settings.isOffline());
if (settings.getLocalRepository() != null) {
result.setLocalRepository(settings.getLocalRepository().getPath());
}
if (result.getLocalRepository() == null) {
result.setLocalRepository(new File(SystemProperties.getUserHome(), ".m2/repository").getPath());
}
return result;
}
use of org.apache.maven.settings.building.SettingsBuildingRequest in project karaf by apache.
the class MavenConfigurationSupport method readSettings.
/**
* Reads on demand <code>settings.xml</code> file - without password decryption. Also
* collects declared servers by ID.
* @param settingsFile
*/
protected synchronized Settings readSettings(File settingsFile) throws SettingsBuildingException {
if (!settingsFile.isFile() || !settingsFile.canRead()) {
return null;
}
try {
DefaultSettingsBuilderFactory factory = new DefaultSettingsBuilderFactory();
DefaultSettingsBuilder builder = factory.newInstance();
SettingsBuildingRequest request = new DefaultSettingsBuildingRequest();
request.setUserSettingsFile(settingsFile);
SettingsBuildingResult result = builder.build(request);
if (result.getProblems().size() > 0) {
for (SettingsProblem problem : result.getProblems()) {
System.err.println(problem);
}
return null;
} else {
Settings settings = result.getEffectiveSettings();
if (settings.getServers() != null) {
for (Server server : settings.getServers()) {
servers.put(server.getId(), server);
}
}
return settings;
}
} catch (Throwable e) {
System.err.println(e.getMessage());
LOG.error(e.getMessage(), e);
throw e;
}
}
use of org.apache.maven.settings.building.SettingsBuildingRequest in project spring-cloud-function by spring-cloud.
the class MavenSettingsReader method loadSettings.
private Settings loadSettings() {
File settingsFile = new File(this.homeDir, ".m2/settings.xml");
if (settingsFile.exists()) {
log.info("Reading settings from: " + settingsFile);
} else {
log.info("No settings found at: " + settingsFile);
}
SettingsBuildingRequest request = new DefaultSettingsBuildingRequest();
request.setUserSettingsFile(settingsFile);
request.setSystemProperties(System.getProperties());
try {
return new DefaultSettingsBuilderFactory().newInstance().build(request).getEffectiveSettings();
} catch (SettingsBuildingException ex) {
throw new IllegalStateException("Failed to build settings from " + settingsFile, ex);
}
}
use of org.apache.maven.settings.building.SettingsBuildingRequest in project spring-boot by spring-projects.
the class MavenSettingsReader method loadSettings.
private Settings loadSettings() {
File settingsFile = new File(this.homeDir, ".m2/settings.xml");
SettingsBuildingRequest request = new DefaultSettingsBuildingRequest();
request.setUserSettingsFile(settingsFile);
request.setSystemProperties(System.getProperties());
try {
return new DefaultSettingsBuilderFactory().newInstance().build(request).getEffectiveSettings();
} catch (SettingsBuildingException ex) {
throw new IllegalStateException("Failed to build settings from " + settingsFile, ex);
}
}
Aggregations