Java Code Examples for org.apache.maven.settings.Settings#getMirrors()
The following examples show how to use
org.apache.maven.settings.Settings#getMirrors() .
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: RepositoryPreferences.java From netbeans with Apache License 2.0 | 6 votes |
/** * if the repository has a mirror, then create a repositoryinfo object for it.. */ private RepositoryInfo getMirrorInfo(RepositoryInfo info, MirrorSelector selector, Settings settings) { RemoteRepository original = new RemoteRepository.Builder(info.getId(), /* XXX do we even support any other layout?*/"default", info.getRepositoryUrl()).build(); RemoteRepository mirror = selector.getMirror(original); if (mirror != null) { try { String name = mirror.getId(); //#213078 need to lookup name for mirror for (Mirror m : settings.getMirrors()) { if (m.getId() != null && m.getId().equals(mirror.getId())) { name = m.getName(); break; } } RepositoryInfo toret = new RepositoryInfo(mirror.getId(), name, null, mirror.getUrl()); toret.setMirrorStrategy(RepositoryInfo.MirrorStrategy.NONE); return toret; } catch (URISyntaxException ex) { Exceptions.printStackTrace(ex); } } return null; }
Example 2
Source File: MavenPluginRepository.java From BIMserver with GNU Affero General Public License v3.0 | 6 votes |
private DefaultRepositorySystemSession newRepositorySystemSession(RepositorySystem system, File localRepoFile, Settings settings) { DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession(); if (!settings.getMirrors().isEmpty()) { DefaultMirrorSelector mirrorSelector = new DefaultMirrorSelector(); for (Mirror mirror : settings.getMirrors()) { mirrorSelector.add(mirror.getId(), mirror.getUrl(), "default", true, mirror.getMirrorOf(), "*"); } session.setMirrorSelector(mirrorSelector); } session.setProxySelector(proxySelector); LocalRepository localRepo = new LocalRepository(localRepoFile); session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepo)); return session; }
Example 3
Source File: MavenSettings.java From spring-init with Apache License 2.0 | 5 votes |
private MirrorSelector createMirrorSelector(Settings settings) { DefaultMirrorSelector selector = new DefaultMirrorSelector(); for (Mirror mirror : settings.getMirrors()) { selector.add(mirror.getId(), mirror.getUrl(), mirror.getLayout(), false, mirror.getMirrorOf(), mirror.getMirrorOfLayouts()); } return selector; }
Example 4
Source File: MavenSettings.java From spring-cloud-function with Apache License 2.0 | 5 votes |
private MirrorSelector createMirrorSelector(Settings settings) { DefaultMirrorSelector selector = new DefaultMirrorSelector(); for (Mirror mirror : settings.getMirrors()) { selector.add(mirror.getId(), mirror.getUrl(), mirror.getLayout(), false, mirror.getMirrorOf(), mirror.getMirrorOfLayouts()); } return selector; }
Example 5
Source File: MavenContainer.java From furnace with Eclipse Public License 1.0 | 5 votes |
private DefaultMirrorSelector createMirrorSelector(Settings settings) { final DefaultMirrorSelector mirrorSelector = new DefaultMirrorSelector(); final List<Mirror> mirrors = settings.getMirrors(); if (mirrors != null) { for (Mirror mirror : mirrors) { mirrorSelector.add(mirror.getId(), mirror.getUrl(), mirror.getLayout(), false, mirror.getMirrorOf(), mirror.getMirrorOfLayouts()); } } return mirrorSelector; }
Example 6
Source File: MavenLocationExpander.java From pom-manipulation-ext with Apache License 2.0 | 4 votes |
private void addRequestRepositoriesTo( final Set<Location> locs, final List<ArtifactRepository> artifactRepositories, final Settings settings, final MirrorSelector mirrorSelector ) throws MalformedURLException { if ( artifactRepositories != null ) { for ( final ArtifactRepository repo : artifactRepositories ) { // TODO: Authentication via memory password manager. String id = repo.getId(); String url = repo.getUrl(); if ( url.startsWith( "file:" ) ) { locs.add( new SimpleLocation( id, url ) ); } else { final List<Mirror> mirrors = settings.getMirrors(); if ( mirrors != null ) { final Mirror mirror = mirrorSelector == null ? null : mirrorSelector.getMirror( repo, mirrors ); if ( mirror != null ) { id = mirror.getId(); url = mirror.getUrl(); } } final ArtifactRepositoryPolicy releases = repo.getReleases(); final ArtifactRepositoryPolicy snapshots = repo.getSnapshots(); SimpleHttpLocation addition = new SimpleHttpLocation( id, url, snapshots != null && snapshots.isEnabled(), releases == null || releases.isEnabled(), true, false, null ); addition.setAttribute(Location.CONNECTION_TIMEOUT_SECONDS, 60); locs.add (addition); } } } }
Example 7
Source File: MavenLocationExpander.java From pom-manipulation-ext with Apache License 2.0 | 4 votes |
private void addSettingsProfileRepositoriesTo( final Set<Location> locs, final Settings settings, final List<String> activeProfiles, final MirrorSelector mirrorSelector ) throws MalformedURLException { if ( settings != null ) { final Map<String, Profile> profiles = settings.getProfilesAsMap(); if ( profiles != null && activeProfiles != null && !activeProfiles.isEmpty() ) { final LinkedHashSet<String> active = new LinkedHashSet<>( activeProfiles ); final List<String> settingsActiveProfiles = settings.getActiveProfiles(); if ( settingsActiveProfiles != null && !settingsActiveProfiles.isEmpty() ) { active.addAll( settingsActiveProfiles ); } for ( final String profileId : active ) { final Profile profile = profiles.get( profileId ); if ( profile != null ) { final List<Repository> repositories = profile.getRepositories(); if ( repositories != null ) { final List<Mirror> mirrors = settings.getMirrors(); final ArtifactRepositoryLayout layout = new DefaultRepositoryLayout(); for ( final Repository repo : repositories ) { String id = repo.getId(); String url = repo.getUrl(); if ( mirrors != null ) { final ArtifactRepositoryPolicy snapshots = convertPolicy( repo.getSnapshots() ); final ArtifactRepositoryPolicy releases = convertPolicy( repo.getReleases() ); final MavenArtifactRepository arepo = new MavenArtifactRepository( id, url, layout, snapshots, releases ); final Mirror mirror = mirrorSelector == null ? null : mirrorSelector.getMirror( arepo, mirrors ); if ( mirror != null ) { id = mirror.getId(); url = mirror.getUrl(); } SimpleHttpLocation addition = new SimpleHttpLocation( id, url, snapshots.isEnabled(), releases.isEnabled(), true, false, null ); addition.setAttribute(Location.CONNECTION_TIMEOUT_SECONDS, 60); locs.add (addition); } } } } } } } }
Example 8
Source File: SettingsIO.java From pom-manipulation-ext with Apache License 2.0 | 4 votes |
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() ) { defaultSettings.getProfiles().removeIf( profile1 -> profile1.getId().equals( profile.getId() ) ); defaultSettings.addProfile( profile ); } for ( String activeProfile : settings.getActiveProfiles() ) { defaultSettings.getActiveProfiles().removeIf( s -> s.equals( activeProfile ) ); 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.", settingsFile, e.getMessage(), e ); } }