本文整理了Java中org.apache.maven.settings.Mirror
类的一些代码示例,展示了Mirror
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mirror
类的具体详情如下:
包路径:org.apache.maven.settings.Mirror
类名称:Mirror
[英]A download mirror for a given repository.
[中]给定存储库的下载镜像。
代码示例来源:origin: apache/maven
if ( mirror.getMirrorOf() != null )
serializer.startTag( NAMESPACE, "mirrorOf" ).text( mirror.getMirrorOf() ).endTag( NAMESPACE, "mirrorOf" );
if ( mirror.getName() != null )
serializer.startTag( NAMESPACE, "name" ).text( mirror.getName() ).endTag( NAMESPACE, "name" );
if ( mirror.getUrl() != null )
serializer.startTag( NAMESPACE, "url" ).text( mirror.getUrl() ).endTag( NAMESPACE, "url" );
if ( ( mirror.getLayout() != null ) && !mirror.getLayout().equals( "default" ) )
serializer.startTag( NAMESPACE, "layout" ).text( mirror.getLayout() ).endTag( NAMESPACE, "layout" );
if ( ( mirror.getMirrorOfLayouts() != null ) && !mirror.getMirrorOfLayouts().equals( "default,legacy" ) )
serializer.startTag( NAMESPACE, "mirrorOfLayouts" ).text( mirror.getMirrorOfLayouts() ).endTag( NAMESPACE, "mirrorOfLayouts" );
if ( ( mirror.getId() != null ) && !mirror.getId().equals( "default" ) )
serializer.startTag( NAMESPACE, "id" ).text( mirror.getId() ).endTag( NAMESPACE, "id" );
代码示例来源:origin: apache/maven
private void injectMirror( ArtifactRepository repository, Mirror mirror )
{
if ( mirror != null )
{
ArtifactRepository original =
createArtifactRepository( repository.getId(), repository.getUrl(), repository.getLayout(),
repository.getSnapshots(), repository.getReleases() );
repository.setMirroredRepositories( Collections.singletonList( original ) );
repository.setId( mirror.getId() );
repository.setUrl( mirror.getUrl() );
if ( StringUtils.isNotEmpty( mirror.getLayout() ) )
{
repository.setLayout( getLayout( mirror.getLayout() ) );
}
}
}
代码示例来源:origin: apache/maven
@Deprecated
public ArtifactRepository getMirrorRepository( ArtifactRepository repository )
{
Mirror mirror = mirrorSelector.getMirror( repository, legacySupport.getSession().getSettings().getMirrors() );
if ( mirror != null )
{
String id = mirror.getId();
if ( id == null )
{
// TODO this should be illegal in settings.xml
id = repository.getId();
}
log.debug( "Using mirror: " + mirror.getUrl() + " (id: " + id + ")" );
repository = artifactRepositoryFactory.createArtifactRepository( id, mirror.getUrl(),
repository.getLayout(), repository.getSnapshots(),
repository.getReleases() );
}
return repository;
}
代码示例来源:origin: apache/maven
@Override
public void validate( Settings settings, SettingsProblemCollector problems )
if ( settings.isUsePluginRegistry() )
List<String> pluginGroups = settings.getPluginGroups();
List<Server> servers = settings.getServers();
validateStringNotEmpty( problems, "mirrors.mirror.id", mirror.getId(), mirror.getUrl() );
validateBannedCharacters( problems, "mirrors.mirror.id", Severity.WARNING, mirror.getId(), null,
ILLEGAL_REPO_ID_CHARS );
if ( "local".equals( mirror.getId() ) )
validateStringNotEmpty( problems, "mirrors.mirror.url", mirror.getUrl(), mirror.getId() );
validateStringNotEmpty( problems, "mirrors.mirror.mirrorOf", mirror.getMirrorOf(), mirror.getId() );
代码示例来源:origin: org.apache.maven.continuum/continuum-core
Proxy proxy = settings.getActiveProxy();
for ( Iterator i = settings.getServers().iterator(); i.hasNext(); )
for ( Iterator i = settings.getMirrors().iterator(); i.hasNext(); )
wagonManager.addMirror( mirror.getId(), mirror.getMirrorOf(), mirror.getUrl() );
代码示例来源:origin: org.jboss.shrinkwrap.resolver/shrinkwrap-resolver-impl-maven
List<Profile> activeProfiles = selector.getActiveProfiles(MavenConverter.asProfiles(getSettings().getProfiles()),
new ProfileActivationContext() {
for (Mirror mirror : getSettings().getMirrors()) {
dms.add(mirror.getId(), mirror.getUrl(), mirror.getLayout(), false, mirror.getMirrorOf(),
mirror.getMirrorOfLayouts());
Server server = getSettings().getServer(remoteRepository.getId());
if (server != null) {
final AuthenticationBuilder authenticationBuilder = new AuthenticationBuilder()
代码示例来源:origin: org.jboss.forge.addon/maven-impl-projects
new File(settings.getLocalRepository()).toURI().toURL().toString(), null, true, true);
request.setLocalRepository(localRepository);
List<String> activeProfiles = settings.getActiveProfiles();
Map<String, Profile> profiles = settings.getProfilesAsMap();
for (Mirror mirror : mirrors)
mirrorSelector.add(mirror.getId(), mirror.getUrl(), mirror.getLayout(), false, mirror.getMirrorOf(),
mirror.getMirrorOfLayouts());
代码示例来源:origin: de.smartics.properties/smartics-properties-resource-maven
private MavenRepository createRepository(final File settingsFile,
final Settings settings, final List<DependencyFilter> filters)
{
final String localRepositoryPath = settings.getLocalRepository();
final List<Mirror> mirrors = settings.getMirrors();
final String remoteRepositoryUrl;
Authentication auth = null;
if (!mirrors.isEmpty())
{
final Mirror mirror = mirrors.get(0);
remoteRepositoryUrl = mirror.getUrl();
final Server server = settings.getServer(mirror.getId());
if (server != null)
{
final String password =
decodePassword(settingsFile, server.getPassword());
auth =
new Authentication(server.getUsername(), password,
server.getPrivateKey(), server.getPassphrase());
}
}
else
{
remoteRepositoryUrl = null;
}
final boolean offline = settings.isOffline();
return new MavenRepository(remoteRepositoryUrl, auth, localRepositoryPath,
filters, offline);
}
代码示例来源:origin: io.tesla.aether/tesla-aether
public RemoteRepository getRemoteRepository() {
String repositoryId = "central";
String repositoryUrl = "http://repo1.maven.org/maven2";
String repoUser = null;
String repoPass = null;
Settings settings = readMavenSettings();
if (settings != null) {
//
// There is a settings.xml file present so we delegate purely to the settings.xml file for mirrors and authentication.
// TODO: We ultimately need to construct a proper mirror selector which we should borrow from Maven itself.
//
if (settings.getMirrors() != null && settings.getMirrors().size() == 1) {
Mirror mirror = settings.getMirrors().get(0);
repositoryUrl = mirror.getUrl();
repositoryId = mirror.getId();
if (settings.getServer(repositoryId) != null) {
repoUser = settings.getServer(repositoryId).getUsername();
repoPass = settings.getServer(repositoryId).getPassword();
}
}
}
RemoteRepository.Builder builder = new RemoteRepository.Builder(repositoryId, "default", repositoryUrl);
if (repoUser != null && repoPass != null) {
Authentication auth = new AuthenticationBuilder().addUsername(repoUser).addPassword(repoPass).build();
builder.setAuthentication(auth);
}
return builder.build();
}
代码示例来源:origin: net.oneandone.maven/embedded
final List<Server> servers;
servers = settings.getServers();
session = MavenRepositorySystemUtils.newSession();
session.setAuthenticationSelector(new AuthenticationSelector() {
session.setTransferListener(transferListener);
session.setOffline(settings.isOffline());
session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepository));
DefaultMirrorSelector mirrorSelector = new DefaultMirrorSelector();
for (Mirror mirror : settings.getMirrors()) {
mirrorSelector.add(mirror.getId(), mirror.getUrl(), mirror.getLayout(), false, mirror.getMirrorOf(),
mirror.getMirrorOfLayouts());
代码示例来源:origin: io.squark.yggdrasil/yggdrasil-maven-provider
repositorySystemSession.setChecksumPolicy(RepositoryPolicy.CHECKSUM_POLICY_WARN);
DefaultMirrorSelector mirrorSelector = new DefaultMirrorSelector();
for (Mirror mirror : mavenSettings.getMirrors()) {mirrorSelector.add(mirror.getId(), mirror.getUrl(),
mirror.getLayout(), false, mirror.getMirrorOf(), mirror.getMirrorOfLayouts());
if (mavenSettings.getActiveProxy() != null) {
Proxy aetherProxy = toAetherProxy(mavenSettings.getActiveProxy());
proxySelector.add(aetherProxy, mavenSettings.getActiveProxy().getNonProxyHosts());
} else if (mavenSettings.getProxies().size() > 0) {
代码示例来源:origin: org.jboss.galleon/galleon-cli
private static List<RemoteRepository> buildRemoteRepositories(Settings settings) throws ArtifactException {
Map<String, Profile> profiles = settings.getProfilesAsMap();
Map<String, RemoteRepository> repos = new LinkedHashMap<>();
List<RemoteRepository> repositories = new ArrayList<>();
for (String profileName : settings.getActiveProfiles()) {
Profile profile = profiles.get(profileName);
if (profile == null) {
for (Mirror mirror : settings.getMirrors()) {
String[] patterns = mirror.getMirrorOf().split(",");
List<RemoteRepository> mirrored = new ArrayList<>();
boolean all = false;
repositories.add(buildRepository(mirror.getId(),
mirror.getLayout(), mirror.getUrl(), settings, null, null, mirrored));
代码示例来源:origin: org.eclipse.tycho/tycho-core
private Mirror createMirror(ArtifactRepository repo, Mirror toMirror) {
Mirror mirror = toMirror.clone();
String urlToReplace = toMirror.getMirrorOf();
String newUrl = StringUtils.replaceOnce(repo.getUrl(), urlToReplace, toMirror.getUrl());
mirror.setUrl(newUrl);
mirror.setId(toMirror.getId());
return mirror;
}
代码示例来源:origin: io.fabric8/fabric-maven
private MirrorSelector selectMirrors( Mirror mirror ) {
// configure mirror
DefaultMirrorSelector selector = new DefaultMirrorSelector();
for( Mirror m : m_settings.getMirrors() ) {
selector.add( m.getName(), m.getUrl(), null, false, m.getMirrorOf(), "*" );
}
if( mirror != null ) {
selector.add(mirror.getName(), mirror.getUrl(), null, false, mirror.getMirrorOf(), "*");
}
return selector;
}
代码示例来源:origin: org.codehaus.mevenide/nb-mvn-embedder
/**
* Method updateMirror
*
* @param value
* @param element
* @param counter
* @param xmlTag
*/
protected void updateMirror(Mirror value, String xmlTag, Counter counter, Element element)
{
Element root = element;
Counter innerCount = new Counter(counter.getDepth() + 1);
findAndReplaceSimpleElement(innerCount, root, "mirrorOf", value.getMirrorOf(), null);
findAndReplaceSimpleElement(innerCount, root, "name", value.getName(), null);
findAndReplaceSimpleElement(innerCount, root, "url", value.getUrl(), null);
findAndReplaceSimpleElement(innerCount, root, "id", value.getId(), null);
} //-- void updateMirror(Mirror, String, Counter, Element)
代码示例来源:origin: dsyer/spring-boot-thin-launcher
private String getThinRepo() {
String repo = getProperty("thin.repo");
if (repo != null) {
return repo;
}
for (Mirror mirror : this.settings.getMirrors()) {
String of = mirror.getMirrorOf();
if ("*".equals(of) || "central".equals(of)
|| (of != null && of.contains("spring"))) {
return mirror.getUrl();
}
}
return null;
}
代码示例来源:origin: org.apache.maven/maven-artifact-ant
protected RemoteRepository createAntRemoteRepositoryBase( org.apache.maven.model.RepositoryBase pomRepository )
{
// TODO: actually, we need to not funnel this through the ant repository - we should pump settings into wagon
// manager at the start like m2 does, and then match up by repository id
// As is, this could potentially cause a problem with 2 remote repositories with different authentication info
RemoteRepository r = new RemoteRepository();
r.setId( pomRepository.getId() );
r.setUrl( pomRepository.getUrl() );
r.setLayout( pomRepository.getLayout() );
Server server = getSettings().getServer( pomRepository.getId() );
if ( server != null )
{
r.addAuthentication( new Authentication( server ) );
}
org.apache.maven.settings.Proxy proxy = getSettings().getActiveProxy();
if ( proxy != null )
{
r.addProxy( new Proxy( proxy ) );
}
Mirror mirror = getSettings().getMirrorOf( pomRepository.getId() );
if ( mirror != null )
{
r.setUrl( mirror.getUrl() );
}
return r;
}
代码示例来源:origin: apache/maven
@Deprecated
public Mirror getMirrorOf( String repositoryId )
{
Mirror match = null;
java.util.List<Mirror> mirrors = getMirrors();
if ( mirrors != null && repositoryId != null )
{
for ( Mirror mirror : mirrors )
{
if ( repositoryId.equals( mirror.getMirrorOf() ) )
{
match = mirror;
break;
}
}
}
return match;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-maven-indexer
/**
* 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(info.getId(), /* XXX do we even support any other layout?*/"default", info.getRepositoryUrl());
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;
}
代码示例来源:origin: org.eclipse.tycho/tycho-core
@Override
public MavenRepositoryLocation getMirror(MavenRepositoryLocation location) {
if (location.getId() == null) {
return null;
}
// TODO check repository type?
ArtifactRepository locationAsMavenRepository = repositorySystem.createArtifactRepository(location.getId(),
location.getURL().toString(), p2layout, P2_REPOSITORY_POLICY, P2_REPOSITORY_POLICY);
Mirror mirror = mirrorSelector.getMirror(locationAsMavenRepository,
context.getSession().getRequest().getMirrors());
if (mirror != null) {
return new MavenRepositoryLocation(mirror.getId(), URI.create(mirror.getUrl()));
}
return null;
}
内容来源于网络,如有侵权,请联系作者删除!