Java 类org.apache.maven.model.Profile 实例源码

项目:incubator-netbeans    文件:NBModelBuilder.java   
@Override
public ModelBuildingResult build(ModelBuildingRequest request) throws ModelBuildingException {
    ModelBuildingResult toRet = super.build(request);
    Model eff = toRet.getEffectiveModel();
    InputSource source = new InputSource();
    source.setLocation("");
    InputLocation location = new InputLocation(-1, -1, source);
    eff.setLocation(NETBEANS_PROFILES, location);
    for (String id : toRet.getModelIds()) {
        Model mdl = toRet.getRawModel(id);
        for (Profile p : mdl.getProfiles()) {
            source.setLocation(source.getLocation() + "|" + p.getId());
        }
    }
    return toRet;
}
项目:apache-maven-shade-plugin    文件:MavenJDOMWriter.java   
/**
 * Method updateProfile
 *
 * @param value
 * @param element
 * @param counter
 * @param xmlTag
 */
protected void updateProfile( Profile value, String xmlTag, Counter counter, Element element )
{
    Element root = element;
    Counter innerCount = new Counter( counter.getDepth() + 1 );
    findAndReplaceSimpleElement( innerCount, root, "id", value.getId(), "default" );
    // updateActivation( value.getActivation(), "activation", innerCount, root);
    updateBuildBase( value.getBuild(), "build", innerCount, root );
    findAndReplaceSimpleLists( innerCount, root, value.getModules(), "modules", "module" );
    iterateRepository( innerCount, root, value.getRepositories(), "repositories", "repository" );
    iterateRepository( innerCount, root, value.getPluginRepositories(), "pluginRepositories", "pluginRepository" );
    iterateDependency( innerCount, root, value.getDependencies(), "dependencies", "dependency" );
    findAndReplaceXpp3DOM( innerCount, root, "reports", (Xpp3Dom) value.getReports() );
    updateReporting( value.getReporting(), "reporting", innerCount, root );
    updateDependencyManagement( value.getDependencyManagement(), "dependencyManagement", innerCount, root );
    updateDistributionManagement( value.getDistributionManagement(), "distributionManagement", innerCount, root );
    findAndReplaceProperties( innerCount, root, "properties", value.getProperties() );
}
项目:spring-cloud-stream-app-maven-plugin    文件:MavenModelUtils.java   
public static void addProfiles(Model pomModel) {
    Profile profile = new Profile();
    profile.setId("milestone");
    DistributionManagement milestoneDistManagement = new DistributionManagement();

    DeploymentRepository milestoneRepo = new DeploymentRepository();
    milestoneRepo.setId("repo.spring.io");
    milestoneRepo.setName("Spring Milestone Repository");
    milestoneRepo.setUrl("https://repo.spring.io/libs-milestone-local");
    milestoneDistManagement.setRepository(milestoneRepo);
    profile.setDistributionManagement(milestoneDistManagement);
    List<Profile> profiles = new ArrayList<>();
    profiles.add(profile);

    profiles.add(centralProfile());

    pomModel.setProfiles(profiles);
}
项目:unleash-maven-plugin    文件:CheckPluginDependencyVersions.java   
private Multimap<ArtifactCoordinates, ArtifactCoordinates> getSnapshotsFromManagement(Profile profile,
    PomPropertyResolver propertyResolver) {
  this.log.debug("\t\tChecking managed plugins of profile '" + profile.getId() + "'");
  Multimap<ArtifactCoordinates, ArtifactCoordinates> result = HashMultimap.create();
  BuildBase build = profile.getBuild();
  if (build != null) {
    PluginManagement pluginManagement = build.getPluginManagement();
    if (pluginManagement != null) {
      for (Plugin plugin : pluginManagement.getPlugins()) {
        Collection<Dependency> snapshots = Collections2.filter(plugin.getDependencies(),
            new IsSnapshotDependency(propertyResolver));
        if (!snapshots.isEmpty()) {
          result.putAll(PluginToCoordinates.INSTANCE.apply(plugin),
              Collections2.transform(snapshots, DependencyToCoordinates.INSTANCE));
        }
      }
    }
  }
  return result;
}
项目:unleash-maven-plugin    文件:CheckPluginDependencyVersions.java   
private Multimap<ArtifactCoordinates, ArtifactCoordinates> getSnapshots(Profile profile,
    PomPropertyResolver propertyResolver) {
  this.log.debug("\t\tChecking direct plugin references of profile '" + profile.getId() + "'");
  Multimap<ArtifactCoordinates, ArtifactCoordinates> result = HashMultimap.create();
  BuildBase build = profile.getBuild();
  if (build != null) {
    for (Plugin plugin : build.getPlugins()) {
      Collection<Dependency> snapshots = Collections2.filter(plugin.getDependencies(),
          new IsSnapshotDependency(propertyResolver));
      if (!snapshots.isEmpty()) {
        result.putAll(PluginToCoordinates.INSTANCE.apply(plugin),
            Collections2.transform(snapshots, DependencyToCoordinates.INSTANCE));
      }
    }
  }
  return result;
}
项目:intellij-ce-playground    文件:Maven30ServerEmbedderImpl.java   
private static Collection<String> collectActivatedProfiles(MavenProject mavenProject)
  throws RemoteException {
  // for some reason project's active profiles do not contain parent's profiles - only local and settings'.
  // parent's profiles do not contain settings' profiles.

  List<Profile> profiles = new ArrayList<Profile>();
  try {
    while (mavenProject != null) {
      profiles.addAll(mavenProject.getActiveProfiles());
      mavenProject = mavenProject.getParent();
    }
  }
  catch (Exception e) {
    // don't bother user if maven failed to build parent project
    Maven3ServerGlobals.getLogger().info(e);
  }
  return collectProfilesIds(profiles);
}
项目:intellij-ce-playground    文件:Maven32ServerEmbedderImpl.java   
private static Collection<String> collectActivatedProfiles(MavenProject mavenProject)
  throws RemoteException {
  // for some reason project's active profiles do not contain parent's profiles - only local and settings'.
  // parent's profiles do not contain settings' profiles.

  List<Profile> profiles = new ArrayList<Profile>();
  try {
    while (mavenProject != null) {
      profiles.addAll(mavenProject.getActiveProfiles());
      mavenProject = mavenProject.getParent();
    }
  }
  catch (Exception e) {
    // don't bother user if maven failed to build parent project
    Maven3ServerGlobals.getLogger().info(e);
  }
  return collectProfilesIds(profiles);
}
项目:tibco-bwmaven    文件:POMManager.java   
/**
 * Add a project as a module.
 * 
 * @param pom
 * @param relativePath
 * @param logger
 * @throws IOException
 * @throws XmlPullParserException
 */
