MavenModel (final MavenGeneralSettings generalSettings, MavenModel model, final Path projectPomDir, final VirtualFile file, final MavenExplicitProfiles explicitProfiles, final Set<VirtualFile> recursionGuard, final MavenProjectReaderProjectLocator locator, Collection<MavenProjectProblem> problems) { if (recursionGuard.contains(file)) { problems .add(MavenProjectProblem.createProblem(file.getPath(), MavenProjectBundle.message("maven.project.problem.recursiveInheritance"), MavenProjectProblem.ProblemType.PARENT, false)); return model; } recursionGuard.add(file); try { final MavenParentDesc[] parentDesc = new MavenParentDesc[1]; MavenParent parent = model.getParent(); if (parent != null) { if (model.getMavenId().equals(parent.getMavenId())) { problems .add(MavenProjectProblem.createProblem(file.getPath(), MavenProjectBundle.message("maven.project.problem.selfInheritance"), MavenProjectProblem.ProblemType.PARENT, false)); return model; } parentDesc[0] = new MavenParentDesc(parent.getMavenId(), parent.getRelativePath()); } Pair<VirtualFile, RawModelReadResult> parentModelWithProblems = new MavenParentProjectFileProcessor<Pair<VirtualFile, RawModelReadResult>>(myProject) { @Override @Nullable protected VirtualFile findManagedFile(@NotNull MavenId id) { return locator.findProjectFile(id); } @Override @Nullable protected Pair<VirtualFile, RawModelReadResult> processRelativeParent(VirtualFile parentFile) { MavenModel parentModel = doReadProjectModel(myProject, parentFile, true).model; MavenId parentId = parentDesc[0].getParentId(); if (!parentId.equals(parentModel.getMavenId())) return null; return super.processRelativeParent(parentFile); } @Override protected Pair<VirtualFile, RawModelReadResult> processSuperParent(VirtualFile parentFile) { return null; // do not process superPom } @Override protected Pair<VirtualFile, RawModelReadResult> doProcessParent(VirtualFile parentFile) { RawModelReadResult result = doReadProjectModel(generalSettings, projectPomDir, parentFile, explicitProfiles, recursionGuard, locator).first; return Pair.create(parentFile, result); } }.process(generalSettings, file, parentDesc[0]); if (parentModelWithProblems == null) return model; // no parent or parent not found; MavenModel parentModel = parentModelWithProblems.second.model; if (!parentModelWithProblems.second.problems.isEmpty()) { problems.add(MavenProjectProblem.createProblem(parentModelWithProblems.first.getPath(), MavenProjectBundle.message("maven.project.problem.parentHasProblems", parentModel.getMavenId()), MavenProjectProblem.ProblemType.PARENT, false)); } model = myReadHelper.assembleInheritance(projectPomDir, parentModel, model); // todo: it is a quick-hack here - we add inherited dummy profiles to correctly collect activated profiles in 'applyProfiles'. List<MavenProfile> profiles = model.getProfiles(); for (MavenProfile each : parentModel.getProfiles()) { MavenProfile copyProfile = new MavenProfile(each.getId(), each.getSource()); if (each.getActivation() != null) { copyProfile.setActivation(each.getActivation().clone()); } addProfileIfDoesNotExist(copyProfile, profiles); } return model; } finally { recursionGuard.remove(file); } }