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

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

Introduction

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

Prototype

public String getVersion() 

Source Link

Usage

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

License:Open Source License

/**
 * Library name./*from w w w.  j  ava  2s. c  o  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.ebayopensource.turmeric.eclipse.maven.core.utils.MavenCoreUtils.java

License:Open Source License

private static MavenAssetInfo getLibraryInfo(final MavenProject mProject) {
    File jarFile = null;/*from  w ww  .j a  v a2  s.c o  m*/
    if (WorkspaceUtil.getProject(mProject.getArtifactId()).isAccessible() == false) {
        jarFile = getJarFileForService(mProject);
    }
    final String dir = jarFile != null && jarFile.exists() ? jarFile.getParent() : "";
    final MavenAssetInfo assetInfo = new MavenAssetInfo(mProject.getGroupId(), mProject.getArtifactId(),
            mProject.getVersion(), dir, null, IAssetInfo.TYPE_LIBRARY);
    if (jarFile != null && StringUtils.isNotBlank(dir))
        assetInfo.setJarNames(ListUtil.array(jarFile.getName()));
    return assetInfo;
}

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

License:Open Source License

public boolean performFinish() {
    //mkleint: this sounds wrong.
    if (!page.isPageComplete()) {
        return false;
    }//from w  w w  .j  a va2 s  .  c  o  m
    if (lifecycleMappingPage != null && !lifecycleMappingPage.isMappingComplete() && !warnIncompleteMapping()) {
        return false;
    }

    final List<IMavenDiscoveryProposal> proposals = getMavenDiscoveryProposals();
    final Collection<MavenProjectInfo> projects = getProjects();

    final IRunnableWithProgress importOperation = new AbstractCreateMavenProjectsOperation(workingSets) {
        @Override
        protected List<IProject> doCreateMavenProjects(IProgressMonitor progressMonitor) throws CoreException {
            SubMonitor monitor = SubMonitor.convert(progressMonitor, 101);
            try {
                List<IMavenProjectImportResult> results = MavenPlugin.getProjectConfigurationManager()
                        .importProjects(projects, importConfiguration,
                                monitor.newChild(proposals.isEmpty() ? 100 : 50));
                return toProjects(results);
            } finally {
                monitor.done();
            }
        }
    };

    boolean doImport = true;

    IMavenDiscoveryUI discovery = getPageFactory();
    if (discovery != null && !proposals.isEmpty()) {
        Set<String> projectsToConfigure = new HashSet<String>();
        for (MavenProjectInfo projectInfo : projects) {
            if (projectInfo.getModel() != null) {
                projectsToConfigure.add(importConfiguration.getProjectName(projectInfo.getModel()));
            }
        }
        doImport = discovery.implement(proposals, importOperation, getContainer(), projectsToConfigure);
    }

    if (doImport) {
        final IRunnableWithProgress ignoreJob = new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                List<IProject> changed = new LinkedList<IProject>();
                for (ILifecycleMappingLabelProvider prov : lifecycleMappingPage.getIgnore()) {
                    ILifecycleMappingRequirement req = prov.getKey();
                    if (req instanceof MojoExecutionMappingRequirement) {
                        changed.addAll(getProject(prov.getProjects()));
                        ignore(((MojoExecutionMappingRequirement) req).getExecution(), prov.getProjects());
                    }
                }

                for (ILifecycleMappingLabelProvider prov : lifecycleMappingPage.getIgnoreParent()) {
                    ILifecycleMappingRequirement req = prov.getKey();
                    if (req instanceof MojoExecutionMappingRequirement) {
                        changed.addAll(getProject(prov.getProjects()));
                        ignoreAtDefinition(((MojoExecutionMappingRequirement) req).getExecution(),
                                prov.getProjects());
                    }
                }

                new UpdateMavenProjectJob(changed.toArray(new IProject[changed.size()])).schedule();
            }

            private Collection<IProject> getProject(Collection<MavenProject> projects) {
                List<IProject> workspaceProjects = new LinkedList<IProject>();
                for (MavenProject project : projects) {
                    IMavenProjectFacade facade = MavenPlugin.getMavenProjectRegistry().getMavenProject(
                            project.getGroupId(), project.getArtifactId(), project.getVersion());
                    if (facade != null) {
                        workspaceProjects.add(facade.getProject());
                    }
                }
                return workspaceProjects;
            }

            private void ignore(MojoExecutionKey key, Collection<MavenProject> projects) {
                String pluginGroupId = key.getGroupId();
                String pluginArtifactId = key.getArtifactId();
                String pluginVersion = key.getVersion();
                String[] goals = new String[] { key.getGoal() };
                for (MavenProject project : projects) {
                    IFile pomFile = M2EUtils.getPomFile(project);
                    try {
                        PomEdits.performOnDOMDocument(
                                new OperationTuple(pomFile, new LifecycleMappingOperation(pluginGroupId,
                                        pluginArtifactId, pluginVersion, PluginExecutionAction.ignore, goals)));
                    } catch (IOException ex) {
                        LOG.error(ex.getMessage(), ex);
                    } catch (CoreException ex) {
                        LOG.error(ex.getMessage(), ex);
                    }
                }
            }

            private void ignoreAtDefinition(MojoExecutionKey key, Collection<MavenProject> projects) {
                ignore(key, M2EUtils.getDefiningProjects(key, projects));
            }
        };

        Job job = new WorkspaceJob(Messages.MavenImportWizard_job) {
            @Override
            public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
                try {
                    importOperation.run(monitor);
                    if (lifecycleMappingPage != null) {
                        ignoreJob.run(monitor);
                    }
                } catch (InvocationTargetException e) {
                    return AbstractCreateMavenProjectsOperation.toStatus(e);
                } catch (InterruptedException e) {
                    return Status.CANCEL_STATUS;
                }
                return Status.OK_STATUS;
            }
        };
        job.setRule(MavenPlugin.getProjectConfigurationManager().getRule());
        job.schedule();
    }

    return doImport;
}

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

