org.apache.maven.settings.building.SettingsBuilder Java Examples
The following examples show how to use
org.apache.maven.settings.building.SettingsBuilder.
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: MavenRepositoriesTest.java From furnace with Eclipse Public License 1.0 | 6 votes |
@Test public void testCentralWithProfiles() throws Exception { SettingsBuilder settingsBuilder = new DefaultSettingsBuilderFactory().newInstance(); SettingsBuildingRequest settingsRequest = new DefaultSettingsBuildingRequest(); settingsRequest.setUserSettingsFile(new File("src/test/resources/profiles/settings.xml")); Settings settings = settingsBuilder.build(settingsRequest).getEffectiveSettings(); MavenContainer container = new MavenContainer(); List<RemoteRepository> remoteRepositories = MavenRepositories.getRemoteRepositories(container, settings); Assert.assertEquals(2, remoteRepositories.size()); Assert.assertEquals("test-repository", remoteRepositories.get(1).getId()); List<RemoteRepository> centralRepos = remoteRepositories.stream().filter(repo -> repo.getId().equals("central")).collect(Collectors.toList()); Assert.assertEquals(1, centralRepos.size()); Assert.assertEquals(MavenRepositories.MAVEN_CENTRAL_REPO, centralRepos.get(0).getUrl()); }
Example #2
Source File: ConfigurationHelperTest.java From LicenseScout with Apache License 2.0 | 5 votes |
/** * Creates a settings instance for testing. * @return a settings instance * @throws SettingsBuildingException */ private Settings createSettings() throws SettingsBuildingException { DefaultSettingsBuilderFactory settingsBuilderFactory = new DefaultSettingsBuilderFactory(); SettingsBuilder settingsBuilder = settingsBuilderFactory.newInstance(); DefaultSettingsBuildingRequest request = new DefaultSettingsBuildingRequest(); final File userSettingsFile = new File("src/test/resources/ConfigurationHelperTest/settings.xml"); request.setUserSettingsFile(userSettingsFile); SettingsBuildingResult settingsBuildingResult = settingsBuilder.build(request); return settingsBuildingResult.getEffectiveSettings(); }
Example #3
Source File: MavenEmbedder.java From netbeans with Apache License 2.0 | 5 votes |
MavenEmbedder(EmbedderConfiguration configuration) throws ComponentLookupException { embedderConfiguration = configuration; plexus = configuration.getContainer(); this.maven = (DefaultMaven) plexus.lookup(Maven.class); this.projectBuilder = plexus.lookup(ProjectBuilder.class); this.repositorySystem = plexus.lookup(RepositorySystem.class); this.settingsBuilder = plexus.lookup(SettingsBuilder.class); this.populator = plexus.lookup(MavenExecutionRequestPopulator.class); settingsDecrypter = plexus.lookup(SettingsDecrypter.class); }
Example #4
Source File: MavenRepositoriesTest.java From furnace with Eclipse Public License 1.0 | 5 votes |
@Test public void testMirrorCentralWithoutProfiles() throws Exception { SettingsBuilder settingsBuilder = new DefaultSettingsBuilderFactory().newInstance(); SettingsBuildingRequest settingsRequest = new DefaultSettingsBuildingRequest(); settingsRequest.setUserSettingsFile(new File("src/test/resources/profiles/mirror-settings.xml")); Settings settings = settingsBuilder.build(settingsRequest).getEffectiveSettings(); MavenContainer container = new MavenContainer(); List<RemoteRepository> remoteRepositories = MavenRepositories.getRemoteRepositories(container, settings); Assert.assertThat(remoteRepositories.size(), equalTo(1)); Assert.assertThat(remoteRepositories.get(0).getId(), equalTo("central")); Assert.assertThat(remoteRepositories.get(0).getUrl(), equalTo("http://repo.cloudbees.com/content/repositories/central/")); }
Example #5
Source File: SettingsIO.java From pom-manipulation-ext with Apache License 2.0 | 4 votes |
@Inject public SettingsIO (SettingsBuilder settingsBuilder) { this.settingsBuilder = settingsBuilder; }
Example #6
Source File: MavenContainer.java From furnace with Eclipse Public License 1.0 | 4 votes |
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); if (userRepositoryLocation != null) { effectiveSettings.setLocalRepository(userRepositoryLocation); } else { effectiveSettings.setLocalRepository(getUserHomePath() + "/.m2/repository"); } } return effectiveSettings; } catch (SettingsBuildingException e) { throw new RuntimeException(e); } }