public static void addProjectAsModule(File pom, String relativePath, String profileId, Log logger) throws IOException, XmlPullParserException {
    if (relativePath == null) return;

    Model model = getModelFromPOM(pom, logger);

    relativePath = relativePath.replace("\\", "/");

    if (profileId != null && !profileId.isEmpty()) {
        Profile p = getProfile(model, profileId);
        if (p != null) {
            p.addModule(relativePath);
        }
    } else {
        model.addModule(relativePath);
    }

    writeModelToPOM(model, pom, logger);
}
项目:tibco-bwmaven    文件:POMManager.java   
public static void removeProjectAsModule(File pom, String relativePath, String profileId, Log logger) throws IOException, XmlPullParserException {
    if (relativePath == null) return;

    Model model = getModelFromPOM(pom, logger);

    relativePath = relativePath.replace("\\", "/");
    if (profileId != null && !profileId.isEmpty()) {
        Profile p = getProfile(model, profileId);
        if (p != null) {
            p.removeModule(relativePath);
        }
    } else {
        model.removeModule(relativePath);
    }

    writeModelToPOM(model, pom, logger);
}
项目:tibco-bwmaven    文件:POMManager.java   
/**
 * Check whether a module exists in a POM.
 * 
 * @param rootPOM
 * @param relative
 * @param log
 * @return 
 * @throws XmlPullParserException 
 * @throws IOException 
 */
