本文整理汇总了Java中org.apache.maven.settings.Mirror.setMirrorOf方法的典型用法代码示例。如果您正苦于以下问题:Java Mirror.setMirrorOf方法的具体用法?Java Mirror.setMirrorOf怎么用?Java Mirror.setMirrorOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.settings.Mirror
的用法示例。
在下文中一共展示了Mirror.setMirrorOf方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addMirrors
import org.apache.maven.settings.Mirror; //导入方法依赖的package包/类
/**
* Adds a list of mirror configurations to the maven settings object
*
* @param contextUrl System URL
* @param settings Maven Settings to append to
* @param mirrors Mirrors to add to the settings
*/
private void addMirrors(String contextUrl, Settings settings, List<MavenSettingsMirror> mirrors) {
for (MavenSettingsMirror mirror : mirrors) {
Mirror mirrorToAdd = new Mirror();
String mirrorId = mirror.getId();
mirrorToAdd.setId(mirrorId);
mirrorToAdd.setName(mirrorId);
mirrorToAdd.setUrl(contextUrl + mirrorId);
mirrorToAdd.setMirrorOf(mirror.getMirrorOf());
settings.addMirror(mirrorToAdd);
}
}
示例2: newMirror
import org.apache.maven.settings.Mirror; //导入方法依赖的package包/类
private Mirror newMirror( String id, String mirrorOf, String layouts, String url )
{
Mirror mirror = new Mirror();
mirror.setId( id );
mirror.setMirrorOf( mirrorOf );
mirror.setMirrorOfLayouts( layouts );
mirror.setUrl( url );
return mirror;
}
示例3: testGetMirrorRepositoryInfos
import org.apache.maven.settings.Mirror; //导入方法依赖的package包/类
/** created in attempt of reproducing issue http://netbeans.org/bugzilla/show_bug.cgi?id=214980
*/
public void testGetMirrorRepositoryInfos() throws Exception {
Mirror mirror = new Mirror();
mirror.setId("mirror");
mirror.setMirrorOf("*");
mirror.setUrl("http://localhost");
mirror.setName("mirror repository");
try {
EmbedderFactory.getOnlineEmbedder().getSettings().addMirror(mirror);
RepositoryPreferences rp = RepositoryPreferences.getInstance();
assertEquals("[local, mirror]", rp.getRepositoryInfos().toString());
RepositoryInfo m = rp.getRepositoryInfoById("mirror");
assertTrue(m.isMirror());
assertEquals("[central]", m.getMirroredRepositories().toString());
//add a repository
rp.addTransientRepository(1, "eclipselink", "Repository for library Library[eclipselink]", "http://ftp.ing.umu.se/mirror/eclipse/rt/eclipselink/maven.repo", RepositoryInfo.MirrorStrategy.ALL);
assertEquals("[local, mirror]", rp.getRepositoryInfos().toString());
m = rp.getRepositoryInfoById("mirror");
assertTrue(m.isMirror());
assertEquals("[eclipselink]", m.getMirroredRepositories().toString());
//add the same repository again..
rp.addTransientRepository(1, "eclipselink", "Repository for library Library[eclipselink]", "http://ftp.ing.umu.se/mirror/eclipse/rt/eclipselink/maven.repo", RepositoryInfo.MirrorStrategy.ALL);
assertEquals("[local, mirror]", rp.getRepositoryInfos().toString());
m = rp.getRepositoryInfoById("mirror");
assertTrue(m.isMirror());
assertEquals("[eclipselink]", m.getMirroredRepositories().toString());
//add as non-transient repository now..
RepositoryInfo ii = new RepositoryInfo("eclipselink", "Repository for library Library[eclipselink]", null, "http://ftp.ing.umu.se/mirror/eclipse/rt/eclipselink/maven.repo");
rp.addOrModifyRepositoryInfo(ii);
//in this case mirror is not used and direct reference is used..
assertEquals("[local, eclipselink]", rp.getRepositoryInfos().toString());
//remove and mirror should show up again..
rp.removeRepositoryInfo(ii);
assertEquals("[local, mirror]", rp.getRepositoryInfos().toString());
m = rp.getRepositoryInfoById("mirror");
assertTrue(m.isMirror());
assertEquals("[eclipselink]", m.getMirroredRepositories().toString());
//add central now.. should have 2 mirrored repositories..
rp.addTransientRepository(1, "central", "central", "http://repo1.maven.org/maven2", RepositoryInfo.MirrorStrategy.ALL);
assertEquals("[local, mirror]", rp.getRepositoryInfos().toString());
m = rp.getRepositoryInfoById("mirror");
assertTrue(m.isMirror());
assertEquals("[eclipselink, central]", m.getMirroredRepositories().toString());
//add central AGAIN and AGAIN.. should have still just 2 mirrored repositories..
rp.addTransientRepository(2, "central", "central", "http://repo1.maven.org/maven2", RepositoryInfo.MirrorStrategy.ALL);
rp.addTransientRepository(3, "central", "central", "http://repo1.maven.org/maven2", RepositoryInfo.MirrorStrategy.ALL);
rp.addTransientRepository(4, "central", "central", "http://repo1.maven.org/maven2", RepositoryInfo.MirrorStrategy.ALL);
assertEquals("[local, mirror]", rp.getRepositoryInfos().toString());
m = rp.getRepositoryInfoById("mirror");
assertTrue(m.isMirror());
assertEquals("[eclipselink, central]", m.getMirroredRepositories().toString());
//try adding slightly modified transient repositories..
rp.addTransientRepository(3, "central", "central", "http://repo1.maven.org/maven2/", RepositoryInfo.MirrorStrategy.ALL);
rp.addTransientRepository(2, "central", "central rep", "http://repo1.maven.org/maven2", RepositoryInfo.MirrorStrategy.ALL);
rp.addTransientRepository(2, "eclipselink", "Repository for library Library", "http://ftp.ing.umu.se/mirror/eclipse/rt/eclipselink/maven.repo", RepositoryInfo.MirrorStrategy.ALL);
assertEquals("[local, mirror]", rp.getRepositoryInfos().toString());
m = rp.getRepositoryInfoById("mirror");
assertTrue(m.isMirror());
assertEquals("[eclipselink, central]", m.getMirroredRepositories().toString());
} finally {
EmbedderFactory.getOnlineEmbedder().getSettings().removeMirror(mirror);
}
}
示例4: generateSettingsXml
import org.apache.maven.settings.Mirror; //导入方法依赖的package包/类
/**
* methode to generate a custom mvn consumer settings.xml file
*
* @return
*/
private String generateSettingsXml() {
Settings settings = new Settings();
settings.setLocalRepository(localRepository);
//
// <mirror>
// <id>FTRDProxy_central</id>
// <mirrorOf>central</mirrorOf>
// <name>FTRD Maven Proxy mirroring central (maven 2) repository</name>
// </mirror>
//
Mirror mirror = new Mirror();
mirror.setId(mirrorId);
mirror.setName("Paas Maven Repo");
mirror.setUrl(mirrorUrl);
mirror.setMirrorOf("*");
settings.getMirrors().add(mirror);
List<org.apache.maven.settings.Server> servers = new ArrayList<org.apache.maven.settings.Server>();
org.apache.maven.settings.Server paasInhouse = new org.apache.maven.settings.Server();
paasInhouse.setId("paas.push.release.repo");
paasInhouse.setUsername(releaseRepositoryUser);
paasInhouse.setPassword(releaseRepositoryPassword);
servers.add(paasInhouse);
org.apache.maven.settings.Server paasInhouseSnapshot = new org.apache.maven.settings.Server();
paasInhouseSnapshot.setId("paas.push.snapshot.repo");
paasInhouseSnapshot.setUsername(snapshotRepositoryUser);
paasInhouseSnapshot.setPassword(snapshotRepositoryPassword);
servers.add(paasInhouseSnapshot);
settings.setServers(servers);
DefaultSettingsWriter settingsWriter = new DefaultSettingsWriter();
try {
StringWriter aWriter = new StringWriter();
settingsWriter.write(aWriter, null, settings);
logger.info("settings xml for project sucessfully generated");
return aWriter.toString();
} catch (IOException e) {
logger.error("settings.xml construction failure, JaxbException :" + e.getMessage());
throw new TechnicalException(e);
}
}
示例5: mirrorAdjustsLocationURLs
import org.apache.maven.settings.Mirror; //导入方法依赖的package包/类
@Test
public void mirrorAdjustsLocationURLs()
throws Exception
{
final Mirror mirror = new Mirror();
mirror.setId( "test-mirror" );
mirror.setMirrorOf( "*" );
mirror.setUrl( "http://nowhere.com" );
final ArtifactRepositoryLayout layout = new DefaultRepositoryLayout();
final ArtifactRepositoryPolicy snapshots =
new ArtifactRepositoryPolicy( true, ArtifactRepositoryPolicy.UPDATE_POLICY_DAILY,
ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN );
final ArtifactRepositoryPolicy releases =
new ArtifactRepositoryPolicy( true, ArtifactRepositoryPolicy.UPDATE_POLICY_NEVER,
ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN );
final File localRepo = File.createTempFile( "local.repo.", ".dir" );
localRepo.deleteOnExit();
final ArtifactRepository local =
new MavenArtifactRepository( "local", localRepo.toURI()
.toString(), layout, snapshots, releases );
final ArtifactRepository remote =
new MavenArtifactRepository( "remote", "http:///repo.maven.apache.org/maven2", layout, snapshots, releases );
final Settings settings = new Settings();
settings.addMirror( mirror );
final MavenLocationExpander ex =
new MavenLocationExpander( Collections.<Location> emptyList(),
Collections.<ArtifactRepository> singletonList( remote ), local,
new DefaultMirrorSelector(), settings, Collections.<String> emptyList() );
final List<Location> result = ex.expand( MavenLocationExpander.EXPANSION_TARGET );
assertThat( result.size(), equalTo( 2 ) );
final Iterator<Location> iterator = result.iterator();
Location loc = iterator.next();
assertThat( loc.getName(), equalTo( local.getId() ) );
assertThat( loc.getUri(), equalTo( local.getUrl() ) );
loc = iterator.next();
assertThat( loc.getName(), equalTo( mirror.getId() ) );
assertThat( loc.getUri(), equalTo( mirror.getUrl() ) );
}