本文整理了Java中org.apache.maven.settings.Settings.getProfilesAsMap()
方法的一些代码示例,展示了Settings.getProfilesAsMap()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Settings.getProfilesAsMap()
方法的具体详情如下:
包路径:org.apache.maven.settings.Settings
类名称:Settings
方法名:getProfilesAsMap
暂无
代码示例来源:origin: io.teecube.t3/t3-common
@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;
}
代码示例来源:origin: io.teecube.t3/t3-common
@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;
}
代码示例来源:origin: org.codehaus.mevenide/nb-project
public List<String> getAllProfiles() {
Set<String> profileIds = new HashSet<String>();
//pom+profiles.xml profiles come first
extractProfiles(profileIds, nmp.getPOMFile());
//Add settings file Properties
profileIds.addAll(MavenSettingsSingleton.getInstance().createUserSettingsModel().
getProfilesAsMap().keySet());
return new ArrayList<String>(profileIds);
}
代码示例来源:origin: org.eclipse.tycho/tycho-core
private Properties getGlobalProperties(MavenSession session) {
Properties globalProps = new Properties();
// 1. system
globalProps.putAll(session.getSystemProperties());
Settings settings = session.getSettings();
// 2. active profiles
Map<String, Profile> profileMap = settings.getProfilesAsMap();
for (String profileId : settings.getActiveProfiles()) {
Profile profile = profileMap.get(profileId);
if (profile != null) {
globalProps.putAll(profile.getProperties());
}
}
// 3. user
globalProps.putAll(session.getUserProperties());
return globalProps;
}
}
代码示例来源:origin: io.fabric8/maven-util
public static List<Repository> getRepositories() {
List<Repository> repositories = new LinkedList<Repository>();
Settings settings = getSettings();
Set<String> profileNames = new LinkedHashSet<String>();
profileNames.addAll(settings.getActiveProfiles());
for (Profile p : settings.getProfiles()) {
if (p.getActivation() != null && p.getActivation().isActiveByDefault()) {
profileNames.add(p.getId());
}
}
for (String profileName : profileNames) {
Object obj = settings.getProfilesAsMap().get(profileName);
if (Profile.class.isAssignableFrom(obj.getClass())) {
Profile p = (Profile) obj;
for (Repository repository : p.getRepositories()) {
repositories.add(repository);
}
}
}
return repositories;
}
代码示例来源:origin: org.fusesource/maven-util
public static List<Repository> getRepositories() {
List<Repository> repositories = new LinkedList<Repository>();
Settings settings = getSettings();
Set<String> profileNames = new LinkedHashSet<String>();
profileNames.addAll(settings.getActiveProfiles());
for (Profile p : settings.getProfiles()) {
if (p.getActivation() != null && p.getActivation().isActiveByDefault()) {
profileNames.add(p.getId());
}
}
for (String profileName : profileNames) {
Object obj = settings.getProfilesAsMap().get(profileName);
if (Profile.class.isAssignableFrom(obj.getClass())) {
Profile p = (Profile) obj;
for (Repository repository : p.getRepositories()) {
repositories.add(repository);
}
}
}
return repositories;
}
代码示例来源:origin: stackoverflow.com
Map<String, Profile> profilesMap = effectiveSettings.getProfilesAsMap();
Collection<RemoteRepository> remotes = new ArrayList<>(20);
for (String profileName : effectiveSettings.getActiveProfiles())
代码示例来源:origin: org.jboss.forge/maven-impl
public List<RemoteRepository> getEnabledRepositoriesFromProfile(Settings settings)
{
List<RemoteRepository> settingsRepos = new ArrayList<RemoteRepository>();
List<String> activeProfiles = settings.getActiveProfiles();
Map<String, Profile> profiles = settings.getProfilesAsMap();
for (String id : activeProfiles)
{
Profile profile = profiles.get(id);
if (profile != null)
{
List<Repository> repositories = profile.getRepositories();
for (Repository repository : repositories)
{
settingsRepos.add(new RemoteRepository(repository.getId(), repository.getLayout(), repository.getUrl()));
}
}
}
return settingsRepos;
}
代码示例来源:origin: io.squark.yggdrasil/yggdrasil-maven-provider
remoteRepositories = new ArrayList<>();
Map<String, Profile> mavenProfiles = mavenSettings.getProfilesAsMap();
List<String> activeMavenProfiles = mavenSettings.getActiveProfiles();
if (activeMavenProfiles.size() == 0) {
代码示例来源:origin: spring-cloud/spring-cloud-function
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;
}
代码示例来源:origin: org.springframework.boot/spring-boot-cli
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<>();
Map<String, Profile> profiles = settings.getProfilesAsMap();
for (org.apache.maven.model.Profile modelProfile : activeModelProfiles) {
activeProfiles.add(profiles.get(modelProfile.getId()));
}
return activeProfiles;
}
代码示例来源:origin: org.jboss.galleon/galleon-cli
private static List<RemoteRepository> buildRemoteRepositories(Settings settings) throws ArtifactException {
Map<String, Profile> profiles = settings.getProfilesAsMap();
Map<String, RemoteRepository> repos = new LinkedHashMap<>();
List<RemoteRepository> repositories = new ArrayList<>();
代码示例来源:origin: org.springframework.boot.experimental/spring-boot-thin-launcher
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;
}
代码示例来源:origin: opoo/opoopress
private String getPropertyValue(String propertyName) throws MojoFailureException {
Map<String, Profile> profiles = settings.getProfilesAsMap();
List<String> activeProfiles = settings.getActiveProfiles();
for(String id: activeProfiles){
Profile profile = profiles.get(id);
if(profile != null){
Properties properties = profile.getProperties();
if(properties != null){
String property = properties.getProperty(propertyName);
if(property != null){
getLog().info("Resolve deploy repository url: " + propertyName + " => " + property);
return property;
}
}
}
}
for(Profile profile: settings.getProfiles()){
if(profile.getActivation() != null && profile.getActivation().isActiveByDefault()){
Properties properties = profile.getProperties();
if(properties != null){
String property = properties.getProperty(propertyName);
if(property != null){
getLog().info("Resolve deploy repository url: " + propertyName + " => " + property);
return property;
}
}
}
}
throw new MojoFailureException("Can not resolve deploy repository url: " + propertyName);
}
代码示例来源:origin: de.julielab/julielab-maven-aether-utilities
public static List<RemoteRepository> getRemoteRepositoriesFromSettings() throws SettingsBuildingException {
Settings effectiveSettings = getMavenSettings();
Map<String, Authentication> authenticationMap = getRepositoryAuthenticationsFromMavenSettings();
Map<String, Profile> profilesMap = effectiveSettings.getProfilesAsMap();
List<RemoteRepository> remotes = new ArrayList<>(20);
for (String profileName : effectiveSettings.getActiveProfiles()) {
Profile profile = profilesMap.get(profileName);
if (profile != null) {
List<Repository> repositories = profile.getRepositories();
for (Repository repo : repositories) {
Authentication auth = authenticationMap.get(repo.getId());
RemoteRepository.Builder repoBuilder = new RemoteRepository.Builder(repo.getId(), "default", repo.getUrl());
if (auth != null)
repoBuilder.setAuthentication(auth);
repoBuilder.setSnapshotPolicy(new RepositoryPolicy(true, RepositoryPolicy.UPDATE_POLICY_ALWAYS, RepositoryPolicy.CHECKSUM_POLICY_WARN));
RemoteRepository remoteRepo
= repoBuilder.build();
remotes.add(remoteRepo);
}
}
}
if (log.isTraceEnabled()) {
remotes.forEach(r -> log.trace("Getting repository from Maven settings: {}", r));
}
return remotes;
}
代码示例来源:origin: apache/karaf
Map<String, Profile> profiles = (Map<String, Profile>)mavenSettings.getProfilesAsMap();
profiles.values().stream()
.filter((profile) -> profile.getActivation() != null && profile.getActivation().isActiveByDefault())
代码示例来源:origin: org.jboss.forge.furnace/furnace-manager-resolver-maven
Map<String, Profile> profiles = settings.getProfilesAsMap();
代码示例来源:origin: coherence-community/oracle-bedrock
Map<String, org.apache.maven.settings.Profile> profiles = settings.getProfilesAsMap();
ArrayList<RemoteRepository> remoteRepositories = new ArrayList<>(20);
代码示例来源:origin: com.remondis.limbus/limbus-engine-impl
Map<String, Profile> profilesMap = effectiveSettings.getProfilesAsMap();
代码示例来源:origin: com.atlassian.testtools/atlassian-testtools
for (final Repository repository : (List<Repository>) ((Map<String, Profile>) settings.getProfilesAsMap()).get(profileId).getRepositories())
内容来源于网络,如有侵权,请联系作者删除!