Example usage for org.apache.maven.project MavenProject getPackaging

List of usage examples for org.apache.maven.project MavenProject getPackaging

Introduction

In this page you can find the example usage for org.apache.maven.project MavenProject getPackaging.

Prototype

public String getPackaging() 

Source Link

Usage

From source file:org.ebayopensource.turmeric.eclipse.maven.core.utils.MavenCoreUtils.java

License:Open Source License

/**
 * Library name./*  w w  w.  jav a 2 s .co m*/
 *
 * @param project the maven project
 * @return The full library name for the given Maven project
 */
public static String libraryName(final MavenProject project) {
    if (SOALogger.DEBUG)
        logger.entering(project);
    final String packaging = StringUtils.isNotBlank(project.getPackaging()) ? project.getPackaging()
            : SOAMavenConstants.MAVEN_PACKAGING_JAR;
    final String result = MavenCoreUtils.translateLibraryName(project.getGroupId(), project.getArtifactId(),
            packaging, project.getVersion());
    if (SOALogger.DEBUG)
        logger.exiting(result);
    return result;
}

From source file:org.eclipse.ebr.maven.BundleMojo.java

License:Open Source License

static boolean isRecipeProject(final MavenProject project) {
    return "eclipse-bundle-recipe".equals(project.getPackaging());
}

From source file:org.eclipse.m2e.core.internal.lifecyclemapping.discovery.LifecycleMappingConfiguration.java

License:Open Source License