public static boolean moduleExists(File pom, String relativePath, String profileId, Log logger) throws IOException, XmlPullParserException {
    if (relativePath == null) return false;

    Model model = getModelFromPOM(pom, logger);

    relativePath = relativePath.replace("\\", "/");

    if (profileId != null && !profileId.isEmpty()) {
        Profile p = getProfile(model, profileId);
        if (p != null) {
            return p.getModules().indexOf(relativePath) >= 0;
        }
    } else {
        return model.getModules().indexOf(relativePath) >= 0;
    }

    return false;
}
项目:tibco-bwmaven    文件:GenerateRootDeploymentPOM.java   
private List<String> getActiveModules(List<Profile> activeProfiles, Model model) {
    List<String> modules = model.getModules();

    for (Profile profile : model.getProfiles()) {
        Boolean found = false;
        for (Profile p : activeProfiles) {
            if (p.getId().equals(profile.getId())) {
                found = true;
                break;
            }
        }
        if (!found) continue;

        for (String module : profile.getModules()) {
            if (modules.indexOf(module) < 0) {
                modules.add(module);
            }
        }
    }

    return modules;
}
项目:tibco-bwmaven    文件:GenerateRootDeploymentPOM.java   
private List<String> addModules(String basedir, Model model, List<Profile> activeProfiles, List<MavenProject> activeProjects) throws IOException, XmlPullParserException {
    List<String> result = new ArrayList<String>();

    List<String> modules = getActiveModules(activeProfiles, model);

    for (String module : modules) {
        String childFileName = basedir + module + File.separator + "pom.xml";
        if (!new File(childFileName).exists()) continue;

        // load the model of the module
        Model child = POMManager.getModelFromPOM(new File(childFileName), getLog());
        if (child.getPackaging().equals(BWEAR_TYPE)) { // add POMs with "bw-ear" packaging
            if (isProjectActive(child, activeProjects) != null) { // exclude inactive projects (if -am command line switch is used)

                String relativePath = getModuleRelativePath(child);
                result.add(applicationsRoot + MODULE_SEPARATOR + relativePath);
            }
        } else if (child.getPackaging().equals(POM_TYPE)) {
            // recursively add children found in POMs with "pom" packaging
            result.addAll(addModules(basedir + module + File.separator, child, activeProfiles, activeProjects));
        }
    }

    return result;
}
项目:properties-maven-plugin    文件:WriteActiveProfileProperties.java   
/** {@inheritDoc} */
public void execute()
    throws MojoExecutionException
{
    validateOutputFile();
    List<?> list = getProject().getActiveProfiles();
    if ( getLog().isInfoEnabled() )
    {
        getLog().debug( list.size() + " profile(s) active" );
    }
    Properties properties = new Properties();
    for ( Iterator<?> iter = list.iterator(); iter.hasNext(); )
    {
        Profile profile = (Profile) iter.next();
        if ( profile.getProperties() != null )
        {
            properties.putAll( profile.getProperties() );
        }
    }

    writeProperties( properties, getOutputFile() );
}
项目:ono-extra-enforcer-rules    文件:AbstractRule.java   
private Set<BuildBase> getDefinedActiveBuilds(MavenProject project) {
    HashSet<BuildBase> activeBuilds = new HashSet<>();
    final Model originalModel = project.getOriginalModel();
    final Build build = originalModel.getBuild();
    activeBuilds.add(build);

    final List<Profile> originalProfiles = originalModel.getProfiles();
    if (originalProfiles != null) {
        for (Profile profile : project.getActiveProfiles()) {
            // check active profile is defined in project
            for (Profile originalProfile : originalProfiles) {
                if (originalProfile.equals(profile)) {
                    activeBuilds.add(originalProfile.getBuild());
                }
            }
        }
    }
    // remove possible null entries
    activeBuilds.remove(null);
    return activeBuilds;
}
项目:che    文件:MavenServerImpl.java   
private List<String> getActiveProfiles(MavenProject project) throws RemoteException {
  List<Profile> profiles = new ArrayList<>();

  try {
    while (project != null) {
      profiles.addAll(project.getActiveProfiles());
      project = project.getParent();
    }
  } catch (Exception e) {
    MavenServerContext.getLogger().info(e);
  }

  return profiles
      .stream()
      .filter(p -> p.getId() != null)
      .map(Profile::getId)
      .collect(Collectors.toList());
}
项目:artifactory    文件:PomTransformerTest.java   
public void transformableWithDiscardAnyReference() throws IOException {
    PomTransformer pomTransformer = new PomTransformer(transformablePomAsString,
            PomCleanupPolicy.discard_any_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) {
        List profileRepositories = profile.getRepositories();
        List profilePluginsRepositories = profile.getPluginRepositories();

        assertEmptyList(profileRepositories, profilePluginsRepositories);
    }
    assertTrue(transformablePomAsString.contains("This is a comment"));
    compareChecksums(transformablePomAsString, transformedPom, false);
}
项目:maven-shade-plugin    文件:MavenJDOMWriter.java   
/**
 * Method updateProfile
 *
 * @param value
 * @param element
 * @param counter
 * @param xmlTag
 */