License:Open Source License

private void readPOMFile(String fileName) {
    try {/*  w  ww . j  a  v  a  2 s  .  c  o 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.editor.composites.DependencyLabelProvider.java

License:Open Source License

private String[] findManaged(DependenciesComposite.Dependency dep) {
    if (pomEditor != null) {
        MavenProject mp = pomEditor.getMavenProject();
        String version = null;//  w ww .  j av a2 s.  co  m
        String scope = null;
        if (mp != null) {
            String id = mp.getGroupId() + ":" + mp.getArtifactId() + ":" + mp.getVersion();
            DependencyManagement dm = mp.getDependencyManagement();
            if (dm != null) {
                for (org.apache.maven.model.Dependency d : dm.getDependencies()) {
                    if (d.getGroupId().equals(dep.groupId) && d.getArtifactId().equals(dep.artifactId)) {
                        //based on location, try finding a match in the live Model
                        InputLocation location = d.getLocation("artifactId");
                        if (location != null) {
                            if (id.equals(location.getSource().getModelId())) {
                                version = d.getVersion();
                                scope = d.getScope();
                                break;
                            }
                        }
                        return new String[] { d.getVersion(), d.getScope() };
                    }
                }
            }
        }
        List<org.apache.maven.model.Dependency> dm = valueProvider.getValue();
        for (org.apache.maven.model.Dependency modelDep : dm) {
            String modelGroupId = modelDep.getGroupId();
            String modelArtifactId = modelDep.getArtifactId();
            String modelVersion = modelDep.getVersion();
            String modelScope = modelDep.getScope();
            if (modelGroupId != null && modelGroupId.equals(dep.groupId) && modelArtifactId != null
                    && modelArtifactId.equals(dep.artifactId)) {
                if (version != null && (modelVersion == null || modelVersion.contains("${"))) {
                    //prefer the resolved version to the model one if the model version as expressions..
                    return new String[] { version, modelScope == null ? scope : modelScope };
                }
                return new String[] { modelVersion, modelScope == null ? scope : modelScope };
            }
        }
    }
    return null;
}

From source file:org.eclipse.m2e.editor.dialogs.ManageDependenciesDialog.java

License:Open Source License

protected void computeResult() {
    MavenProject targetPOM = getTargetPOM();
    IMavenProjectFacade targetFacade = MavenPlugin.getMavenProjectRegistry()
            .getMavenProject(targetPOM.getGroupId(), targetPOM.getArtifactId(), targetPOM.getVersion());
    MavenProject currentPOM = projectHierarchy.getFirst();
    IMavenProjectFacade currentFacade = MavenPlugin.getMavenProjectRegistry()
            .getMavenProject(currentPOM.getGroupId(), currentPOM.getArtifactId(), currentPOM.getVersion());

    if (targetFacade == null || currentFacade == null) {
        return;/*www  .ja  va  2s .c o  m*/
    }
    final boolean same = targetPOM.equals(currentPOM);

    final LinkedList<Dependency> modelDeps = getDependenciesList();

    /*
     * 1) Remove version values from the dependencies from the current POM
     * 2) Add dependencies to dependencyManagement of targetPOM
     */

    //First we remove the version from the original dependency
    final IFile current = currentFacade.getPom();
    final IFile target = targetFacade.getPom();
    Job perform = new Job("Updating POM file(s)") {
        @Override
        protected IStatus run(IProgressMonitor monitor) {
            try {
                if (same) {
                    performOnDOMDocument(new OperationTuple(current, new CompoundOperation(
                            createManageOperation(modelDeps), createRemoveVersionOperation(modelDeps))));
                } else {
                    performOnDOMDocument(new OperationTuple(target, createManageOperation(modelDeps)),
                            new OperationTuple(current, createRemoveVersionOperation(modelDeps)));
                }
            } catch (Exception e) {
                LOG.error("Error updating managed dependencies", e);
                return new Status(IStatus.ERROR, MavenEditorPlugin.PLUGIN_ID,
                        "Error updating managed dependencies", e);
            }
            return Status.OK_STATUS;
        }
    };
    perform.setUser(false);
    perform.setSystem(true);
    perform.schedule();
}