static LifecycleMappingConfiguration calculate(Collection<MavenProjectInfo> projects,
        IProgressMonitor monitor) {//from  w w w  .ja  v  a2s .c  o  m
    monitor.beginTask("Analysing project execution plan", projects.size());

    LifecycleMappingConfiguration result = new LifecycleMappingConfiguration();

    List<MavenProjectInfo> nonErrorProjects = new ArrayList<MavenProjectInfo>();
    final IMaven maven = MavenPlugin.getMaven();

    for (final MavenProjectInfo projectInfo : projects) {
        if (monitor.isCanceled()) {
            throw new OperationCanceledException();
        }
        MavenProject mavenProject = null;
        try {
            SubMonitor subMmonitor = SubMonitor.convert(monitor,
                    NLS.bind("Analysing {0}", projectInfo.getLabel()), 1);

            MavenExecutionResult executionResult = maven.execute(new ICallable<MavenExecutionResult>() {
                public MavenExecutionResult call(IMavenExecutionContext context, IProgressMonitor monitor)
                        throws CoreException {
                    return maven.readMavenProject(projectInfo.getPomFile(),
                            context.newProjectBuildingRequest());
                }
            }, subMmonitor);

            mavenProject = executionResult.getProject();

            if (monitor.isCanceled()) {
                throw new OperationCanceledException();
            }

            if (mavenProject != null) {
                if ("pom".equals(projectInfo.getModel().getPackaging())) {
                    // m2e uses a noop lifecycle mapping for packaging=pom
                    List<MojoExecution> mojoExecutions = new ArrayList<MojoExecution>();
                    PackagingTypeMappingConfiguration pkgConfiguration = new PackagingTypeMappingConfiguration(
                            mavenProject.getPackaging(), null /*lifecycleMappingId*/);
                    ProjectLifecycleMappingConfiguration configuration = new ProjectLifecycleMappingConfiguration(
                            projectInfo.getLabel(), mavenProject, mojoExecutions, pkgConfiguration);
                    result.addProject(projectInfo, configuration);
                    nonErrorProjects.add(projectInfo);
                    continue;
                }

                List<MojoExecution> mojoExecutions = new ArrayList<MojoExecution>();
                MavenExecutionPlan executionPlan = maven.calculateExecutionPlan(mavenProject,
                        Arrays.asList(ProjectRegistryManager.LIFECYCLE_CLEAN), false, subMmonitor);
                mojoExecutions.addAll(executionPlan.getMojoExecutions());
                executionPlan = maven.calculateExecutionPlan(mavenProject,
                        Arrays.asList(ProjectRegistryManager.LIFECYCLE_DEFAULT), false, subMmonitor);
                mojoExecutions.addAll(executionPlan.getMojoExecutions());
                executionPlan = maven.calculateExecutionPlan(mavenProject,
                        Arrays.asList(ProjectRegistryManager.LIFECYCLE_SITE), false, subMmonitor);
                mojoExecutions.addAll(executionPlan.getMojoExecutions());

                LifecycleMappingResult lifecycleResult = new LifecycleMappingResult();

                List<MappingMetadataSource> metadataSources;
                try {
                    metadataSources = LifecycleMappingFactory.getProjectMetadataSources(mavenProject,
                            LifecycleMappingFactory.getBundleMetadataSources(), mojoExecutions, true, monitor);
                } catch (LifecycleMappingConfigurationException e) {
                    // could not read/parse/interpret mapping metadata configured in the pom or inherited from parent pom.
                    // record the problem and continue
                    log.error(e.getMessage(), e);
                    continue;
                }

                LifecycleMappingFactory.calculateEffectiveLifecycleMappingMetadata(lifecycleResult,
                        metadataSources, mavenProject, mojoExecutions, false, monitor);
                LifecycleMappingFactory.instantiateLifecycleMapping(lifecycleResult, mavenProject,
                        lifecycleResult.getLifecycleMappingId());
                LifecycleMappingFactory.instantiateProjectConfigurators(mavenProject, lifecycleResult,
                        lifecycleResult.getMojoExecutionMapping());

                PackagingTypeMappingConfiguration pkgConfiguration = new PackagingTypeMappingConfiguration(
                        mavenProject.getPackaging(),
                        isProjectSource(lifecycleResult.getLifecycleMappingMetadata())
                                ? lifecycleResult.getLifecycleMappingId()
                                : null);
                ProjectLifecycleMappingConfiguration configuration = new ProjectLifecycleMappingConfiguration(
                        projectInfo.getLabel(), mavenProject, mojoExecutions, pkgConfiguration);

                if (lifecycleResult.getLifecycleMapping() != null) {
                    result.addInstalledProvider(configuration.getPackagingTypeMappingConfiguration()
                            .getLifecycleMappingRequirement());
                }

                for (Map.Entry<MojoExecutionKey, List<IPluginExecutionMetadata>> entry : lifecycleResult
                        .getMojoExecutionMapping().entrySet()) {
                    MojoExecutionKey key = entry.getKey();
                    List<IPluginExecutionMetadata> mapppings = entry.getValue();
                    IPluginExecutionMetadata primaryMapping = null;
                    if (mapppings != null && !mapppings.isEmpty()) {
                        primaryMapping = mapppings.get(0);
                    }
                    MojoExecutionMappingConfiguration executionConfiguration = new MojoExecutionMappingConfiguration(
                            key, isProjectSource(primaryMapping) ? primaryMapping : null);
                    configuration.addMojoExecution(executionConfiguration);
                    if (primaryMapping != null) {
                        switch (primaryMapping.getAction()) {
                        case configurator:
                            AbstractProjectConfigurator projectConfigurator = lifecycleResult
                                    .getProjectConfigurators()
                                    .get(LifecycleMappingFactory.getProjectConfiguratorId(primaryMapping));
                            if (projectConfigurator != null) {
                                result.addInstalledProvider(
                                        executionConfiguration.getLifecycleMappingRequirement());
                            }
                            break;
                        case error:
                        case execute:
                        case ignore:
                            result.addInstalledProvider(
                                    executionConfiguration.getLifecycleMappingRequirement());
                            break;
                        default:
                            throw new IllegalArgumentException(
                                    "Missing handling for action=" + primaryMapping.getAction());
                        }
                    }
                }
                result.addProject(projectInfo, configuration);
                nonErrorProjects.add(projectInfo);
            } else {
                //XXX mkleint: what shall happen now? we don't have a valid MavenProject instance to play with,
                // currently we skip such project silently, is that ok?
            }

        } catch (OperationCanceledException ex) {
            throw ex;
        } catch (Throwable th) {
            result.addError(projectInfo, th);
        } finally {
            if (mavenProject != null) {
                ((MavenImpl) maven).releaseExtensionsRealm(mavenProject);
            }
        }
    }

    result.setSelectedProjects(nonErrorProjects);

    return result;
}