protected void updateProfile( Profile value, String xmlTag, Counter counter, Element element )
{
    Element root = element;
    Counter innerCount = new Counter( counter.getDepth() + 1 );
    findAndReplaceSimpleElement( innerCount, root, "id", value.getId(), "default" );
    // updateActivation( value.getActivation(), "activation", innerCount, root);
    updateBuildBase( value.getBuild(), "build", innerCount, root );
    findAndReplaceSimpleLists( innerCount, root, value.getModules(), "modules", "module" );
    iterateRepository( innerCount, root, value.getRepositories(), "repositories", "repository" );
    iterateRepository( innerCount, root, value.getPluginRepositories(), "pluginRepositories", "pluginRepository" );
    iterateDependency( innerCount, root, value.getDependencies(), "dependencies", "dependency" );
    findAndReplaceXpp3DOM( innerCount, root, "reports", (Xpp3Dom) value.getReports() );
    updateReporting( value.getReporting(), "reporting", innerCount, root );
    updateDependencyManagement( value.getDependencyManagement(), "dependencyManagement", innerCount, root );
    updateDistributionManagement( value.getDistributionManagement(), "distributionManagement", innerCount, root );
    findAndReplaceProperties( innerCount, root, "properties", value.getProperties() );
}
项目:pom-manipulation-ext    文件:Project.java   
public Map<String, Plugin> getPluginMap( final ModelBase base )
{
    final BuildBase build;
    if ( base instanceof Model )
    {
        build = ( (Model) base ).getBuild();
    }
    else
    {
        build = ( (Profile) base ).getBuild();
    }

    if ( build == null )
    {
        return Collections.emptyMap();
    }

    final Map<String, Plugin> result = build.getPluginsAsMap();
    if ( result == null )
    {
        return Collections.emptyMap();
    }

    return result;
}
项目:pom-manipulation-ext    文件:Project.java   
/**
 * This method will scan the dependencies in the potentially active Profiles in this project and
 * return a fully resolved list.  Note that this will only return full dependencies not managed
 * i.e. those with a group, artifact and version.
 *
 * Note that while updating the {@link Dependency} reference returned will be reflected in the
 * Model as it is the same object, if you wish to remove or add items to the Model then you
 * must use {@link #getModel()}
 *
 * @param session MavenSessionHandler, used by {@link PropertyResolver}
 * @return a list of fully resolved {@link ArtifactRef} to the original {@link Dependency}
 * @throws ManipulationException if an error occurs
 */
public HashMap<Profile, HashMap<ArtifactRef, Dependency>> getResolvedProfileDependencies( MavenSessionHandler session) throws ManipulationException
{
    if ( resolvedProfileDependencies == null )
    {
        resolvedProfileDependencies = new HashMap<>(  );

        for ( final Profile profile : ProfileUtils.getProfiles( session, model ) )
        {
            HashMap<ArtifactRef, Dependency> profileDeps = new HashMap<>();

            resolveDeps( session, profile.getDependencies(), false, profileDeps );

            resolvedProfileDependencies.put( profile, profileDeps );
        }
    }
    return resolvedProfileDependencies;
}
项目:pom-manipulation-ext    文件:Project.java   
/**
 * This method will scan the dependencies in the potentially active Profiles in this project and
 * return a fully resolved list. Note that this will return all dependencies including managed
 * i.e. those with a group, artifact and potentially empty version.
 *
 * Note that while updating the {@link Dependency} reference returned will be reflected in the
 * Model as it is the same object, if you wish to remove or add items to the Model then you
 * must use {@link #getModel()}
 *
 * @param session MavenSessionHandler, used by {@link PropertyResolver}
 * @return a list of fully resolved {@link ArtifactRef} to the original {@link Dependency}
 * @throws ManipulationException if an error occurs
 */
