use of org.jetbrains.idea.maven.dom.model.MavenDomPluginExecution 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();
}
use of org.jetbrains.idea.maven.dom.model.MavenDomPluginExecution 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;
}
Aggregations