当前位置: 首页>>代码示例>>Java>>正文


Java Mirror.setMirrorOf方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:20,代码来源:MavenServiceImpl.java

示例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;
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:12,代码来源:MirrorProcessorTest.java

示例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); 
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:79,代码来源:RepositoryPreferencesTest.java

示例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);
	}
}
 
开发者ID:orange-cloudfoundry,项目名称:elpaaso-core,代码行数:57,代码来源:SettingsGenerator.java

示例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() ) );
}
 
开发者ID:release-engineering,项目名称:pom-manipulation-ext,代码行数:53,代码来源:MavenLocationExpanderTest.java


注:本文中的org.apache.maven.settings.Mirror.setMirrorOf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。