From source file:org.eclipse.m2e.editor.dialogs.ManageDependenciesDialog.java

License:Open Source License

protected void checkStatus(MavenProject targetProject, LinkedList<Dependency> selectedDependencies) {
    if (targetProject == null || selectedDependencies.isEmpty()) {
        updateStatus(new Status(IStatus.ERROR, MavenEditorPlugin.PLUGIN_ID,
                Messages.ManageDependenciesDialog_emptySelectionError));
        return;//w w w .ja va2 s.c om
    }
    boolean error = false;
    IMavenProjectFacade facade = MavenPlugin.getMavenProjectRegistry().getMavenProject(
            targetProject.getGroupId(), targetProject.getArtifactId(), targetProject.getVersion());
    if (facade == null) {
        error = true;
        updateStatus(new Status(IStatus.ERROR, MavenEditorPlugin.PLUGIN_ID,
                Messages.ManageDependenciesDialog_projectNotPresentError));
    } else {
        org.apache.maven.model.Model model = null;
        if (facade.getMavenProject() == null || facade.getMavenProject().getModel() == null) {
            try {
                model = MavenPlugin.getMavenModelManager().readMavenModel(facade.getPom());
            } catch (CoreException e) {
                Object[] arguments = { facade.getPom(), e.getLocalizedMessage() };
                String message = NLS.bind(Messages.ManageDependenciesDialog_pomReadingError, arguments);
                Status status = new Status(IStatus.ERROR, MavenEditorPlugin.PLUGIN_ID, message);
                LOG.info(message, e);
                updateStatus(status);
                error = true;
            }
        } else {
            model = facade.getMavenProject().getModel();
        }
        if (model != null) {
            error = checkDependencies(model, getDependenciesList());
        }
    }

    if (!error) {
        clearStatus();
    }
}

