use of org.apache.maven.settings.building.DefaultSettingsBuildingRequest 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.DefaultSettingsBuildingRequest 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.DefaultSettingsBuildingRequest 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.DefaultSettingsBuildingRequest 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.DefaultSettingsBuildingRequest in project pom-manipulation-ext by release-engineering.
the class SettingsIO method update.
public void update(Settings settings, File settingsFile) throws ManipulationException {
try {
Settings defaultSettings = new Settings();
if (settingsFile.exists()) {
DefaultSettingsBuildingRequest settingsRequest = new DefaultSettingsBuildingRequest();
settingsRequest.setGlobalSettingsFile(settingsFile);
defaultSettings = settingsBuilder.build(settingsRequest).getEffectiveSettings();
}
for (Profile profile : settings.getProfiles()) {
Iterator<Profile> i = defaultSettings.getProfiles().iterator();
while (i.hasNext()) {
if (i.next().getId().equals(profile.getId())) {
i.remove();
}
}
defaultSettings.addProfile(profile);
}
for (String activeProfile : settings.getActiveProfiles()) {
Iterator<String> i = defaultSettings.getActiveProfiles().iterator();
while (i.hasNext()) {
if (i.next().equals(activeProfile)) {
i.remove();
}
}
defaultSettings.addActiveProfile(activeProfile);
}
for (Mirror mirror : settings.getMirrors()) {
defaultSettings.addMirror(mirror);
}
for (Proxy proxy : settings.getProxies()) {
defaultSettings.addProxy(proxy);
}
for (Server server : settings.getServers()) {
defaultSettings.addServer(server);
}
for (String pluginGroup : settings.getPluginGroups()) {
defaultSettings.addPluginGroup(pluginGroup);
}
if (settings.getLocalRepository() != null) {
defaultSettings.setLocalRepository(settings.getLocalRepository());
}
write(defaultSettings, settingsFile);
} catch (SettingsBuildingException e) {
throw new ManipulationException("Failed to build existing settings.xml for repo removal backup.", e, settingsFile, e.getMessage());
}
}
Aggregations