org.apache.maven.settings.Profile类的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(9.9k)|赞(0)|评价(0)|浏览(106)

本文整理了Java中org.apache.maven.settings.Profile类的一些代码示例,展示了Profile类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Profile类的具体详情如下:
包路径:org.apache.maven.settings.Profile
类名称:Profile

Profile介绍

[英]Modifications to the build process which is keyed on some sort of environmental parameter.
[中]对构建过程的修改取决于某种环境参数。

代码示例

代码示例来源:origin: apache/maven

if ( profile.getActivation() != null )
  writeActivation( (Activation) profile.getActivation(), "activation", serializer );
if ( ( profile.getProperties() != null ) && ( profile.getProperties().size() > 0 ) )
  for ( Iterator iter = profile.getProperties().keySet().iterator(); iter.hasNext(); )
    String value = (String) profile.getProperties().get( key );
    serializer.startTag( NAMESPACE, "" + key + "" ).text( value ).endTag( NAMESPACE, "" + key + "" );
if ( ( profile.getRepositories() != null ) && ( profile.getRepositories().size() > 0 ) )
  for ( Iterator iter = profile.getRepositories().iterator(); iter.hasNext(); )
if ( ( profile.getPluginRepositories() != null ) && ( profile.getPluginRepositories().size() > 0 ) )
  for ( Iterator iter = profile.getPluginRepositories().iterator(); iter.hasNext(); )
if ( ( profile.getId() != null ) && !profile.getId().equals( "default" ) )
  serializer.startTag( NAMESPACE, "id" ).text( profile.getId() ).endTag( NAMESPACE, "id" );

代码示例来源:origin: apache/maven

Profile profile = new Profile();
for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
    profile.setActivation( parseActivation( parser, strict ) );
      profile.addProperty( key, value );
    profile.setRepositories( repositories );
    while ( parser.nextTag() == XmlPullParser.START_TAG )
    profile.setPluginRepositories( pluginRepositories );
    while ( parser.nextTag() == XmlPullParser.START_TAG )
    profile.setId( interpolatedTrimmed( parser.nextText(), "id" ) );

代码示例来源:origin: apache/maven

if ( !profileIds.add( profile.getId() ) )
         "must be unique but found duplicate profile with id " + profile.getId() );
String prefix = "profiles.profile[" + profile.getId() + "].";
validateRepositories( problems, profile.getRepositories(), prefix + "repositories.repository" );
validateRepositories( problems, profile.getPluginRepositories(), prefix
  + "pluginRepositories.pluginRepository" );

代码示例来源: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.uberfire/uberfire-maven-integration

private boolean isProfileActive( Profile profile ) {
  return settings.getActiveProfiles().contains( profile.getId() ) ||
      ( profile.getActivation() != null && profile.getActivation().isActiveByDefault() );
}

代码示例来源:origin: apache/maven

/**
 * Method addRepository.
 * 
 * @param repository
 */
public void addRepository( Repository repository )
{
  getRepositories().add( repository );
} //-- void addRepository( Repository )

代码示例来源:origin: org.jboss.forge.addon/maven-api

public ProfileAdapter(final org.apache.maven.settings.Profile profile)
{
 setId(profile.getId());
 Activation activation = new Activation();
 setActivation(activation);
 for (org.apache.maven.settings.Repository repository : profile.getRepositories())
 {
   Repository mavenRepository = new Repository();
   mavenRepository.setId(repository.getId());
   mavenRepository.setUrl(repository.getUrl());
   getRepositories().add(mavenRepository);
 }
 setProperties(profile.getProperties());
}

代码示例来源:origin: apache/maven

/**
 * @return a Map of profiles field with <code>Profile#getId()</code> as key
 * @see org.apache.maven.settings.Profile#getId()
 */
public java.util.Map<String, Profile> getProfilesAsMap()
{
  if ( profileMap == null )
  {
    profileMap = new java.util.LinkedHashMap<String, Profile>();
    if ( getProfiles() != null )
    {
      for ( Profile profile : getProfiles() )
      {
        profileMap.put( profile.getId(), profile );
      }
    }
  }
  return profileMap;
}

代码示例来源:origin: io.squark.yggdrasil/yggdrasil-maven-provider

