Search in sources :

Example 1 with MavenDomParameter

use of org.jetbrains.idea.maven.dom.plugin.MavenDomParameter in project intellij-community by JetBrains.

the class MavenPluginConfigurationDomExtender method collectParameters.

private static Collection<ParameterData> collectParameters(MavenDomPluginModel pluginModel, MavenDomConfiguration config) {
    List<String> selectedGoals = null;
    MavenDomPluginExecution executionElement = config.getParentOfType(MavenDomPluginExecution.class, false);
    if (executionElement != null) {
        selectedGoals = new ArrayList<>();
        String id = executionElement.getId().getStringValue();
        String defaultPrefix = "default-";
        if (id != null && id.startsWith(defaultPrefix)) {
            String goal = id.substring(defaultPrefix.length());
            if (!StringUtil.isEmptyOrSpaces(goal))
                selectedGoals.add(goal);
        }
        for (GenericDomValue<String> goal : executionElement.getGoals().getGoals()) {
            selectedGoals.add(goal.getStringValue());
        }
    }
    Map<String, ParameterData> namesWithParameters = new THashMap<>();
    for (MavenDomMojo eachMojo : pluginModel.getMojos().getMojos()) {
        String goal = eachMojo.getGoal().getStringValue();
        if (goal == null)
            continue;
        if (selectedGoals == null || selectedGoals.contains(goal)) {
            for (MavenDomParameter eachParameter : eachMojo.getParameters().getParameters()) {
                if (eachParameter.getEditable().getValue() == Boolean.FALSE)
                    continue;
                String name = eachParameter.getName().getStringValue();
                if (name == null)
                    continue;
                ParameterData data = new ParameterData(eachParameter);
                fillParameterData(name, data, eachMojo);
                ParameterData oldParameter = namesWithParameters.get(name);
                if (oldParameter == null || hasMorePriority(data, oldParameter, executionElement != null)) {
                    namesWithParameters.put(name, data);
                }
            }
        }
    }
    return namesWithParameters.values();
}
Also used : MavenDomPluginExecution(org.jetbrains.idea.maven.dom.model.MavenDomPluginExecution) THashMap(gnu.trove.THashMap) MavenDomMojo(org.jetbrains.idea.maven.dom.plugin.MavenDomMojo) MavenDomParameter(org.jetbrains.idea.maven.dom.plugin.MavenDomParameter)

Aggregations

THashMap (gnu.trove.THashMap)1 MavenDomPluginExecution (org.jetbrains.idea.maven.dom.model.MavenDomPluginExecution)1 MavenDomMojo (org.jetbrains.idea.maven.dom.plugin.MavenDomMojo)1 MavenDomParameter (org.jetbrains.idea.maven.dom.plugin.MavenDomParameter)1