use of org.eclipse.m2e.model.edit.pom.Exclusion in project m2e-core-tests by tesla.
the class ExcludeArtifactRefactoringTest method hasExclusionSet.
/*
* The editor has the given exclusion set
*/
protected static boolean hasExclusionSet(MavenPomEditor editor, final ArtifactKey dependencyKey, final ArtifactKey excluded) throws Exception {
final boolean[] found = new boolean[1];
found[0] = false;
performOnDOMDocument(new OperationTuple(editor.getDocument(), document -> {
Element dep = findChild(findChild(document.getDocumentElement(), DEPENDENCIES), DEPENDENCY, childEquals(GROUP_ID, dependencyKey.getGroupId()), childEquals(ARTIFACT_ID, dependencyKey.getArtifactId()), childEquals(VERSION, dependencyKey.getVersion()));
if (dep != null) {
Element exclusion = findChild(findChild(dep, EXCLUSIONS), EXCLUSION, childEquals(GROUP_ID, excluded.getGroupId()), childEquals(ARTIFACT_ID, excluded.getArtifactId()));
found[0] = exclusion != null;
}
}, true));
return found[0];
}
use of org.eclipse.m2e.model.edit.pom.Exclusion in project m2e-core-tests by tesla.
the class ExcludeArtifactRefactoringTest method hasExclusionSet.
/*
* The editor has the given exclusion set
*/
protected static boolean hasExclusionSet(IProject project, ArtifactKey dependencyKey, ArtifactKey excluded) throws Exception {
Model model = loadResource(project.getFile("pom.xml")).getModel();
Dependency d = null;
for (Dependency dep : model.getDependencies()) {
if (dep.getArtifactId().equals(dependencyKey.getArtifactId()) && dep.getGroupId().equals(dependencyKey.getGroupId()) && dep.getVersion().equals(dependencyKey.getVersion())) {
d = dep;
break;
}
}
if (d == null) {
return false;
}
for (Exclusion ex : d.getExclusions()) {
if (ex.getArtifactId().equals(excluded.getArtifactId()) && ex.getGroupId().equals(excluded.getGroupId())) {
return true;
}
}
return false;
}
Aggregations