本文整理汇总了Java中org.apache.maven.settings.Settings.addProfile方法的典型用法代码示例。如果您正苦于以下问题:Java Settings.addProfile方法的具体用法?Java Settings.addProfile怎么用?Java Settings.addProfile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.settings.Settings
的用法示例。
在下文中一共展示了Settings.addProfile方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: transformSettings
import org.apache.maven.settings.Settings; //导入方法依赖的package包/类
/**
* Recieves artifactories MavenSettings object and transforms it to maven's Settings object
*
* @param mavenSettings Settings to transform
* @return Settings - Transformed settings
*/
private Settings transformSettings(MavenSettings mavenSettings) {
String contextUrl = mavenSettings.getUrl();
Settings settings = new Settings();
Profile profile = new Profile();
profile.setId("artifactory");
//Add plugin and releases repositories to the profile
addReleaseRepositories(contextUrl, profile, mavenSettings.getReleaseRepositories());
addPluginRepositories(contextUrl, profile, mavenSettings.getPluginRepositories());
settings.addProfile(profile);
settings.setActiveProfiles(Collections.singletonList(profile.getId()));
//Add mirrors to the settings
addMirrors(contextUrl, settings, mavenSettings.getMirrorRepositories());
addServers(settings, mavenSettings.getServers());
return settings;
}
示例2: testValidate
import org.apache.maven.settings.Settings; //导入方法依赖的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() );
}
示例3: testValidateUniqueProfileId
import org.apache.maven.settings.Settings; //导入方法依赖的package包/类
public void testValidateUniqueProfileId()
throws Exception
{
Settings settings = new Settings();
Profile profile1 = new Profile();
profile1.setId( "test" );
settings.addProfile( profile1 );
Profile profile2 = new Profile();
profile2.setId( "test" );
settings.addProfile( profile2 );
SimpleProblemCollector problems = new SimpleProblemCollector();
validator.validate( settings, problems );
assertEquals( 1, problems.messages.size() );
assertContains( problems.messages.get( 0 ),
"'profiles.profile.id' must be unique but found duplicate profile with id test" );
}
示例4: testValidateUniqueRepositoryId
import org.apache.maven.settings.Settings; //导入方法依赖的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.Settings; //导入方法依赖的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() ) );
}