PomXmlUtils extends AbstractXmlUtil { @SuppressWarnings("unchecked") Set<Artifact> readDependencies(Path pomXml) { String dependenciesExp = String.format("/%s/%s/*", PROJECT, DEPENDENCIES); String dependenciesManagmentExp = String.format("/%s/%s/%s/*", PROJECT, DEPENDENCIES_MANAGMENT, DEPENDENCIES); Document doc = readDocumentFromFile(pomXml); NodeList dependenciesNode = executeExpression(dependenciesExp, doc); if (dependenciesNode == null || dependenciesNode.getLength() == 0) { dependenciesNode = executeExpression(dependenciesManagmentExp, doc); } Set<Artifact> dependencies = Sets.newHashSet(); if (dependenciesNode != null && dependenciesNode.getLength() != 0) { Map<String, String> versions = getPropertiesVersionsFromPomXml(pomXml); for (int i = 0; i < dependenciesNode.getLength(); i++) { Node node = dependenciesNode.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) node; Artifact artifact = parseDependency(element, versions); if (artifact!=null) dependencies.add(artifact); } } } return dependencies; }    }
@Test public void readDependencies() { Path parent = Paths.get("../pom.xml"); Set<Artifact> artifacts = OrienteerClassLoaderUtil.readDependencies(parent); assertTrue("Dependencies from parent pom.xml", artifacts.size() > 0); }