org.apache.maven.settings.building.DefaultSettingsBuilder Java Examples
The following examples show how to use
org.apache.maven.settings.building.DefaultSettingsBuilder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Utils.java From gate-core with GNU Lesser General Public License v3.0 | 6 votes |
public static Settings loadMavenSettings() throws SettingsBuildingException { // http://stackoverflow.com/questions/27818659/loading-mavens-settings-xml-for-jcabi-aether-to-use SettingsBuildingRequest settingsBuildingRequest = new DefaultSettingsBuildingRequest(); settingsBuildingRequest.setSystemProperties(System.getProperties()); settingsBuildingRequest.setUserSettingsFile(new File(settingsXml)); settingsBuildingRequest.setGlobalSettingsFile(DEFAULT_GLOBAL_SETTINGS_FILE); SettingsBuildingResult settingsBuildingResult; DefaultSettingsBuilderFactory mvnSettingBuilderFactory = new DefaultSettingsBuilderFactory(); DefaultSettingsBuilder settingsBuilder = mvnSettingBuilderFactory.newInstance(); settingsBuildingResult = settingsBuilder.build(settingsBuildingRequest); Settings effectiveSettings = settingsBuildingResult.getEffectiveSettings(); return effectiveSettings; }
Example #2
Source File: MavenPluginRepository.java From BIMserver with GNU Affero General Public License v3.0 | 6 votes |
private Settings loadDefaultUserSettings() { String userHome = System.getProperty("user.home"); File userMavenConfigurationHome = new File(userHome, ".m2"); String envM2Home = System.getenv("M2_HOME"); File DEFAULT_USER_SETTINGS_FILE = new File(userMavenConfigurationHome, "settings.xml"); File DEFAULT_GLOBAL_SETTINGS_FILE = new File(System.getProperty("maven.home", envM2Home != null ? envM2Home : ""), "conf/settings.xml"); SettingsBuildingRequest settingsBuildingRequest = new DefaultSettingsBuildingRequest(); settingsBuildingRequest.setSystemProperties(System.getProperties()); settingsBuildingRequest.setUserSettingsFile(DEFAULT_USER_SETTINGS_FILE); settingsBuildingRequest.setGlobalSettingsFile(DEFAULT_GLOBAL_SETTINGS_FILE); DefaultSettingsBuilderFactory mvnSettingBuilderFactory = new DefaultSettingsBuilderFactory(); DefaultSettingsBuilder settingsBuilder = mvnSettingBuilderFactory.newInstance(); try { SettingsBuildingResult settingsBuildingResult = settingsBuilder.build(settingsBuildingRequest); Settings settings = settingsBuildingResult.getEffectiveSettings(); return settings; } catch (SettingsBuildingException e) { e.printStackTrace(); } return null; }
Example #3
Source File: MavenMvnSettings.java From galleon with Apache License 2.0 | 5 votes |
private static Settings buildMavenSettings(Path settingsPath) throws ArtifactException { SettingsBuildingRequest settingsBuildingRequest = new DefaultSettingsBuildingRequest(); settingsBuildingRequest.setSystemProperties(System.getProperties()); settingsBuildingRequest.setUserSettingsFile(settingsPath.toFile()); SettingsBuildingResult settingsBuildingResult; DefaultSettingsBuilderFactory mvnSettingBuilderFactory = new DefaultSettingsBuilderFactory(); DefaultSettingsBuilder settingsBuilder = mvnSettingBuilderFactory.newInstance(); try { settingsBuildingResult = settingsBuilder.build(settingsBuildingRequest); } catch (SettingsBuildingException ex) { throw new ArtifactException(ex.getLocalizedMessage()); } return settingsBuildingResult.getEffectiveSettings(); }
Example #4
Source File: MavenDependencyUtil.java From DevToolBox with GNU Lesser General Public License v2.1 | 5 votes |
/** * maven仓库处理 * * @return * @throws Exception */ private static ArtifactRepository localRepository() throws Exception { if (mavenHome == null) { getMavenHome(); } SettingsBuildingRequest request = new DefaultSettingsBuildingRequest(); request.setGlobalSettingsFile(new File(mavenHome, "/conf/settings.xml")); DefaultSettingsBuilder builder = new DefaultSettingsBuilderFactory().newInstance(); SettingsBuildingResult ret = builder.build(request); String path = ret.getEffectiveSettings().getLocalRepository(); path = path == null ? String.format("%s%s", System.getProperty("user.home"), "\\.m2\\repository") : path; return FACTORY.createArtifactRepository("local", "file://" + path, (ArtifactRepositoryLayout) new DefaultRepositoryLayout(), null, null); }