From source file:org.eclipse.m2e.editor.xml.internal.dialogs.SelectSPDXLicenseDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    Composite container = (Composite) super.createDialogArea(parent);

    Label lblLicenseNameFilter = new Label(container, SWT.NONE);
    lblLicenseNameFilter.setText(Messages.SelectSPDXLicenseDialog_lblLicenseNameFilter_text);

    final Text licenseFilter = new Text(container, SWT.BORDER | SWT.SEARCH);
    licenseFilter.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Label lblLicenses = new Label(container, SWT.NONE);
    lblLicenses.setText(Messages.SelectSPDXLicenseDialog_lblLicenses_text);

    final TableViewer licensesViewer = new TableViewer(container, SWT.BORDER | SWT.FULL_SELECTION);
    Table licensesTable = licensesViewer.getTable();
    licensesTable.addMouseListener(new MouseAdapter() {
        @Override// w  w  w.  ja  va  2 s.c  o  m
        public void mouseDoubleClick(MouseEvent e) {
            handleDoubleClick();
        }
    });
    licensesTable.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            ISelection selection = licensesViewer.getSelection();
            if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
                license = (SPDXLicense) ((IStructuredSelection) selection).getFirstElement();
            } else {
                license = null;
            }
            updateStatus();
        }
    });
    GridData gd_licensesTable = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    gd_licensesTable.heightHint = 400;
    licensesTable.setLayoutData(gd_licensesTable);
    licensesViewer.setContentProvider(new IStructuredContentProvider() {
        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }

        public void dispose() {
        }

        public Object[] getElements(Object inputElement) {
            if (inputElement instanceof Collection<?>) {
                return ((Collection<?>) inputElement).toArray();
            }
            return null;
        }
    });
    licensesViewer.setLabelProvider(new ILabelProvider() {
        public void removeListener(ILabelProviderListener listener) {
        }

        public boolean isLabelProperty(Object element, String property) {
            return false;
        }

        public void dispose() {
        }

        public void addListener(ILabelProviderListener listener) {
        }

        public String getText(Object element) {
            if (element instanceof SPDXLicense) {
                return ((SPDXLicense) element).getName();
            }
            return null;
        }

        public Image getImage(Object element) {
            return null;
        }
    });
    licensesViewer.setInput(SPDXLicense.getStandardLicenses());

    licenseFilter.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            String text = licenseFilter.getText();
            ViewerFilter[] filters;
            if (text != null && text.trim().length() > 0) {
                filters = new ViewerFilter[] { new LicenseFilter(text.trim()) };
            } else {
                filters = new ViewerFilter[] {};
            }
            licensesViewer.setFilters(filters);
        }
    });

    Label lblPomxml = new Label(container, SWT.NONE);
    lblPomxml.setText(Messages.SelectSPDXLicenseDialog_lblPomxml_text);

    final PomHierarchyComposite parentComposite = new PomHierarchyComposite(container, SWT.NONE);
    parentComposite.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseDoubleClick(MouseEvent e) {
            handleDoubleClick();
        }
    });
    parentComposite.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            ISelection selection = parentComposite.getSelection();
            if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
                MavenProject mavenProject = (MavenProject) ((IStructuredSelection) selection).getFirstElement();
                targetProject = MavenPlugin.getMavenProjectRegistry().getMavenProject(mavenProject.getGroupId(),
                        mavenProject.getArtifactId(), mavenProject.getVersion());
                updateStatus();
            }
        }
    });
    parentComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    parentComposite.computeHeirarchy(project, null); // FIXME proper progress monitor
    parentComposite.setSelection(new StructuredSelection(parentComposite.getHierarchy().get(0)));

    return container;
}

From source file:org.eclipse.m2e.editor.xml.internal.MarkerLocationService.java

License:Open Source License

