use of org.apache.maven.settings.building.SettingsBuildingRequest in project sts4 by spring-projects.
the class MavenBridge method buildSettings.
public Settings buildSettings(String globalSettings, String userSettings) throws MavenException {
SettingsBuildingRequest request = new DefaultSettingsBuildingRequest();
request.setGlobalSettingsFile(globalSettings != null ? new File(globalSettings) : null);
request.setUserSettingsFile(userSettings != null ? new File(userSettings) : SettingsXmlConfigurationProcessor.DEFAULT_USER_SETTINGS_FILE);
try {
return lookup(SettingsBuilder.class).build(request).getEffectiveSettings();
} catch (SettingsBuildingException ex) {
throw new MavenException(ex);
}
}
use of org.apache.maven.settings.building.SettingsBuildingRequest in project drools by kiegroup.
the class MavenEmbedder method getSettings.
public Settings getSettings() throws MavenEmbedderException, ComponentLookupException {
SettingsBuildingRequest settingsBuildingRequest = new DefaultSettingsBuildingRequest();
if (this.mavenRequest.getGlobalSettingsFile() != null) {
settingsBuildingRequest.setGlobalSettingsFile(new File(this.mavenRequest.getGlobalSettingsFile()));
} else {
settingsBuildingRequest.setGlobalSettingsFile(DEFAULT_GLOBAL_SETTINGS_FILE);
}
if (this.mavenRequest.getUserSettingsSource() != null) {
settingsBuildingRequest.setUserSettingsSource(this.mavenRequest.getUserSettingsSource());
} else {
SettingsSource userSettingsSource = MavenSettings.getUserSettingsSource();
if (userSettingsSource != null) {
settingsBuildingRequest.setUserSettingsSource(userSettingsSource);
}
}
settingsBuildingRequest.setUserProperties(this.mavenRequest.getUserProperties());
settingsBuildingRequest.getSystemProperties().putAll(System.getProperties());
settingsBuildingRequest.getSystemProperties().putAll(this.mavenRequest.getSystemProperties());
settingsBuildingRequest.getSystemProperties().putAll(getEnvVars());
try {
return componentProvider.lookup(SettingsBuilder.class).build(settingsBuildingRequest).getEffectiveSettings();
} catch (SettingsBuildingException e) {
throw new MavenEmbedderException(e.getMessage(), e);
}
}
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 intellij-plugins by JetBrains.
the class GeneratorServer method createSettings.
private Settings createSettings(MavenExecutionRequest mavenExecutionRequest) throws ComponentLookupException, SettingsBuildingException {
SettingsBuildingRequest request = new DefaultSettingsBuildingRequest();
request.setSystemProperties(request.getSystemProperties());
request.setGlobalSettingsFile(mavenExecutionRequest.getGlobalSettingsFile());
request.setUserSettingsFile(mavenExecutionRequest.getUserSettingsFile());
// IDEA-87004, getEffectiveSettings contains local repo as null, but our mavenExecutionRequest already has not-null local repo
Settings settings = plexusContainer.lookup(SettingsBuilder.class).build(request).getEffectiveSettings();
settings.setLocalRepository(mavenExecutionRequest.getLocalRepositoryPath().getPath());
return settings;
}
use of org.apache.maven.settings.building.SettingsBuildingRequest in project fabric8 by jboss-fuse.
the class MavenConfigurationImpl method buildSettings.
private Settings buildSettings(String localRepoPath, String settingsPath, boolean useFallbackRepositories) {
Settings settings;
if (settingsPath == null) {
settings = new Settings();
} else {
DefaultSettingsBuilderFactory factory = new DefaultSettingsBuilderFactory();
DefaultSettingsBuilder builder = factory.newInstance();
SettingsBuildingRequest request = new DefaultSettingsBuildingRequest();
request.setUserSettingsFile(new File(settingsPath));
try {
SettingsBuildingResult result = builder.build(request);
settings = result.getEffectiveSettings();
} catch (SettingsBuildingException exc) {
throw new AssertionError("cannot build settings", exc);
}
}
if (useFallbackRepositories) {
Profile fallbackProfile = new Profile();
Repository central = new Repository();
central.setId("central");
central.setUrl("http://repo1.maven.org/maven2");
fallbackProfile.setId("fallback");
fallbackProfile.setRepositories(Arrays.asList(central));
settings.addProfile(fallbackProfile);
settings.addActiveProfile("fallback");
}
if (localRepoPath != null) {
settings.setLocalRepository(localRepoPath);
}
return settings;
}
Aggregations