From source file:org.eclipse.m2e.core.internal.lifecyclemapping.LifecycleMappingFactory.java

License:Open Source License

public static void calculateEffectiveLifecycleMappingMetadata(LifecycleMappingResult result,
        MavenProject mavenProject, List<MojoExecution> mojoExecutions, IProgressMonitor monitor)
        throws CoreException {

    String packagingType = mavenProject.getPackaging();
    if ("pom".equals(packagingType)) { //$NON-NLS-1$
        log.debug("Using NoopLifecycleMapping lifecycle mapping for {}.", mavenProject.toString()); //$NON-NLS-1$

        LifecycleMappingMetadata lifecycleMappingMetadata = new LifecycleMappingMetadata();
        lifecycleMappingMetadata.setLifecycleMappingId(NoopLifecycleMapping.LIFECYCLE_MAPPING_ID);

        result.setLifecycleMappingMetadata(lifecycleMappingMetadata);

        Map<MojoExecutionKey, List<IPluginExecutionMetadata>> executionMapping = new LinkedHashMap<MojoExecutionKey, List<IPluginExecutionMetadata>>();
        result.setMojoExecutionMapping(executionMapping);

        return;//  w w w.  jav a  2  s .  co  m
    }

    if (result.getLifecycleMapping() != null
            && !(result.getLifecycleMapping() instanceof AbstractCustomizableLifecycleMapping)) {

        String lifecycleMappingId = result.getLifecycleMapping().getId();

        log.debug("Using non-customizable lifecycle mapping {} for {}.", lifecycleMappingId,
                mavenProject.toString()); // $NON-NLS-1$

        LifecycleMappingMetadata lifecycleMappingMetadata = new LifecycleMappingMetadata();
        lifecycleMappingMetadata.setLifecycleMappingId(lifecycleMappingId);

        result.setLifecycleMappingMetadata(lifecycleMappingMetadata);

        Map<MojoExecutionKey, List<IPluginExecutionMetadata>> executionMapping = new LinkedHashMap<MojoExecutionKey, List<IPluginExecutionMetadata>>();
        result.setMojoExecutionMapping(executionMapping);

        return;
    }

    List<MappingMetadataSource> metadataSources;
    try {
        metadataSources = getProjectMetadataSources(mavenProject, getBundleMetadataSources(), mojoExecutions,
                true, monitor);
    } catch (LifecycleMappingConfigurationException e) {
        // could not read/parse/interpret mapping metadata configured in the pom or inherited from parent pom.
        // record the problem and return
        result.addProblem(new MavenProblemInfo(mavenProject, e));
        return;
    }

    calculateEffectiveLifecycleMappingMetadata(result, metadataSources, mavenProject, mojoExecutions, true,
            monitor);
}

From source file:org.eclipse.m2e.core.internal.lifecyclemapping.LifecycleMappingFactory.java

License:Open Source License