public HashMap<Profile, HashMap<ArtifactRef, Dependency>> getAllResolvedProfileDependencies( MavenSessionHandler session) throws ManipulationException
{
    if ( allResolvedProfileDependencies == null )
    {
        allResolvedProfileDependencies = new HashMap<>(  );

        for ( final Profile profile : ProfileUtils.getProfiles( session, model ) )
        {
            HashMap<ArtifactRef, Dependency> profileDeps = new HashMap<>();

            resolveDeps( session, profile.getDependencies(), true, profileDeps );

            allResolvedProfileDependencies.put( profile, profileDeps );
        }
    }
    return allResolvedProfileDependencies;
}
项目:pom-manipulation-ext    文件:Project.java   
/**
 * This method will scan the dependencies in the dependencyManagement section of the potentially active Profiles in
 * this project and return a fully resolved list. Note that while updating the {@link Dependency}
 * reference returned will be reflected in the Model as it is the same object, if you wish to remove or add items
 * to the Model then you must use {@link #getModel()}
 *
 * @param session MavenSessionHandler, used by {@link PropertyResolver}
 * @return a list of fully resolved {@link ArtifactRef} to the original {@link Dependency} (that were within DependencyManagement)
 * @throws ManipulationException if an error occurs
 */
public HashMap<Profile, HashMap<ArtifactRef, Dependency>> getResolvedProfileManagedDependencies( MavenSessionHandler session) throws ManipulationException
{
    if ( resolvedProfileManagedDependencies == null )
    {
        resolvedProfileManagedDependencies = new HashMap<>(  );

        for ( final Profile profile : ProfileUtils.getProfiles( session, model ) )
        {
            HashMap<ArtifactRef, Dependency> profileDeps = new HashMap<>();

            final DependencyManagement dm = profile.getDependencyManagement();
            if ( ! ( dm == null || dm.getDependencies() == null ) )
            {
                resolveDeps( session, dm.getDependencies(), false, profileDeps );

                resolvedProfileManagedDependencies.put( profile, profileDeps );
            }
        }
    }
    return resolvedProfileManagedDependencies;
}
项目:pom-manipulation-ext    文件:Project.java   
/**
 * This method will scan the plugins in the potentially active Profiles in this project and
 * return a fully resolved list. Note that while updating the {@link Plugin} reference
 * returned will be reflected in the Model as it is the same object, if you wish to
 * remove or add items to the Model then you must use {@link #getModel()}
 *
 * @param session MavenSessionHandler, used by {@link PropertyResolver}
 * @return a list of fully resolved {@link ProjectVersionRef} to the original {@link Plugin}
 * @throws ManipulationException if an error occurs
 */
public HashMap<Profile,HashMap<ProjectVersionRef,Plugin>> getResolvedProfilePlugins( MavenSessionHandler session )
                throws ManipulationException
{
    if ( resolvedProfilePlugins == null )
    {
        resolvedProfilePlugins = new HashMap<>();

        for ( final Profile profile : ProfileUtils.getProfiles( session, model ) )
        {
            HashMap<ProjectVersionRef, Plugin> profileDeps = new HashMap<>();

            if ( profile.getBuild() != null )
            {
                resolvePlugins( session, profile.getBuild().getPlugins(), profileDeps );

            }
            resolvedProfilePlugins.put( profile, profileDeps );
        }
    }
    return resolvedProfilePlugins;
}
项目:pom-manipulation-ext    文件:Project.java   
/**
 * This method will scan the plugins in the pluginManagement section in the potentially active Profiles
 * in this project and return a fully resolved list. Note that while updating the {@link Plugin}
 * reference returned will be reflected in the Model as it is the same object, if you wish to remove
 * or add items to the Model then you must use {@link #getModel()}
 *
 * @param session MavenSessionHandler, used by {@link PropertyResolver}
 * @return a list of fully resolved {@link ProjectVersionRef} to the original {@link Plugin}
 * @throws ManipulationException if an error occurs
 */
