private static void collectChildrenProjects( @NotNull final MavenDomProjectModel model, @NotNull Set<MavenDomProjectModel> models) { MavenProject mavenProject = MavenDomUtil.findProject(model); if (mavenProject != null) { final Project project = model.getManager().getProject(); for (MavenProject inheritor : MavenProjectsManager.getInstance(project).findInheritors(mavenProject)) { MavenDomProjectModel inheritorProjectModel = MavenDomUtil.getMavenDomProjectModel(project, inheritor.getFile()); if (inheritorProjectModel != null && !models.contains(inheritorProjectModel)) { models.add(inheritorProjectModel); collectChildrenProjects(inheritorProjectModel, models); } } } }
@Nullable public static MavenDomProjectModel findParent( @NotNull MavenDomParent mavenDomParent, Project project) { if (!DomUtil.hasXml(mavenDomParent)) return null; MavenId id = new MavenId( mavenDomParent.getGroupId().getStringValue(), mavenDomParent.getArtifactId().getStringValue(), mavenDomParent.getVersion().getStringValue()); MavenProject mavenProject = MavenProjectsManager.getInstance(project).findProject(id); return mavenProject != null ? MavenDomUtil.getMavenDomProjectModel(project, mavenProject.getFile()) : null; }
public static void processChildrenRecursively( @Nullable MavenDomProjectModel model, @NotNull Processor<MavenDomProjectModel> processor, @NotNull Project project, @NotNull Set<MavenDomProjectModel> processedModels, boolean strict) { if (model != null && !processedModels.contains(model)) { processedModels.add(model); if (strict && processor.process(model)) return; MavenProject mavenProject = MavenDomUtil.findProject(model); if (mavenProject != null) { for (MavenProject childProject : MavenProjectsManager.getInstance(project).findInheritors(mavenProject)) { MavenDomProjectModel childProjectModel = MavenDomUtil.getMavenDomProjectModel(project, childProject.getFile()); processChildrenRecursively(childProjectModel, processor, project, processedModels, true); } } } }
private static <T> boolean processProfiles( MavenDomProfiles profilesDom, MavenProject mavenProjectOrNull, Processor<T> processor, Function<? super MavenDomProfile, T> f) { Collection<String> activeProfiles = mavenProjectOrNull == null ? null : mavenProjectOrNull.getActivatedProfilesIds().getEnabledProfiles(); for (MavenDomProfile each : profilesDom.getProfiles()) { XmlTag idTag = each.getId().getXmlTag(); if (idTag == null) continue; if (activeProfiles != null && !activeProfiles.contains(idTag.getValue().getTrimmedText())) continue; if (processProfile(each, processor, f)) return true; } return false; }
protected VirtualFile findManagedFile(@NotNull MavenId id) { MavenProject project = myManager.findProject(id); return project == null ? null : project.getFile(); }