private static void checkManagedDependencies(IMavenMarkerManager mavenMarkerManager, Element root,
        IResource pomFile, MavenProject mavenproject, String type, IStructuredDocument document)
        throws CoreException {
    List<Element> candidates = new ArrayList<Element>();

    Element dependencies = findChild(root, PomEdits.DEPENDENCIES);
    if (dependencies != null) {
        for (Element el : findChilds(dependencies, PomEdits.DEPENDENCY)) {
            Element version = findChild(el, PomEdits.VERSION);
            if (version != null) {
                candidates.add(el);/* w w w  .  ja  v  a2 s  .  c  om*/
            }
        }
    }
    //we should also consider <dependencies> section in the profiles, but profile are optional and so is their
    // dependencyManagement section.. that makes handling our markers more complex.
    // see MavenProject.getInjectedProfileIds() for a list of currently active profiles in effective pom
    String currentProjectKey = mavenproject.getGroupId() + ":" + mavenproject.getArtifactId() + ":" //$NON-NLS-1$//$NON-NLS-2$
            + mavenproject.getVersion();
    List<String> activeprofiles = mavenproject.getInjectedProfileIds().get(currentProjectKey);
    //remember what profile we found the dependency in.
    Map<Element, String> candidateProfile = new HashMap<Element, String>();
    Element profiles = findChild(root, PomEdits.PROFILES);
    if (profiles != null) {
        for (Element profile : findChilds(profiles, PomEdits.PROFILE)) {
            String idString = getTextValue(findChild(profile, PomEdits.ID));
            if (idString != null && activeprofiles.contains(idString)) {
                dependencies = findChild(profile, PomEdits.DEPENDENCIES);
                if (dependencies != null) {
                    for (Element el : findChilds(dependencies, PomEdits.DEPENDENCY)) {
                        Element version = findChild(el, PomEdits.VERSION);
                        if (version != null) {
                            candidates.add(el);
                            candidateProfile.put(el, idString);
                        }
                    }
                }
            }
        }
    }
    //collect the managed dep ids
    Map<String, String> managed = new HashMap<String, String>();
    DependencyManagement dm = mavenproject.getDependencyManagement();
    if (dm != null) {
        List<Dependency> deps = dm.getDependencies();
        if (deps != null) {
            for (Dependency dep : deps) {
                if (dep.getVersion() != null) { //#335366
                    //shall we be using geManagementkey() here? but it contains also the type, not only the gr+art ids..
                    managed.put(dep.getGroupId() + ":" + dep.getArtifactId(), dep.getVersion()); //$NON-NLS-1$
                }
            }
        }
    }

    //now we have all the candidates, match them against the effective managed set 
    for (Element dep : candidates) {
        Element version = findChild(dep, PomEdits.VERSION);
        String grpString = getTextValue(findChild(dep, PomEdits.GROUP_ID));
        String artString = getTextValue(findChild(dep, PomEdits.ARTIFACT_ID));
        String versionString = getTextValue(version);
        if (grpString != null && artString != null && versionString != null) {
            String id = grpString + ":" + artString; //$NON-NLS-1$
            if (managed.containsKey(id)) {
                String managedVersion = managed.get(id);
                if (version instanceof IndexedRegion) {
                    IndexedRegion off = (IndexedRegion) version;
                    if (lookForIgnoreMarker(document, version, off, IMavenConstants.MARKER_IGNORE_MANAGED)) {
                        continue;
                    }

                    IMarker mark = mavenMarkerManager.addMarker(pomFile, type,
                            NLS.bind(org.eclipse.m2e.core.internal.Messages.MavenMarkerManager_managed_title,
                                    managedVersion, artString),
                            document.getLineOfOffset(off.getStartOffset()) + 1, IMarker.SEVERITY_WARNING);
                    mark.setAttribute(IMavenConstants.MARKER_ATTR_EDITOR_HINT,
                            IMavenConstants.EDITOR_HINT_MANAGED_DEPENDENCY_OVERRIDE);
                    mark.setAttribute(IMarker.CHAR_START, off.getStartOffset());
                    mark.setAttribute(IMarker.CHAR_END, off.getEndOffset());
                    mark.setAttribute("problemType", "pomhint"); //only imporant in case we enable the generic xml quick fixes //$NON-NLS-1$ //$NON-NLS-2$
                    //add these attributes to easily and deterministicaly find the declaration in question
                    mark.setAttribute("groupId", grpString); //$NON-NLS-1$
                    mark.setAttribute("artifactId", artString); //$NON-NLS-1$
                    String profile = candidateProfile.get(dep);
                    if (profile != null) {
                        mark.setAttribute("profile", profile); //$NON-NLS-1$
                    }
                }
            }
        }
    }
}

From source file:org.eclipse.m2e.editor.xml.internal.MarkerLocationService.java

License:Open Source License

