本文整理汇总了Java中org.apache.maven.settings.Profile类的典型用法代码示例。如果您正苦于以下问题:Java Profile类的具体用法?Java Profile怎么用?Java Profile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Profile类属于org.apache.maven.settings包,在下文中一共展示了Profile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: determineActiveProfiles
import org.apache.maven.settings.Profile; //导入依赖的package包/类
private List<Profile> determineActiveProfiles(Settings settings) {
SpringBootCliModelProblemCollector problemCollector = new SpringBootCliModelProblemCollector();
List<org.apache.maven.model.Profile> activeModelProfiles = createProfileSelector()
.getActiveProfiles(createModelProfiles(settings.getProfiles()),
new SpringBootCliProfileActivationContext(
settings.getActiveProfiles()),
problemCollector);
if (!problemCollector.getProblems().isEmpty()) {
throw new IllegalStateException(createFailureMessage(problemCollector));
}
List<Profile> activeProfiles = new ArrayList<Profile>();
Map<String, Profile> profiles = settings.getProfilesAsMap();
for (org.apache.maven.model.Profile modelProfile : activeModelProfiles) {
activeProfiles.add(profiles.get(modelProfile.getId()));
}
return activeProfiles;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:18,代码来源:MavenSettings.java
示例2: getPropertyValueInSettings
import org.apache.maven.settings.Profile; //导入依赖的package包/类
@SuppressWarnings("unchecked") // because of Maven poor typing
public String getPropertyValueInSettings(String propertyName, Settings settings) {
if (settings == null) {
return null;
}
List<String> activeProfiles = settings.getActiveProfiles();
for (Object _profileWithId : settings.getProfilesAsMap().entrySet()) {
Entry<String, Profile> profileWithId = (Entry<String, Profile>) _profileWithId;
if (activeProfiles.contains(profileWithId.getKey())) {
Profile profile = profileWithId.getValue();
String value = profile.getProperties().getProperty(propertyName);
if (value != null) {
return value;
}
}
}
return null;
}
示例3: propertyExistsInSettings
import org.apache.maven.settings.Profile; //导入依赖的package包/类
@SuppressWarnings("unchecked") // because of Maven poor typing
public boolean propertyExistsInSettings(String propertyName, Settings settings) {
if (settings == null) {
return false;
}
List<String> activeProfiles = getActiveProfiles(settings);
for (Object _profileWithId : settings.getProfilesAsMap().entrySet()) {
Entry<String, Profile> profileWithId = (Entry<String, Profile>) _profileWithId;
if (activeProfiles.contains(profileWithId.getKey())) {
Profile profile = profileWithId.getValue();
boolean result = profile.getProperties().containsKey(propertyName);
if (result) {
return result;
}
}
}
return false;
}
示例4: transformSettings
import org.apache.maven.settings.Profile; //导入依赖的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;
}
示例5: addReleaseRepositories
import org.apache.maven.settings.Profile; //导入依赖的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);
}
}
示例6: addPluginRepositories
import org.apache.maven.settings.Profile; //导入依赖的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);
}
}
示例7: testValidate
import org.apache.maven.settings.Profile; //导入依赖的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() );
}
示例8: testValidateUniqueProfileId
import org.apache.maven.settings.Profile; //导入依赖的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" );
}
示例9: testValidateUniqueRepositoryId
import org.apache.maven.settings.Profile; //导入依赖的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" );
}
示例10: getRepositoryList
import org.apache.maven.settings.Profile; //导入依赖的package包/类
public static List<RemoteRepository> getRepositoryList() throws SettingsBuildingException {
List<RemoteRepository> repos = new ArrayList<RemoteRepository>();
RemoteRepository central =
new RemoteRepository.Builder("central", "default",
"http://repo1.maven.org/maven2/").build();
// Without this we wouldn't be able to find SNAPSHOT builds of plugins we
// haven't built and installed locally ourselves
RemoteRepository gateRepo = new RemoteRepository.Builder("gate", "default",
"http://repo.gate.ac.uk/content/groups/public/").build();
// Add all repos from settings.xml
// http://stackoverflow.com/questions/27818659/loading-mavens-settings-xml-for-jcabi-aether-to-use
Settings effectiveSettings = loadMavenSettings();
Map<String, Profile> profilesMap = effectiveSettings.getProfilesAsMap();
for(String profileName : effectiveSettings.getActiveProfiles()) {
Profile profile = profilesMap.get(profileName);
List<Repository> repositories = profile.getRepositories();
for(Repository repo : repositories) {
RemoteRepository remoteRepo =
new RemoteRepository.Builder(repo.getId(), "default",
repo.getUrl()).build();
repos.add(remoteRepo);
}
}
repos.add(central);
repos.add(gateRepo);
return repos;
}
示例11: newRemoteRepositories
import org.apache.maven.settings.Profile; //导入依赖的package包/类
protected static List<RemoteRepository> newRemoteRepositories(Settings settings) {
Map<String, Profile> profiles = settings.getProfilesAsMap();
List<RemoteRepository> remoteRepositories = settings.getActiveProfiles().stream().map(activeProfile -> {
if (!profiles.containsKey(activeProfile)) {
throw new RuntimeException("Activate profile " + activeProfile + " is not defined");
}
return profiles.get(activeProfile);
}).map(Profile::getRepositories).flatMap(Collection::stream).map(
repository -> new RemoteRepository.Builder(repository.getId(), "default", repository.getUrl()).build())
.collect(Collectors.toList());
if (!remoteRepositories.isEmpty()) {
return remoteRepositories;
}
return Lists.newArrayList(DEFAULT_REMOTE_REPOSITORY);
}
示例12: createModelProfiles
import org.apache.maven.settings.Profile; //导入依赖的package包/类
private List<org.apache.maven.model.Profile> createModelProfiles(
List<Profile> profiles) {
List<org.apache.maven.model.Profile> modelProfiles = new ArrayList<org.apache.maven.model.Profile>();
for (Profile profile : profiles) {
org.apache.maven.model.Profile modelProfile = new org.apache.maven.model.Profile();
modelProfile.setId(profile.getId());
if (profile.getActivation() != null) {
modelProfile
.setActivation(createModelActivation(profile.getActivation()));
}
modelProfiles.add(modelProfile);
}
return modelProfiles;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:15,代码来源:MavenSettings.java
示例13: addActiveProfileRepositories
import org.apache.maven.settings.Profile; //导入依赖的package包/类
private static void addActiveProfileRepositories(List<Profile> activeProfiles,
List<RepositoryConfiguration> configurations) {
for (Profile activeProfile : activeProfiles) {
Interpolator interpolator = new RegexBasedInterpolator();
interpolator.addValueSource(
new PropertiesBasedValueSource(activeProfile.getProperties()));
for (Repository repository : activeProfile.getRepositories()) {
configurations.add(getRepositoryConfiguration(interpolator, repository));
}
}
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:12,代码来源:RepositoryConfigurationFactory.java
示例14: mavenRepositories
import org.apache.maven.settings.Profile; //导入依赖的package包/类
private Collection<? extends ArtifactRepository> mavenRepositories(
MavenSettings settings) {
List<ArtifactRepository> list = new ArrayList<>();
for (Profile profile : settings.getActiveProfiles()) {
for (Repository repository : profile.getRepositories()) {
addRepositoryIfMissing(list, repository.getId(), repository.getUrl(),
repository.getReleases() != null
? repository.getReleases().isEnabled() : true,
repository.getSnapshots() != null
? repository.getSnapshots().isEnabled() : false);
}
}
return list;
}
示例15: getActiveProfiles
import org.apache.maven.settings.Profile; //导入依赖的package包/类
private List<String> getActiveProfiles(Settings settings) {
if (settings == null) return null;
List<String> result = settings.getActiveProfiles();
for (org.apache.maven.settings.Profile profile : settings.getProfiles()) {
if (profile.getActivation().isActiveByDefault() && !result.contains(profile.getId())) {
result.add(profile.getId());
}
}
return result;
}