static void calculateEffectiveLifecycleMappingMetadata0(LifecycleMappingResult result,
        List<MappingMetadataSource> metadataSources, MavenProject mavenProject,
        List<MojoExecution> mojoExecutions, boolean applyDefaultStrategy, IProgressMonitor monitor) {

    ///*w  w  w .  j  a  v a2 s  .com*/
    // PHASE 1. Look for lifecycle mapping for packaging type
    //

    LifecycleMappingMetadata lifecycleMappingMetadata = null;
    MappingMetadataSource originalMetadataSource = null;

    for (int i = 0; i < metadataSources.size(); i++) {
        MappingMetadataSource source = metadataSources.get(i);
        try {
            lifecycleMappingMetadata = source.getLifecycleMappingMetadata(mavenProject.getPackaging());
            if (lifecycleMappingMetadata != null) {
                originalMetadataSource = new SimpleMappingMetadataSource(lifecycleMappingMetadata);
                metadataSources.add(i, originalMetadataSource);
                break;
            }
        } catch (DuplicateMappingException e) {
            log.error("Duplicate lifecycle mapping metadata for {}.", mavenProject.toString());
            result.addProblem(new MavenProblemInfo(1,
                    NLS.bind(Messages.LifecycleDuplicate, mavenProject.getPackaging())));
            return; // fatal error
        }
    }

    if (lifecycleMappingMetadata == null && applyDefaultStrategy) {
        lifecycleMappingMetadata = new LifecycleMappingMetadata();
        lifecycleMappingMetadata.setLifecycleMappingId("DEFAULT"); // TODO proper constant
        lifecycleMappingMetadata.setPackagingType(mavenProject.getPackaging());
    }

    // TODO if lifecycleMappingMetadata.lifecycleMappingId==null, convert to error lifecycle mapping metadata

    result.setLifecycleMappingMetadata(lifecycleMappingMetadata);

    //
    // PHASE 2. Bind project configurators to mojo executions.
    //

    Map<MojoExecutionKey, List<IPluginExecutionMetadata>> executionMapping = new LinkedHashMap<MojoExecutionKey, List<IPluginExecutionMetadata>>();

    if (mojoExecutions != null) {
        for (MojoExecution execution : mojoExecutions) {
            MojoExecutionKey executionKey = new MojoExecutionKey(execution);

            PluginExecutionMetadata primaryMetadata = null;

            // find primary mapping first
            try {
                for (MappingMetadataSource source : metadataSources) {
                    try {
                        List<PluginExecutionMetadata> metadatas = applyParametersFilter(
                                source.getPluginExecutionMetadata(executionKey), mavenProject, execution,
                                monitor);
                        for (PluginExecutionMetadata executionMetadata : metadatas) {
                            if (LifecycleMappingFactory.isPrimaryMapping(executionMetadata)) {
                                if (primaryMetadata != null) {
                                    primaryMetadata = null;
                                    throw new DuplicateMappingException();
                                }
                                primaryMetadata = executionMetadata;
                            }
                        }
                        if (primaryMetadata != null) {
                            break;
                        }
                    } catch (CoreException e) {
                        SourceLocation location = SourceLocationHelper.findLocation(mavenProject, executionKey);
                        result.addProblem(new MavenProblemInfo(location, e));
                    }
                }
            } catch (DuplicateMappingException e) {
                log.debug("Duplicate plugin execution mapping metadata for {}.", executionKey.toString());
                result.addProblem(new MavenProblemInfo(1,
                        NLS.bind(Messages.PluginExecutionMappingDuplicate, executionKey.toString())));
            }

            if (primaryMetadata != null && !isValidPluginExecutionMetadata(primaryMetadata)) {
                log.debug("Invalid plugin execution mapping metadata for {}.", executionKey.toString());
                result.addProblem(new MavenProblemInfo(1,
                        NLS.bind(Messages.PluginExecutionMappingInvalid, executionKey.toString())));
                primaryMetadata = null;
            }

            List<IPluginExecutionMetadata> executionMetadatas = new ArrayList<IPluginExecutionMetadata>();
            if (primaryMetadata != null) {
                executionMetadatas.add(primaryMetadata);

                if (primaryMetadata.getAction() == PluginExecutionAction.configurator) {
                    // attach any secondary mapping
                    for (MappingMetadataSource source : metadataSources) {
                        try {
                            List<PluginExecutionMetadata> metadatas = source
                                    .getPluginExecutionMetadata(executionKey);
                            metadatas = applyParametersFilter(metadatas, mavenProject, execution, monitor);
                            for (PluginExecutionMetadata metadata : metadatas) {
                                if (isValidPluginExecutionMetadata(metadata)) {
                                    if (metadata.getAction() == PluginExecutionAction.configurator
                                            && isSecondaryMapping(metadata, primaryMetadata)) {
                                        executionMetadatas.add(metadata);
                                    }
                                } else {
                                    log.debug("Invalid secondary lifecycle mapping metadata for {}.",
                                            executionKey.toString());
                                }
                            }
                        } catch (CoreException e) {
                            SourceLocation location = SourceLocationHelper.findLocation(mavenProject,
                                    executionKey);
                            result.addProblem(new MavenProblemInfo(location, e));
                        }
                    }
                }
            }

            // TODO valid executionMetadatas and convert to error mapping invalid enties.

            executionMapping.put(executionKey, executionMetadatas);
        }
    } else {
        log.debug("Execution plan is null, could not calculate mojo execution mapping for {}.",
                mavenProject.toString());
    }

    result.setMojoExecutionMapping(executionMapping);
}