public HashMap<Profile,HashMap<ProjectVersionRef,Plugin>> getResolvedProfileManagedPlugins( MavenSessionHandler session )
                throws ManipulationException
{
    if ( resolvedProfileManagedPlugins == null )
    {
        resolvedProfileManagedPlugins = new HashMap<>();

        for ( final Profile profile : ProfileUtils.getProfiles( session, model ) )
        {
            HashMap<ProjectVersionRef, Plugin> profileDeps = new HashMap<>();

            if ( profile.getBuild() != null )
            {
                final PluginManagement pm = profile.getBuild().getPluginManagement();
                if ( !( pm == null || pm.getPlugins() == null ) )
                {
                    resolvePlugins( session, pm.getPlugins(), profileDeps );
                }
            }
            resolvedProfileManagedPlugins.put( profile, profileDeps );
        }
    }
    return resolvedProfileManagedPlugins;
}
项目:pom-manipulation-ext    文件:ProfileUtils.java   
public static List<Profile> getProfiles ( MavenSessionHandler session, Model model)
{
    final List<Profile> result = new ArrayList<>( );
    final List<Profile> profiles = model.getProfiles();
    final boolean scanActiveProfiles = Boolean.parseBoolean( session.getUserProperties().getProperty( PROFILE_SCANNING , "false" ) );

    if ( profiles != null )
    {
        if ( scanActiveProfiles )
        {
            for ( Profile p : profiles )
            {
                if ( session.getActiveProfiles().contains( p.getId() ) )
                {
                    result.add( p );
                }
            }
        }
        else
        {
            result.addAll( profiles );
        }
    }
    return result;
}
项目:pom-manipulation-ext    文件:PluginRemovalManipulator.java   
private boolean apply( final Project project, final Model model )
{
    final PluginRemovalState state = session.getState( PluginRemovalState.class );

    logger.debug( "Applying plugin changes to: " + ga( project ) );

    boolean result = false;
    List<ProjectRef> pluginsToRemove = state.getPluginRemoval();
    if ( model.getBuild() != null )
    {
        result = scanPlugins( pluginsToRemove, model.getBuild().getPlugins() );
    }

    for ( final Profile profile : ProfileUtils.getProfiles( session, model) )
    {
        if ( profile.getBuild() != null && scanPlugins( pluginsToRemove, profile.getBuild().getPlugins() ) )
        {
            result = true;
        }
    }
    return result;
}
项目:oceano    文件:OperatingSystemProfileActivator.java   
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;
}
项目:oceano    文件:DefaultProfileManager.java   
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 );
    }
}
项目:oceano    文件:DefaultMavenExecutionRequest.java   
public MavenExecutionRequest addProfile( Profile profile )
{
    if ( profile == null )
    {
        throw new IllegalArgumentException( "profile missing" );
    }

    for ( Profile p : getProfiles() )
    {
        if ( p.getId() != null && p.getId().equals( profile.getId() ) )
        {
            return this;
        }
    }

    getProfiles().add( profile );

    return this;
}
项目:oceano    文件:DefaultProfileInjector.java   
public void injectProfile( Model model, Profile profile, ModelBuildingRequest request,
                           ModelProblemCollector problems )
{
    if ( profile != null )
    {
        merger.mergeModelBase( model, profile );

        if ( profile.getBuild() != null )
        {
            if ( model.getBuild() == null )
            {
                model.setBuild( new Build() );
            }
            merger.mergeBuildBase( model.getBuild(), profile.getBuild() );
        }
    }
}
项目:oceano    文件:DefaultProfileSelector.java   
private boolean isActive( Profile profile, ProfileActivationContext context, ModelProblemCollector problems )
{
    for ( ProfileActivator activator : activators )
    {
        try
        {
            if ( activator.isActive( profile, context, problems ) )
            {
                return true;
            }
        }
        catch ( RuntimeException e )
        {
            problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE)
                    .setMessage( "Failed to determine activation for profile " + profile.getId())
                    .setLocation( profile.getLocation( "" ))
                    .setException( e ));
            return false;
        }
    }
    return false;
}
项目:oceano    文件:DefaultModelBuildingResult.java   
public DefaultModelBuildingResult setActivePomProfiles( String modelId, List<Profile> activeProfiles )
{
    if ( modelId == null )
    {
        throw new IllegalArgumentException( "no model identifier specified" );
    }

    if ( activeProfiles != null )
    {
        this.activePomProfiles.put( modelId, new ArrayList<Profile>( activeProfiles ) );
    }
    else
    {
        this.activePomProfiles.remove( modelId );
    }

    return this;
}
项目:oceano    文件:JdkVersionProfileActivatorTest.java   
public void testVersionRangeInclusiveBounds()
    throws Exception
{
    Profile profile = newProfile( "[1.5,1.6]" );

    assertActivation( false, profile, newContext( null, newProperties( "1.4" ) ) );
    assertActivation( false, profile, newContext( null, newProperties( "1.4.2" ) ) );
    assertActivation( false, profile, newContext( null, newProperties( "1.4.2_09" ) ) );
    assertActivation( false, profile, newContext( null, newProperties( "1.4.2_09-b03" ) ) );

    assertActivation( true, profile, newContext( null, newProperties( "1.5" ) ) );
    assertActivation( true, profile, newContext( null, newProperties( "1.5.0" ) ) );
    assertActivation( true, profile, newContext( null, newProperties( "1.5.0_09" ) ) );
    assertActivation( true, profile, newContext( null, newProperties( "1.5.0_09-b03" ) ) );
    assertActivation( true, profile, newContext( null, newProperties( "1.5.1" ) ) );

    assertActivation( true, profile, newContext( null, newProperties( "1.6" ) ) );
    assertActivation( true, profile, newContext( null, newProperties( "1.6.0" ) ) );
    assertActivation( true, profile, newContext( null, newProperties( "1.6.0_09" ) ) );
    assertActivation( true, profile, newContext( null, newProperties( "1.6.0_09-b03" ) ) );
}
项目:oceano    文件:JdkVersionProfileActivatorTest.java   
public void testVersionRangeExclusiveBounds()
    throws Exception
{
    Profile profile = newProfile( "(1.3,1.6)" );

    assertActivation( false, profile, newContext( null, newProperties( "1.3" ) ) );
    assertActivation( false, profile, newContext( null, newProperties( "1.3.0" ) ) );
    assertActivation( false, profile, newContext( null, newProperties( "1.3.0_09" ) ) );
    assertActivation( false, profile, newContext( null, newProperties( "1.3.0_09-b03" ) ) );

    assertActivation( true, profile, newContext( null, newProperties( "1.3.1" ) ) );
    assertActivation( true, profile, newContext( null, newProperties( "1.3.1_09" ) ) );
    assertActivation( true, profile, newContext( null, newProperties( "1.3.1_09-b03" ) ) );

    assertActivation( true, profile, newContext( null, newProperties( "1.5" ) ) );
    assertActivation( true, profile, newContext( null, newProperties( "1.5.0" ) ) );
    assertActivation( true, profile, newContext( null, newProperties( "1.5.0_09" ) ) );
    assertActivation( true, profile, newContext( null, newProperties( "1.5.0_09-b03" ) ) );
    assertActivation( true, profile, newContext( null, newProperties( "1.5.1" ) ) );

    assertActivation( false, profile, newContext( null, newProperties( "1.6" ) ) );
}
项目:oceano    文件:JdkVersionProfileActivatorTest.java   
public void testVersionRangeInclusiveLowerBound()
    throws Exception
{
    Profile profile = newProfile( "[1.5,)" );

    assertActivation( false, profile, newContext( null, newProperties( "1.4" ) ) );
    assertActivation( false, profile, newContext( null, newProperties( "1.4.2" ) ) );
    assertActivation( false, profile, newContext( null, newProperties( "1.4.2_09" ) ) );
    assertActivation( false, profile, newContext( null, newProperties( "1.4.2_09-b03" ) ) );

    assertActivation( true, profile, newContext( null, newProperties( "1.5" ) ) );
    assertActivation( true, profile, newContext( null, newProperties( "1.5.0" ) ) );
    assertActivation( true, profile, newContext( null, newProperties( "1.5.0_09" ) ) );
    assertActivation( true, profile, newContext( null, newProperties( "1.5.0_09-b03" ) ) );
    assertActivation( true, profile, newContext( null, newProperties( "1.5.1" ) ) );

    assertActivation( true, profile, newContext( null, newProperties( "1.6" ) ) );
    assertActivation( true, profile, newContext( null, newProperties( "1.6.0" ) ) );
    assertActivation( true, profile, newContext( null, newProperties( "1.6.0_09" ) ) );
    assertActivation( true, profile, newContext( null, newProperties( "1.6.0_09-b03" ) ) );
}
项目:oceano    文件:JdkVersionProfileActivatorTest.java   
public void testVersionRangeExclusiveUpperBound()
    throws Exception
{
    Profile profile = newProfile( "(,1.6)" );

    assertActivation( true, profile, newContext( null, newProperties( "1.5" ) ) );
    assertActivation( true, profile, newContext( null, newProperties( "1.5.0" ) ) );
    assertActivation( true, profile, newContext( null, newProperties( "1.5.0_09" ) ) );
    assertActivation( true, profile, newContext( null, newProperties( "1.5.0_09-b03" ) ) );
    assertActivation( true, profile, newContext( null, newProperties( "1.5.1" ) ) );

    assertActivation( false, profile, newContext( null, newProperties( "1.6" ) ) );
    assertActivation( false, profile, newContext( null, newProperties( "1.6.0" ) ) );
    assertActivation( false, profile, newContext( null, newProperties( "1.6.0_09" ) ) );
    assertActivation( false, profile, newContext( null, newProperties( "1.6.0_09-b03" ) ) );
}
项目:maven-jdev-plugin    文件:JDeveloperMojo.java   
private List<String> getProfilesExecution(MavenProject project)
{
    List<String> values = new ArrayList<String>();

    for(Iterator<Profile> i = project.getActiveProfiles().iterator(); i.hasNext();){
        Profile profile = i.next();
        values.add(String.format(" -D%s=%s ", profile.getActivation().getProperty().getName(), profile.getActivation().getProperty().getValue()));          
    }

    /*this.getLog().info("Profiles " + this.project.getExecutionProject().getProjectBuildingRequest().getProfiles());
    for(Iterator<Profile> i = this.project.getProjectBuildingRequest().getProfiles().iterator(); i.hasNext();){
        Profile profile = i.next();
        values.add(String.format(" -D%s=%s ", profile.getActivation().getProperty().getName(), profile.getActivation().getProperty().getValue()));
    }*/

    return values;
}
项目:buildmetadata-maven-plugin    文件:MavenMetaDataProvider.java   
private void provideActiveProfiles(final Properties buildMetaDataProperties)
{
  final List<Profile> profiles = getActiveProfiles();
  if (profiles != null && !profiles.isEmpty())
  {
    final List<String> profileIds = new ArrayList<String>(profiles.size());
    for (final Profile profile : profiles)
    {
      final String profileId = profile.getId();
      if (!profileIds.contains(profileId))
      {
        final String key =
            Constant.MAVEN_ACTIVE_PROFILE_PREFIX + '.' + profileId;
        final String value = profile.getSource();
        buildMetaDataProperties.setProperty(key, value);
        profileIds.add(profileId);
      }
    }
    buildMetaDataProperties.setProperty(
        Constant.PROP_NAME_MAVEN_ACTIVE_PROFILES,
        MojoUtils.toPrettyString(profileIds));
  }
}
项目:redhat-repository-validator    文件:TestDependenciesValidator.java   
@Test
public void shouldResolveDependencyFromDefaultProfile() {
    Model bar = pom().artifactId("bar").create(repoBarDir);
    Model foo = pom().artifactId("foo").create(repoFooDir);

    Activation fooProfileActivation = new Activation();
    fooProfileActivation.setActiveByDefault(true);

    Profile fooProfile = new Profile();
    fooProfile.setId("fooProfile");
    fooProfile.setActivation(fooProfileActivation);
    fooProfile.addDependency(dependency().to(bar).build());
    foo.addProfile(fooProfile);

    createArtifact(repoFooDir, foo);

    validationExecutor.execute(ctx);

    assertSuccess();
    assertLocalRepoContains(foo);
    assertLocalRepoContains(bar);
}
项目:redhat-repository-validator    文件:TestDependenciesValidator.java   
@Test
public void shouldResolveDependencyFromActiveProfile() {
    Model bar = pom().artifactId("bar").create(repoBarDir);
    Model foo = pom().artifactId("foo").create(repoFooDir);

    Activation fooProfileActivation = new Activation();
    fooProfileActivation.setJdk("!1.0");

    Profile fooProfile = new Profile();
    fooProfile.setId("fooProfile");
    fooProfile.setActivation(fooProfileActivation);
    fooProfile.addDependency(dependency().to(bar).build());
    foo.addProfile(fooProfile);

    createArtifact(repoFooDir, foo);

    validationExecutor.execute(ctx);

    assertSuccess();
    assertLocalRepoContains(foo);
    assertLocalRepoContains(bar);
}
项目:redhat-repository-validator    文件:TestDependenciesValidator.java   
@Test
public void shouldFindMissingDependencyFromActiveProfile() {
    Model bar = pom().artifactId("bar").model();
    Model foo = pom().artifactId("foo").create(repoFooDir);

    Activation fooProfileActivation = new Activation();
    fooProfileActivation.setJdk("!1.0");

    Profile fooProfile = new Profile();
    fooProfile.setId("fooProfile");
    fooProfile.setActivation(fooProfileActivation);
    fooProfile.addDependency(dependency().to(bar).build());
    foo.addProfile(fooProfile);

    createArtifact(repoFooDir, foo);

    validationExecutor.execute(ctx);

    assertExpectedException(ArtifactNotFoundException.class, "Could not find artifact com.acme:bar:jar:1.0");
}