Search in sources :

Example 1 with MavenDomGoal

use of org.jetbrains.idea.maven.dom.model.MavenDomGoal in project intellij-community by JetBrains.

the class MavenPluginDescriptor method processDescriptors.

public static boolean processDescriptors(Processor<MavenPluginDescriptor> processor, MavenDomConfiguration cfg) {
    Map<String, Map<String, Map<String, List<MavenPluginDescriptor>>>> map = getDescriptorsMap();
    DomElement parent = cfg.getParent();
    MavenDomPlugin plugin = DomUtil.getParentOfType(parent, MavenDomPlugin.class, false);
    if (plugin == null)
        return true;
    Map<String, Map<String, List<MavenPluginDescriptor>>> groupMap = map.get(plugin.getArtifactId().getStringValue());
    if (groupMap == null)
        return true;
    Map<String, List<MavenPluginDescriptor>> goalsMap = groupMap.get(plugin.getGroupId().getStringValue());
    if (goalsMap == null)
        return true;
    List<MavenPluginDescriptor> descriptorsForAllGoals = goalsMap.get(null);
    if (descriptorsForAllGoals != null) {
        for (MavenPluginDescriptor descriptor : descriptorsForAllGoals) {
            if (!processor.process(descriptor))
                return false;
        }
    }
    if (parent instanceof MavenDomPluginExecution) {
        for (MavenDomGoal goal : ((MavenDomPluginExecution) parent).getGoals().getGoals()) {
            List<MavenPluginDescriptor> descriptors = goalsMap.get(goal.getStringValue());
            if (descriptors != null) {
                for (MavenPluginDescriptor descriptor : descriptors) {
                    if (!processor.process(descriptor))
                        return false;
                }
            }
        }
    }
    return true;
}
Also used : MavenDomPluginExecution(org.jetbrains.idea.maven.dom.model.MavenDomPluginExecution) DomElement(com.intellij.util.xml.DomElement) MavenDomPlugin(org.jetbrains.idea.maven.dom.model.MavenDomPlugin) List(java.util.List) SmartList(com.intellij.util.SmartList) HashMap(java.util.HashMap) Map(java.util.Map) MavenDomGoal(org.jetbrains.idea.maven.dom.model.MavenDomGoal)

Example 2 with MavenDomGoal

use of org.jetbrains.idea.maven.dom.model.MavenDomGoal in project intellij-community by JetBrains.

the class MavenGoalsPresentationProvider method getName.

@Nullable
@Override
public String getName(MavenDomGoals mavenDomGoals) {
    StringBuilder res = new StringBuilder("Goals");
    boolean hasGoals = false;
    for (MavenDomGoal mavenDomGoal : mavenDomGoals.getGoals()) {
        String goal = mavenDomGoal.getStringValue();
        if (!StringUtil.isEmptyOrSpaces(goal)) {
            if (hasGoals) {
                res.append(", ");
            } else {
                res.append(" (");
                hasGoals = true;
            }
            res.append(goal);
        }
    }
    if (hasGoals) {
        res.append(")");
    }
    return res.toString();
}
Also used : MavenDomGoal(org.jetbrains.idea.maven.dom.model.MavenDomGoal) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

MavenDomGoal (org.jetbrains.idea.maven.dom.model.MavenDomGoal)2 SmartList (com.intellij.util.SmartList)1 DomElement (com.intellij.util.xml.DomElement)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Nullable (org.jetbrains.annotations.Nullable)1 MavenDomPlugin (org.jetbrains.idea.maven.dom.model.MavenDomPlugin)1 MavenDomPluginExecution (org.jetbrains.idea.maven.dom.model.MavenDomPluginExecution)1