From source file:org.eclipse.m2e.core.internal.lifecyclemapping.LifecycleMappingFactory.java

License:Open Source License

private static LifecycleMappingMetadataSource getEmbeddedMetadataSource(MavenProject mavenProject)
        throws CoreException {
    // TODO this does not merge configuration from profiles 
    PluginManagement pluginManagement = getPluginManagement(mavenProject);
    Plugin metadataPlugin = pluginManagement.getPluginsAsMap().get(LIFECYCLE_MAPPING_PLUGIN_KEY);
    if (metadataPlugin != null) {
        checkCompatibleVersion(metadataPlugin);

        Xpp3Dom configurationDom = (Xpp3Dom) metadataPlugin.getConfiguration();
        if (configurationDom != null) {
            Xpp3Dom lifecycleMappingDom = configurationDom.getChild(ELEMENT_LIFECYCLE_MAPPING_METADATA);
            if (lifecycleMappingDom != null) {
                try {
                    LifecycleMappingMetadataSource metadataSource = new LifecycleMappingMetadataSourceXpp3Reader()
                            .read(new StringReader(lifecycleMappingDom.toString()));
                    postCreateLifecycleMappingMetadataSource(metadataSource);
                    String packagingType = mavenProject.getPackaging();
                    if (!"pom".equals(packagingType)) { //$NON-NLS-1$
                        for (LifecycleMappingMetadata lifecycleMappingMetadata : metadataSource
                                .getLifecycleMappings()) {
                            if (!packagingType.equals(lifecycleMappingMetadata.getPackagingType())) {
                                SourceLocation location = SourceLocationHelper.findLocation(metadataPlugin,
                                        SourceLocationHelper.CONFIGURATION);
                                throw new LifecycleMappingConfigurationException(
                                        NLS.bind(Messages.LifecycleMappingPackagingMismatch,
                                                lifecycleMappingMetadata.getPackagingType(), packagingType),
                                        location);
                            }//w  w  w .  jav a  2s.c  om
                        }
                    }
                    return metadataSource;
                } catch (IOException e) {
                    throw new LifecycleMappingConfigurationException(
                            "Cannot read lifecycle mapping metadata for maven project " + mavenProject, e);
                } catch (XmlPullParserException e) {
                    throw new LifecycleMappingConfigurationException(
                            "Cannot parse lifecycle mapping metadata for maven project " + mavenProject, e);
                } catch (LifecycleMappingConfigurationException e) {
                    throw e;
                } catch (RuntimeException e) {
                    throw new LifecycleMappingConfigurationException(
                            "Cannot load lifecycle mapping metadata for maven project " + mavenProject, e);
                }
            }
        }
    }
    return null;
}

From source file:org.eclipse.m2e.core.internal.project.registry.MavenProjectFacade.java

License:Open Source License

