private void exclude() { final MavenArtifact artifactToExclude = mavenArtifactNode.getArtifact(); final MavenArtifactNode oldestParent = getOldestParentMavenArtifact(); DomFileElement domFileElement = getDomFileElement(oldestParent); if (domFileElement != null) { final MavenDomProjectModel rootElement = (MavenDomProjectModel) domFileElement.getRootElement(); final MavenDomDependencies dependencies = rootElement.getDependencies(); boolean found = false; for (MavenDomDependency mavenDomDependency : dependencies.getDependencies()) { if (isSameDependency(oldestParent.getArtifact(), mavenDomDependency)) { found = true; final MavenDomExclusions exclusions = mavenDomDependency.getExclusions(); for (MavenDomExclusion mavenDomExclusion : exclusions.getExclusions()) { if (isSameDependency(artifactToExclude, mavenDomExclusion)) { return; } } createExclusion(artifactToExclude, exclusions); dependencyExcluded(); } } if (!found) { final Notification notification = new Notification( MAVEN_HELPER_DEPENDENCY_ANALYZER_NOTIFICATION, "", "Parent dependency not found, it is probably in parent pom", NotificationType.WARNING); ApplicationManager.getApplication() .invokeLater( new Runnable() { @Override public void run() { Notifications.Bus.notify(notification, project); } }); } } else { final Notification notification = new Notification( MAVEN_HELPER_DEPENDENCY_ANALYZER_NOTIFICATION, "", "Pom file not found", NotificationType.WARNING); ApplicationManager.getApplication() .invokeLater( new Runnable() { @Override public void run() { Notifications.Bus.notify(notification, project); } }); } }
private static void checkMavenProjectModel( @NotNull MavenDomProjectModel projectModel, @NotNull XmlFile xmlFile, @NotNull DomElementAnnotationHolder holder) { final Map<String, Set<MavenDomDependency>> allDuplicates = getDuplicateDependenciesMap(projectModel); for (MavenDomDependency dependency : projectModel.getDependencies().getDependencies()) { String id = createId(dependency); if (id != null) { Set<MavenDomDependency> dependencies = allDuplicates.get(id); if (dependencies != null && dependencies.size() > 1) { addProblem(dependency, dependencies, holder); } } } }
@NotNull public static MavenDomDependency createDomDependency( @NotNull MavenDomProjectModel model, @Nullable Editor editor) { return createDomDependency(model.getDependencies(), editor); }