private static void checkManagedPlugins(IMavenMarkerManager mavenMarkerManager, Element root, IResource pomFile,
        MavenProject mavenproject, String type, IStructuredDocument document) throws CoreException {
    List<Element> candidates = new ArrayList<Element>();
    Element build = findChild(root, PomEdits.BUILD);
    if (build == null) {
        return;/*from  www .ja va 2s. c  o m*/
    }
    Element plugins = findChild(build, PomEdits.PLUGINS);
    if (plugins != null) {
        for (Element el : findChilds(plugins, PomEdits.PLUGIN)) {
            Element version = findChild(el, PomEdits.VERSION);
            if (version != null) {
                candidates.add(el);
            }
        }
    }
    //we should also consider <plugins> section in the profiles, but profile are optional and so is their
    // pluginManagement section.. that makes handling our markers more complex.
    // see MavenProject.getInjectedProfileIds() for a list of currently active profiles in effective pom
    String currentProjectKey = mavenproject.getGroupId() + ":" + mavenproject.getArtifactId() + ":" //$NON-NLS-1$//$NON-NLS-2$
            + mavenproject.getVersion();
    List<String> activeprofiles = mavenproject.getInjectedProfileIds().get(currentProjectKey);
    //remember what profile we found the dependency in.
    Map<Element, String> candidateProfile = new HashMap<Element, String>();
    Element profiles = findChild(root, PomEdits.PROFILES);
    if (profiles != null) {
        for (Element profile : findChilds(profiles, PomEdits.PROFILE)) {
            String idString = getTextValue(findChild(profile, PomEdits.ID));
            if (idString != null && activeprofiles.contains(idString)) {
                build = findChild(profile, PomEdits.BUILD);
                if (build == null) {
                    continue;
                }
                plugins = findChild(build, PomEdits.PLUGINS);
                if (plugins != null) {
                    for (Element el : findChilds(plugins, PomEdits.PLUGIN)) {
                        Element version = findChild(el, PomEdits.VERSION);
                        if (version != null) {
                            candidates.add(el);
                            candidateProfile.put(el, idString);
                        }
                    }
                }
            }
        }
    }
    //collect the managed plugin ids
    Map<String, String> managed = new HashMap<String, String>();
    PluginManagement pm = mavenproject.getPluginManagement();
    if (pm != null) {
        List<Plugin> plgs = pm.getPlugins();
        if (plgs != null) {
            for (Plugin plg : plgs) {
                InputLocation loc = plg.getLocation("version");
                //#350203 skip plugins defined in the superpom
                if (loc != null) {
                    managed.put(plg.getKey(), plg.getVersion());
                }
            }
        }
    }

    //now we have all the candidates, match them against the effective managed set 
    for (Element dep : candidates) {
        String grpString = getTextValue(findChild(dep, PomEdits.GROUP_ID)); //$NON-NLS-1$
        if (grpString == null) {
            grpString = "org.apache.maven.plugins"; //$NON-NLS-1$
        }
        String artString = getTextValue(findChild(dep, PomEdits.ARTIFACT_ID)); //$NON-NLS-1$
        Element version = findChild(dep, PomEdits.VERSION); //$NON-NLS-1$
        String versionString = getTextValue(version);
        if (artString != null && versionString != null) {
            String id = Plugin.constructKey(grpString, artString);
            if (managed.containsKey(id)) {
                String managedVersion = managed.get(id);
                if (version instanceof IndexedRegion) {
                    IndexedRegion off = (IndexedRegion) version;
                    if (lookForIgnoreMarker(document, version, off, IMavenConstants.MARKER_IGNORE_MANAGED)) {
                        continue;
                    }

                    IMarker mark = mavenMarkerManager.addMarker(pomFile, type,
                            NLS.bind(org.eclipse.m2e.core.internal.Messages.MavenMarkerManager_managed_title,
                                    managedVersion, artString),
                            document.getLineOfOffset(off.getStartOffset()) + 1, IMarker.SEVERITY_WARNING);
                    mark.setAttribute(IMavenConstants.MARKER_ATTR_EDITOR_HINT,
                            IMavenConstants.EDITOR_HINT_MANAGED_PLUGIN_OVERRIDE);
                    mark.setAttribute(IMarker.CHAR_START, off.getStartOffset());
                    mark.setAttribute(IMarker.CHAR_END, off.getEndOffset());
                    mark.setAttribute("problemType", "pomhint"); //only imporant in case we enable the generic xml quick fixes //$NON-NLS-1$ //$NON-NLS-2$
                    //add these attributes to easily and deterministicaly find the declaration in question
                    mark.setAttribute("groupId", grpString); //$NON-NLS-1$
                    mark.setAttribute("artifactId", artString); //$NON-NLS-1$
                    String profile = candidateProfile.get(dep);
                    if (profile != null) {
                        mark.setAttribute("profile", profile); //$NON-NLS-1$
                    }
                }
            }
        }
    }
}