public MavenProjectFacade(ProjectRegistryManager manager, IFile pom, MavenProject mavenProject,
        Map<String, List<MojoExecution>> executionPlans, ResolverConfiguration resolverConfiguration) {
    this.manager = manager;
    this.pom = pom;
    IPath location = pom.getLocation();//from  w  w  w.  j  a va 2s  . c  o m
    this.pomFile = location == null ? null : location.toFile(); // save pom file
    this.resolverConfiguration = resolverConfiguration;

    this.mavenProject = mavenProject;
    this.executionPlans = executionPlans;

    this.artifactKey = new ArtifactKey(mavenProject.getArtifact());
    this.packaging = mavenProject.getPackaging();
    this.modules = mavenProject.getModules();

    this.resourceLocations = MavenProjectUtils.getResourceLocations(getProject(), mavenProject.getResources());
    this.testResourceLocations = MavenProjectUtils.getResourceLocations(getProject(),
            mavenProject.getTestResources());
    this.compileSourceLocations = MavenProjectUtils.getSourceLocations(getProject(),
            mavenProject.getCompileSourceRoots());
    this.testCompileSourceLocations = MavenProjectUtils.getSourceLocations(getProject(),
            mavenProject.getTestCompileSourceRoots());

    IPath fullPath = getProject().getFullPath();

    IPath path = getProjectRelativePath(mavenProject.getBuild().getOutputDirectory());
    this.outputLocation = (path != null) ? fullPath.append(path) : null;

    path = getProjectRelativePath(mavenProject.getBuild().getTestOutputDirectory());
    this.testOutputLocation = path != null ? fullPath.append(path) : null;

    this.artifactRepositories = new LinkedHashSet<ArtifactRepositoryRef>();
    for (ArtifactRepository repository : mavenProject.getRemoteArtifactRepositories()) {
        this.artifactRepositories.add(new ArtifactRepositoryRef(repository));
    }

    this.pluginArtifactRepositories = new LinkedHashSet<ArtifactRepositoryRef>();
    for (ArtifactRepository repository : mavenProject.getPluginArtifactRepositories()) {
        this.pluginArtifactRepositories.add(new ArtifactRepositoryRef(repository));
    }

    setMavenProjectArtifacts();

    updateTimestamp();
}

From source file:org.eclipse.m2e.core.ui.internal.wizards.MavenInstallFileArtifactWizardPage.java

License:Open Source License

private void readPOMFile(String fileName) {
    try {//ww  w .  ja  v  a2s. co  m
        IMaven maven = MavenPlugin.getMaven();
        MavenProject mavenProject = maven.readProject(new File(fileName), null);

        groupIdCombo.setText(mavenProject.getGroupId());
        artifactIdCombo.setText(mavenProject.getArtifactId());
        versionCombo.setText(mavenProject.getVersion());
        packagingCombo.setText(mavenProject.getPackaging());
        return;

    } catch (CoreException ex) {
        log.error(ex.getMessage(), ex);
    }
}

From source file:org.eclipse.m2e.internal.discovery.MavenDiscoveryService.java

License:Open Source License