if (activeMavenProfiles.size() == 0) {
  for (Map.Entry<String, Profile> profile : mavenProfiles.entrySet()) {
    if (profile.getValue().getActivation() != null && profile.getValue().getActivation().isActiveByDefault()) {
      activeMavenProfiles.add(profile.getKey());
for (String activeProfile : activeMavenProfiles) {
  Profile profile = mavenProfiles.get(activeProfile);
  List<Repository> profileRepositories = profile.getRepositories();
  for (Repository repository : profileRepositories) {
    RemoteRepository remoteRepository = new RemoteRepository.Builder(repository.getId(), "default",

代码示例来源:origin: apache/karaf

if (profile.getRepositories().stream().anyMatch((r) -> id.equals(r.getId()))) {
  List<Repository> newRepos = profile.getRepositories().stream()
      .filter((r) -> !id.equals(r.getId())).collect(Collectors.toList());
  profile.setRepositories(newRepos);
  System.out.printf("Repository with ID \"%s\" was removed from profile \"%s\"\n", id, profile.getId());
  break;

代码示例来源:origin: org.kie.soup/kie-soup-maven-integration

private Collection<RemoteRepository> initExtraRepositories() {
  Collection<RemoteRepository> extraRepositories = new HashSet<RemoteRepository>();
  for ( Profile profile : settings.getProfiles() ) {
    if ( isProfileActive( profile ) ) {
      for ( Repository repository : profile.getRepositories() ) {
        extraRepositories.add( toRemoteRepositoryBuilder( settings,
                                 repository ).build() );
      }
      for ( Repository repository : profile.getPluginRepositories() ) {
        extraRepositories.add( toRemoteRepositoryBuilder( settings,
                                 repository ).build() );
      }
    }
  }
  return extraRepositories;
}

代码示例来源:origin: com.itemis.maven.plugins/unleash-maven-plugin

if (!this.profiles.contains(profile.getId())) {
 continue;
for (Map.Entry<Object, Object> entry : profile.getProperties().entrySet()) {
 this.properties.put((String) entry.getKey(), (String) entry.getValue());

代码示例来源:origin: org.eclipse.hudson.main/maven3-eventspy-3.0

private static void logSettingsProfileList( List<org.apache.maven.settings.Profile> profiles, String type )
  {
    log.debug( String.format( "%s %s profiles.", type, profiles.size() ) );
    for ( org.apache.maven.settings.Profile profile : profiles )
    {
      log.debug( "  {}", String.format("Profile {id: %s, source: %s}", profile.getId(), profile.getSourceLevel() ) );
    }
  }
}

代码示例来源:origin: org.springframework.boot/spring-boot-cli

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));
    }
  }
}

代码示例来源: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: apache/maven

Profile profile = new Profile();
profile.setId( modelProfile.getId() );
  profile.setActivation( activation );
profile.setProperties( modelProfile.getProperties() );
    profile.addRepository( convertToSettingsRepository( repo ) );
    profile.addPluginRepository( convertToSettingsRepository( pluginRepo ) );

代码示例来源:origin: apache/maven

/**
 * Method addProperty.
 * 
 * @param key
 * @param value
 */
public void addProperty( String key, String value )
{
  getProperties().put( key, value );
} //-- void addProperty( String, String )

代码示例来源:origin: io.teecube.t3/t3-site-enhancer

public org.apache.maven.settings.Profile getFullSampleProfile(String id, Properties profileProperties) {
  org.apache.maven.settings.Profile profile = new org.apache.maven.settings.Profile();
  profile.setId(id);
  for (GlobalParameter globalParameter : globalParameters) {
    if (!globalParameter.valueGuessedByDefault) {
      String value;
      if (profileProperties.containsKey(globalParameter.property)) {
        value = profileProperties.getProperty(globalParameter.property);
      } else {
        value = "[...]";
      }
      profile.getProperties().put(globalParameter.property, value);
    }
  }
  return profile;
}

代码示例来源:origin: apache/maven

/**
 * Method addPluginRepository.
 * 
 * @param repository
 */
public void addPluginRepository( Repository repository )
{
  getPluginRepositories().add( repository );
} //-- void addPluginRepository( Repository )

代码示例来源:origin: org.codehaus.mevenide/nb-project

Profile myProfile = new Profile();
if (repoRoot != null) {
  myProfile.setId(PROFILE_PUBLIC);//NOI18N
  Repository repo = new Repository();
  repo.setUrl("file://" + repoRoot.getAbsolutePath());//NOI18N
  repo.setSnapshots(snap);
  repo.setName("NetBeans IDE internal Repository hosting plugins that are executable in NetBeans IDE only.");//NOI18N
  myProfile.addPluginRepository(repo);
  Activation act = new Activation();
  ActivationProperty prop = new ActivationProperty();
  prop.setValue("true");//NOI18N
  act.setProperty(prop);
  myProfile.setActivation(act);

相关文章