当前位置: 首页>>代码示例>>Java>>正文


Java Profile.getActivation方法代码示例

本文整理汇总了Java中org.apache.maven.model.Profile.getActivation方法的典型用法代码示例。如果您正苦于以下问题:Java Profile.getActivation方法的具体用法?Java Profile.getActivation怎么用?Java Profile.getActivation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.maven.model.Profile的用法示例。


在下文中一共展示了Profile.getActivation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isActive

import org.apache.maven.model.Profile; //导入方法依赖的package包/类
public boolean isActive( Profile profile )
{
    Activation activation = profile.getActivation();
    ActivationOS os = activation.getOs();

    boolean result = ensureAtLeastOneNonNull( os );

    if ( result && os.getFamily() != null )
    {
        result = determineFamilyMatch( os.getFamily() );
    }
    if ( result && os.getName() != null )
    {
        result = determineNameMatch( os.getName() );
    }
    if ( result && os.getArch() != null )
    {
        result = determineArchMatch( os.getArch() );
    }
    if ( result && os.getVersion() != null )
    {
        result = determineVersionMatch( os.getVersion() );
    }
    return result;
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:26,代码来源:OperatingSystemProfileActivator.java

示例2: addProfile

import org.apache.maven.model.Profile; //导入方法依赖的package包/类
public void addProfile( Profile profile )
{
    String profileId = profile.getId();

    Profile existing = (Profile) profilesById.get( profileId );
    if ( existing != null )
    {
        logger.warn( "Overriding profile: \'" + profileId + "\' (source: " + existing.getSource()
            + ") with new instance from source: " + profile.getSource() );
    }

    profilesById.put( profile.getId(), profile );

    Activation activation = profile.getActivation();

    if ( activation != null && activation.isActiveByDefault() )
    {
        activateAsDefault( profileId );
    }
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:21,代码来源:DefaultProfileManager.java

示例3: activateProfilesWithProperties

import org.apache.maven.model.Profile; //导入方法依赖的package包/类
private List<String> activateProfilesWithProperties(MavenProject mavenProject, List<String> activeProfileIds) {
	if (mavenProject == null) return activeProfileIds;
	List<String> result = new ArrayList<String>();
	if (activeProfileIds != null) {
		result.addAll(activeProfileIds);
	}

	for (Profile profile : mavenProject.getModel().getProfiles()) {
		Activation activation = profile.getActivation();
		if (activation != null) {
			ActivationProperty property = activation.getProperty();
			if (property != null) {
				String name = property.getName();
				if (name != null) {
					String value;
					if (name.startsWith("!")) {
						value = propertiesManager.getPropertyValue(name.substring(1));
					} else {
						value = propertiesManager.getPropertyValue(name);
					}
					if (value != null) {
						if (!name.startsWith("!") && value.equals(property.getValue()) || name.startsWith("!") && !value.equals(property.getValue())) {
							result.add(profile.getId());
						}
					}
				}
			}
		}
	}

	return result;
}
 
开发者ID:fastconnect,项目名称:tibco-bwmaven,代码行数:33,代码来源:BWLifecycleParticipant.java

示例4: transformableWithDiscardActiveReference

import org.apache.maven.model.Profile; //导入方法依赖的package包/类
@SuppressWarnings({"unchecked"})
public void transformableWithDiscardActiveReference() throws IOException {

    PomTransformer pomTransformer = new PomTransformer(transformablePomAsString,
            PomCleanupPolicy.discard_active_reference);
    String transformedPom = pomTransformer.transform();

    Model pom = MavenModelUtils.stringToMavenModel(transformedPom);
    List repositoriesList = pom.getRepositories();
    List pluginsRepositoriesList = pom.getPluginRepositories();

    assertEmptyList(repositoriesList, pluginsRepositoriesList);

    List<Profile> pomProfiles = pom.getProfiles();
    for (Profile profile : pomProfiles) {
        boolean activeByDefault = false;
        Activation activation = profile.getActivation();
        if (activation != null) {
            activeByDefault = activation.isActiveByDefault();
        }
        List profileRepositories = profile.getRepositories();
        List profilePluginsRepositories = profile.getPluginRepositories();
        if (activeByDefault) {
            assertEmptyList(profileRepositories, profilePluginsRepositories);
        } else {
            assertNotEmptyList(profileRepositories, profilePluginsRepositories);
        }
    }
    assertTrue(transformablePomAsString.contains("This is a comment"));
    compareChecksums(transformablePomAsString, transformedPom, false);
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:32,代码来源:PomTransformerTest.java

示例5: addProfile

import org.apache.maven.model.Profile; //导入方法依赖的package包/类
/**
 * Add the profile to the list of profiles. If an existing profile has the same
 * id it is removed first.
 *
 * @param profiles Existing profiles
 * @param profile Target profile to add
 */
void addProfile( final List<Profile> profiles, final Profile profile )
{
    final Iterator<Profile> i = profiles.iterator();
    while ( i.hasNext() )
    {
        final Profile p = i.next();

        if ( profile.getId()
                    .equals( p.getId() ) )
        {
            logger.debug( "Removing local profile {} ", p );
            i.remove();
            // Don't break out of the loop so we can check for active profiles
        }

        // If we have injected profiles and one of the current profiles is using
        // activeByDefault it will get mistakingly deactivated due to the semantics
        // of activeByDefault. Therefore replace the activation.
        if (p.getActivation() != null && p.getActivation().isActiveByDefault())
        {
            logger.warn( "Profile {} is activeByDefault", p );

            final Activation replacement = new Activation();
            final ActivationProperty replacementProp = new ActivationProperty();
            replacementProp.setName( "!disableProfileActivation" );
            replacement.setProperty( replacementProp );

            p.setActivation( replacement );
        }
    }

    logger.debug( "Adding profile {}", profile );
    profiles.add( profile );
}
 
开发者ID:release-engineering,项目名称:pom-manipulation-ext,代码行数:42,代码来源:ProfileInjectionManipulator.java

示例6: isActive

import org.apache.maven.model.Profile; //导入方法依赖的package包/类
public boolean isActive( Profile profile )
    throws ProfileActivationException
{
    Activation activation = profile.getActivation();

    String jdk = activation.getJdk();

    // null case is covered by canDetermineActivation(), so we can do a straight startsWith() here.
    if ( jdk.startsWith( "[" ) || jdk.startsWith( "(" ) )
    {
        try
        {
            return matchJdkVersionRange( jdk );
        }
        catch ( InvalidVersionSpecificationException e )
        {
            throw new ProfileActivationException( "Invalid JDK version in profile '" + profile.getId() + "': "
                + e.getMessage() );
        }
    }

    boolean reverse = false;

    if ( jdk.startsWith( "!" ) )
    {
        reverse = true;
        jdk = jdk.substring( 1 );
    }

    if ( getJdkVersion().startsWith( jdk ) )
    {
        return !reverse;
    }
    else
    {
        return reverse;
    }
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:39,代码来源:JdkPrefixProfileActivator.java

示例7: isActive

import org.apache.maven.model.Profile; //导入方法依赖的package包/类
public boolean isActive( Profile profile, ProfileActivationContext context, ModelProblemCollector problems )
{
    Activation activation = profile.getActivation();

    if ( activation == null )
    {
        return false;
    }

    String jdk = activation.getJdk();

    if ( jdk == null )
    {
        return false;
    }

    String version = context.getSystemProperties().get( "java.version" );

    if ( version == null || version.length() <= 0 )
    {
        problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE )
                .setMessage( "Failed to determine Java version for profile " + profile.getId() )
                .setLocation(activation.getLocation( "jdk" ) ) );
        return false;
    }

    if ( jdk.startsWith( "!" ) )
    {
        return !version.startsWith( jdk.substring( 1 ) );
    }
    else if ( isRange( jdk ) )
    {
        return isInRange( version, getRange( jdk ) );
    }
    else
    {
        return version.startsWith( jdk );
    }
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:40,代码来源:JdkVersionProfileActivator.java

示例8: isActive

import org.apache.maven.model.Profile; //导入方法依赖的package包/类
public boolean isActive( Profile profile, ProfileActivationContext context, ModelProblemCollector problems )
{
    Activation activation = profile.getActivation();

    if ( activation == null )
    {
        return false;
    }

    ActivationOS os = activation.getOs();

    if ( os == null )
    {
        return false;
    }

    boolean active = ensureAtLeastOneNonNull( os );

    if ( active && os.getFamily() != null )
    {
        active = determineFamilyMatch( os.getFamily() );
    }
    if ( active && os.getName() != null )
    {
        active = determineNameMatch( os.getName() );
    }
    if ( active && os.getArch() != null )
    {
        active = determineArchMatch( os.getArch() );
    }
    if ( active && os.getVersion() != null )
    {
        active = determineVersionMatch( os.getVersion() );
    }

    return active;
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:38,代码来源:OperatingSystemProfileActivator.java

示例9: canDetectActivation

import org.apache.maven.model.Profile; //导入方法依赖的package包/类
protected boolean canDetectActivation( Profile profile )
{
    return profile.getActivation() != null && profile.getActivation().getFile() != null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:MyFileProfileActivator.java

示例10: applyProfiles

import org.apache.maven.model.Profile; //导入方法依赖的package包/类
public static ProfileApplicationResult applyProfiles(MavenModel model,
                                                     File basedir,
                                                     MavenExplicitProfiles explicitProfiles,
                                                     Collection<String> alwaysOnProfiles) throws RemoteException {
  Model nativeModel = MavenModelConverter.toNativeModel(model);

  Collection<String> enabledProfiles = explicitProfiles.getEnabledProfiles();
  Collection<String> disabledProfiles = explicitProfiles.getDisabledProfiles();
  List<Profile> activatedPom = new ArrayList<Profile>();
  List<Profile> activatedExternal = new ArrayList<Profile>();
  List<Profile> activeByDefault = new ArrayList<Profile>();

  List<Profile> rawProfiles = nativeModel.getProfiles();
  List<Profile> expandedProfilesCache = null;
  List<Profile> deactivatedProfiles = new ArrayList<Profile>();

  for (int i = 0; i < rawProfiles.size(); i++) {
    Profile eachRawProfile = rawProfiles.get(i);

    if (disabledProfiles.contains(eachRawProfile.getId())) {
      deactivatedProfiles.add(eachRawProfile);
      continue;
    }

    boolean shouldAdd = enabledProfiles.contains(eachRawProfile.getId()) || alwaysOnProfiles.contains(eachRawProfile.getId());

    Activation activation = eachRawProfile.getActivation();
    if (activation != null) {
      if (activation.isActiveByDefault()) {
        activeByDefault.add(eachRawProfile);
      }

      // expand only if necessary
      if (expandedProfilesCache == null) expandedProfilesCache = doInterpolate(nativeModel, basedir).getProfiles();
      Profile eachExpandedProfile = expandedProfilesCache.get(i);

      for (ProfileActivator eachActivator : getProfileActivators(basedir)) {
        try {
          if (eachActivator.canDetermineActivation(eachExpandedProfile) && eachActivator.isActive(eachExpandedProfile)) {
            shouldAdd = true;
            break;
          }
        }
        catch (ProfileActivationException e) {
          Maven3ServerGlobals.getLogger().warn(e);
        }
      }
    }

    if (shouldAdd) {
      if (MavenConstants.PROFILE_FROM_POM.equals(eachRawProfile.getSource())) {
        activatedPom.add(eachRawProfile);
      }
      else {
        activatedExternal.add(eachRawProfile);
      }
    }
  }

  List<Profile> activatedProfiles = new ArrayList<Profile>(activatedPom.isEmpty() ? activeByDefault : activatedPom);
  activatedProfiles.addAll(activatedExternal);

  for (Profile each : activatedProfiles) {
    new DefaultProfileInjector().injectProfile(nativeModel, each, null, null);
  }

  return new ProfileApplicationResult(MavenModelConverter.convertModel(nativeModel, null),
                                      new MavenExplicitProfiles(collectProfilesIds(activatedProfiles),
                                                                collectProfilesIds(deactivatedProfiles))
  );
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:72,代码来源:Maven30ServerEmbedderImpl.java

示例11: applyProfiles

import org.apache.maven.model.Profile; //导入方法依赖的package包/类
public static ProfileApplicationResult applyProfiles(MavenModel model,
                                                     File basedir,
                                                     MavenExplicitProfiles explicitProfiles,
                                                     Collection<String> alwaysOnProfiles) throws RemoteException {
  Model nativeModel = Maven2ModelConverter.toNativeModel(model);

  Collection<String> enabledProfiles = explicitProfiles.getEnabledProfiles();
  Collection<String> disabledProfiles = explicitProfiles.getDisabledProfiles();
  List<Profile> activatedPom = new ArrayList<Profile>();
  List<Profile> activatedExternal = new ArrayList<Profile>();
  List<Profile> activeByDefault = new ArrayList<Profile>();

  List<Profile> rawProfiles = nativeModel.getProfiles();
  List<Profile> expandedProfilesCache = null;
  List<Profile> deactivatedProfiles = new ArrayList<Profile>();

  for (int i = 0; i < rawProfiles.size(); i++) {
    Profile eachRawProfile = rawProfiles.get(i);

    if (disabledProfiles.contains(eachRawProfile.getId())) {
      deactivatedProfiles.add(eachRawProfile);
      continue;
    }

    boolean shouldAdd = enabledProfiles.contains(eachRawProfile.getId()) || alwaysOnProfiles.contains(eachRawProfile.getId());

    Activation activation = eachRawProfile.getActivation();
    if (activation != null) {
      if (activation.isActiveByDefault()) {
        activeByDefault.add(eachRawProfile);
      }

      // expand only if necessary
      if (expandedProfilesCache == null) expandedProfilesCache = doInterpolate(nativeModel, basedir).getProfiles();
      Profile eachExpandedProfile = expandedProfilesCache.get(i);

      for (ProfileActivator eachActivator : getProfileActivators(basedir)) {
        try {
          if (eachActivator.canDetermineActivation(eachExpandedProfile) && eachActivator.isActive(eachExpandedProfile)) {
            shouldAdd = true;
            break;
          }
        }
        catch (ProfileActivationException e) {
          Maven2ServerGlobals.getLogger().warn(e);
        }
      }
    }

    if (shouldAdd) {
      if (MavenConstants.PROFILE_FROM_POM.equals(eachRawProfile.getSource())) {
        activatedPom.add(eachRawProfile);
      }
      else {
        activatedExternal.add(eachRawProfile);
      }
    }
  }

  List<Profile> activatedProfiles = new ArrayList<Profile>(activatedPom.isEmpty() ? activeByDefault : activatedPom);
  activatedProfiles.addAll(activatedExternal);

  for (Profile each : activatedProfiles) {
    new DefaultProfileInjector().inject(each, nativeModel);
  }

  return new ProfileApplicationResult(Maven2ModelConverter.convertModel(nativeModel, null),
                                      new MavenExplicitProfiles(collectProfilesIds(activatedProfiles),
                                                                collectProfilesIds(deactivatedProfiles))
  );
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:72,代码来源:Maven2ServerEmbedderImpl.java

示例12: canDetectActivation

import org.apache.maven.model.Profile; //导入方法依赖的package包/类
protected boolean canDetectActivation(Profile profile) {
  return profile.getActivation() != null && profile.getActivation().getFile() != null;
}
 
开发者ID:eclipse,项目名称:che,代码行数:4,代码来源:MavenFileProfileActivator.java

示例13: applyProfiles

import org.apache.maven.model.Profile; //导入方法依赖的package包/类
public static ProfileApplicationResult applyProfiles(MavenModel model,
                                                     File basedir,
                                                     Collection<String> explicitProfiles,
                                                     Collection<String> alwaysOnProfiles) throws RemoteException {
  Model nativeModel = MavenModelConverter.toNativeModel(model);

  List<Profile> activatedPom = new ArrayList<Profile>();
  List<Profile> activatedExternal = new ArrayList<Profile>();
  List<Profile> activeByDefault = new ArrayList<Profile>();

  List<Profile> rawProfiles = nativeModel.getProfiles();
  List<Profile> expandedProfilesCache = null;

  for (int i = 0; i < rawProfiles.size(); i++) {
    Profile eachRawProfile = rawProfiles.get(i);

    boolean shouldAdd = explicitProfiles.contains(eachRawProfile.getId()) || alwaysOnProfiles.contains(eachRawProfile.getId());

    Activation activation = eachRawProfile.getActivation();
    if (activation != null) {
      if (activation.isActiveByDefault()) {
        activeByDefault.add(eachRawProfile);
      }

      // expand only if necessary
      if (expandedProfilesCache == null) expandedProfilesCache = doInterpolate(nativeModel, basedir).getProfiles();
      Profile eachExpandedProfile = expandedProfilesCache.get(i);

      for (ProfileActivator eachActivator : getProfileActivators(basedir)) {
        try {
          if (eachActivator.canDetermineActivation(eachExpandedProfile) && eachActivator.isActive(eachExpandedProfile)) {
            shouldAdd = true;
            break;
          }
        }
        catch (ProfileActivationException e) {
          Maven3ServerGlobals.getLogger().warn(e);
        }
      }
    }

    if (shouldAdd) {
      if (MavenConstants.PROFILE_FROM_POM.equals(eachRawProfile.getSource())) {
        activatedPom.add(eachRawProfile);
      }
      else {
        activatedExternal.add(eachRawProfile);
      }
    }
  }

  List<Profile> activatedProfiles = new ArrayList<Profile>(activatedPom.isEmpty() ? activeByDefault : activatedPom);
  activatedProfiles.addAll(activatedExternal);

  for (Profile each : activatedProfiles) {
    new DefaultProfileInjector().injectProfile(nativeModel, each, null, null);
  }

  return new ProfileApplicationResult(MavenModelConverter.convertModel(nativeModel, null),
                                      collectProfilesIds(activatedProfiles));
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:62,代码来源:Maven3ServerEmbedderImpl.java

示例14: applyProfiles

import org.apache.maven.model.Profile; //导入方法依赖的package包/类
public static ProfileApplicationResult applyProfiles(MavenModel model,
                                                     File basedir,
                                                     Collection<String> explicitProfiles,
                                                     Collection<String> alwaysOnProfiles) throws RemoteException {
  Model nativeModel = Maven2ModelConverter.toNativeModel(model);

  List<Profile> activatedPom = new ArrayList<Profile>();
  List<Profile> activatedExternal = new ArrayList<Profile>();
  List<Profile> activeByDefault = new ArrayList<Profile>();

  List<Profile> rawProfiles = nativeModel.getProfiles();
  List<Profile> expandedProfilesCache = null;

  for (int i = 0; i < rawProfiles.size(); i++) {
    Profile eachRawProfile = rawProfiles.get(i);

    boolean shouldAdd = explicitProfiles.contains(eachRawProfile.getId()) || alwaysOnProfiles.contains(eachRawProfile.getId());

    Activation activation = eachRawProfile.getActivation();
    if (activation != null) {
      if (activation.isActiveByDefault()) {
        activeByDefault.add(eachRawProfile);
      }

      // expand only if necessary
      if (expandedProfilesCache == null) expandedProfilesCache = doInterpolate(nativeModel, basedir).getProfiles();
      Profile eachExpandedProfile = expandedProfilesCache.get(i);

      for (ProfileActivator eachActivator : getProfileActivators(basedir)) {
        try {
          if (eachActivator.canDetermineActivation(eachExpandedProfile) && eachActivator.isActive(eachExpandedProfile)) {
            shouldAdd = true;
            break;
          }
        }
        catch (ProfileActivationException e) {
          Maven2ServerGlobals.getLogger().warn(e);
        }
      }
    }

    if (shouldAdd) {
      if (MavenConstants.PROFILE_FROM_POM.equals(eachRawProfile.getSource())) {
        activatedPom.add(eachRawProfile);
      }
      else {
        activatedExternal.add(eachRawProfile);
      }
    }
  }

  List<Profile> activatedProfiles = new ArrayList<Profile>(activatedPom.isEmpty() ? activeByDefault : activatedPom);
  activatedProfiles.addAll(activatedExternal);

  for (Profile each : activatedProfiles) {
    new DefaultProfileInjector().inject(each, nativeModel);
  }

  return new ProfileApplicationResult(Maven2ModelConverter.convertModel(nativeModel, null),
                                      collectProfilesIds(activatedProfiles));
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:62,代码来源:Maven2ServerEmbedderImpl.java

示例15: canDetectActivation

import org.apache.maven.model.Profile; //导入方法依赖的package包/类
protected boolean canDetectActivation( Profile profile )
{
    return profile.getActivation() != null && profile.getActivation().getProperty() != null;
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:5,代码来源:SystemPropertyProfileActivator.java


注:本文中的org.apache.maven.model.Profile.getActivation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。