Map<ILifecycleMappingRequirement, List<IMavenDiscoveryProposal>> discover0(MavenProject mavenProject,
        List<MojoExecution> mojoExecutions, List<IMavenDiscoveryProposal> preselected, IProgressMonitor monitor)
        throws CoreException {
    Map<ILifecycleMappingRequirement, List<IMavenDiscoveryProposal>> proposals = new LinkedHashMap<ILifecycleMappingRequirement, List<IMavenDiscoveryProposal>>();

    Collection<CatalogItem> selectedItems = toCatalogItems(preselected);
    List<LifecycleMappingMetadataSource> selectedSources = toMetadataSources(preselected);

    for (CatalogItemCacheEntry itemEntry : items) {
        CatalogItem item = itemEntry.getItem();
        LifecycleMappingMetadataSource src = itemEntry.getMetadataSource();

        boolean preselectItem = false;
        for (CatalogItem selectedItem : selectedItems) {
            if (selectedItem.getSiteUrl().equals(item.getSiteUrl())
                    && selectedItem.getInstallableUnits().equals(item.getInstallableUnits())) {
                preselectItem = true;//from w w w  . j  a  v  a2s  .  c o  m
                break;
            }
        }

        if (src != null) {
            log.debug("Considering catalog item '{}'", item.getName()); //$NON-NLS-1$

            src.setSource(item);

            LifecycleMappingResult mappingResult = new LifecycleMappingResult();

            List<LifecycleMappingMetadataSource> sources = new ArrayList<LifecycleMappingMetadataSource>(
                    selectedSources);
            if (!preselectItem) {
                sources.add(src);
            }

            List<MappingMetadataSource> metadataSources = LifecycleMappingFactory
                    .getProjectMetadataSources(mavenProject, sources, mojoExecutions, false, monitor);

            LifecycleMappingFactory.calculateEffectiveLifecycleMappingMetadata(mappingResult, metadataSources,
                    mavenProject, mojoExecutions, false, monitor);

            LifecycleMappingMetadata lifecycleMappingMetadata = mappingResult.getLifecycleMappingMetadata();
            if (lifecycleMappingMetadata != null) {
                IMavenDiscoveryProposal proposal = getProposal(lifecycleMappingMetadata.getSource());
                if (proposal != null) {
                    put(proposals, new PackagingTypeMappingConfiguration.PackagingTypeMappingRequirement(
                            mavenProject.getPackaging()), proposal);
                } else if (!LifecycleMappingFactory.getLifecycleMappingExtensions()
                        .containsKey(lifecycleMappingMetadata.getLifecycleMappingId())) {
                    if (itemEntry.getMappingStrategies()
                            .contains(lifecycleMappingMetadata.getLifecycleMappingId())) {
                        put(proposals,
                                new PackagingTypeMappingConfiguration.LifecycleStrategyMappingRequirement(
                                        lifecycleMappingMetadata.getPackagingType(),
                                        lifecycleMappingMetadata.getLifecycleMappingId()),
                                new InstallCatalogItemMavenDiscoveryProposal(item));
                    }
                }
            }

            for (Map.Entry<MojoExecutionKey, List<IPluginExecutionMetadata>> entry : mappingResult
                    .getMojoExecutionMapping().entrySet()) {
                if (entry.getValue() != null) {
                    for (IPluginExecutionMetadata executionMapping : entry.getValue()) {
                        log.debug("mapping proposal {} => {}", entry.getKey().toString(), //$NON-NLS-1$
                                executionMapping.getAction().toString());
                        IMavenDiscoveryProposal proposal = getProposal(
                                ((PluginExecutionMetadata) executionMapping).getSource());
                        if (proposal != null) {
                            // assumes installation of mapping proposal installs all required project configurators 
                            put(proposals,
                                    new MojoExecutionMappingConfiguration.MojoExecutionMappingRequirement(
                                            entry.getKey()),
                                    proposal);
                        } else if (executionMapping.getAction() == PluginExecutionAction.configurator) {
                            // we have <configurator/> mapping from pom.xml
                            String configuratorId = LifecycleMappingFactory
                                    .getProjectConfiguratorId(executionMapping);
                            if (!LifecycleMappingFactory.getProjectConfiguratorExtensions()
                                    .containsKey(configuratorId)) {
                                // User Story.
                                // Project pom.xml explicitly specifies lifecycle mapping strategy implementation, 
                                // but the implementation is not currently installed. As a user I expect m2e to search 
                                // marketplace for the implementation and offer installation if available

                                if (itemEntry.getProjectConfigurators().contains(configuratorId)) {
                                    put(proposals,
                                            new MojoExecutionMappingConfiguration.ProjectConfiguratorMappingRequirement(
                                                    entry.getKey(), configuratorId),
                                            new InstallCatalogItemMavenDiscoveryProposal(item));
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    return proposals;
}

From source file:org.eclipse.m2e.wtp.AcrPluginConfiguration.java

License:Open Source License

public AcrPluginConfiguration(IMavenProjectFacade facade) {

    MavenProject mavenProject = facade.getMavenProject();
    if (JEEPackaging.APP_CLIENT != JEEPackaging.getValue(mavenProject.getPackaging()))
        throw new IllegalArgumentException("Maven project must have app-client packaging");

    this.mavenProjectFacade = facade;
    Plugin plugin = mavenProject.getPlugin("org.apache.maven.plugins:maven-acr-plugin");
    if (plugin != null) {
        setConfiguration((Xpp3Dom) plugin.getConfiguration());
    }//from   w ww  .  j  av  a2  s  .c o m
}