本文整理汇总了Java中org.apache.maven.settings.Repository.setId方法的典型用法代码示例。如果您正苦于以下问题:Java Repository.setId方法的具体用法?Java Repository.setId怎么用?Java Repository.setId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.settings.Repository
的用法示例。
在下文中一共展示了Repository.setId方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addReleaseRepositories
import org.apache.maven.settings.Repository; //导入方法依赖的package包/类
/**
* Adds a list of release repository configurations to the maven profile object
*
* @param contextUrl System URL
* @param profile Maven profile to append to
* @param repositories Repositories to add to the profile
*/
private void addReleaseRepositories(String contextUrl, Profile profile,
List<MavenSettingsRepository> repositories) {
for (MavenSettingsRepository repository : repositories) {
Repository repoToAdd = new Repository();
repoToAdd.setId(repository.getId());
String repositoryName = repository.getName();
repoToAdd.setName(repositoryName);
repoToAdd.setUrl(contextUrl + repositoryName);
boolean handlesSnapshots = repository.isHandlesSnapshots();
RepositoryPolicy snapshotPolicy = new RepositoryPolicy();
snapshotPolicy.setEnabled(handlesSnapshots);
repoToAdd.setSnapshots(snapshotPolicy);
profile.addRepository(repoToAdd);
}
}
示例2: addPluginRepositories
import org.apache.maven.settings.Repository; //导入方法依赖的package包/类
/**
* Adds a list of plugin repository configurations to the maven profile object
*
* @param contextUrl System URL
* @param profile Maven profile to append to
* @param repositories Repositories to add to the profile
*/
private void addPluginRepositories(String contextUrl, Profile profile, List<MavenSettingsRepository> repositories) {
for (MavenSettingsRepository repository : repositories) {
Repository repoToAdd = new Repository();
repoToAdd.setId(repository.getId());
String repositoryName = repository.getName();
repoToAdd.setName(repositoryName);
repoToAdd.setUrl(contextUrl + repositoryName);
boolean handlesSnapshots = repository.isHandlesSnapshots();
RepositoryPolicy snapshotPolicy = new RepositoryPolicy();
snapshotPolicy.setEnabled(handlesSnapshots);
repoToAdd.setSnapshots(snapshotPolicy);
profile.addPluginRepository(repoToAdd);
}
}
示例3: testValidate
import org.apache.maven.settings.Repository; //导入方法依赖的package包/类
public void testValidate()
{
Settings model = new Settings();
Profile prof = new Profile();
prof.setId( "xxx" );
model.addProfile( prof );
SimpleProblemCollector problems = new SimpleProblemCollector();
validator.validate( model, problems );
assertEquals( 0, problems.messages.size() );
Repository repo = new Repository();
prof.addRepository( repo );
problems = new SimpleProblemCollector();
validator.validate( model, problems );
assertEquals( 2, problems.messages.size() );
repo.setUrl( "http://xxx.xxx.com" );
problems = new SimpleProblemCollector();
validator.validate( model, problems );
assertEquals( 1, problems.messages.size() );
repo.setId( "xxx" );
problems = new SimpleProblemCollector();
validator.validate( model, problems );
assertEquals( 0, problems.messages.size() );
}
示例4: testValidateUniqueRepositoryId
import org.apache.maven.settings.Repository; //导入方法依赖的package包/类
public void testValidateUniqueRepositoryId()
throws Exception
{
Settings settings = new Settings();
Profile profile = new Profile();
profile.setId( "pro" );
settings.addProfile( profile );
Repository repo1 = new Repository();
repo1.setUrl( "http://apache.org/" );
repo1.setId( "test" );
profile.addRepository( repo1 );
Repository repo2 = new Repository();
repo2.setUrl( "http://apache.org/" );
repo2.setId( "test" );
profile.addRepository( repo2 );
SimpleProblemCollector problems = new SimpleProblemCollector();
validator.validate( settings, problems );
assertEquals( 1, problems.messages.size() );
assertContains( problems.messages.get( 0 ), "'profiles.profile[pro].repositories.repository.id' must be unique"
+ " but found duplicate repository with id test" );
}
示例5: useActiveSettingsProfileRepos
import org.apache.maven.settings.Repository; //导入方法依赖的package包/类
@Test
public void useActiveSettingsProfileRepos()
throws Exception
{
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 Repository remote = new Repository();
remote.setId( "remote" );
remote.setUrl( "http:///repo.maven.apache.org/maven2" );
final Profile profile = new Profile();
profile.setId( "test" );
profile.addRepository( remote );
final Settings settings = new Settings();
settings.addProfile( profile );
final MavenLocationExpander ex =
new MavenLocationExpander( Collections.<Location> emptyList(),
Collections.<ArtifactRepository> emptyList(), local,
new DefaultMirrorSelector(), settings,
Collections.<String> singletonList( profile.getId() ) );
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( remote.getId() ) );
assertThat( loc.getUri(), equalTo( remote.getUrl() ) );
}