PomXmlUtils extends AbstractXmlUtil { Artifact readGroupArtifactVersionInPomXml(Path pomXml) { String groupExpression = String.format("/%s/%s", PROJECT, GROUP); String artifactExpression = String.format("/%s/%s", PROJECT, ARTIFACT); String versionExpression = String.format("/%s/%s", PROJECT, VERSION); Document doc = readDocumentFromFile(pomXml); NodeList group = executeExpression(groupExpression, doc); NodeList artifact = executeExpression(artifactExpression, doc); NodeList version = executeExpression(versionExpression, doc); Artifact parent = readParentGAVInPomXml(pomXml); String groupId = (group != null && group.getLength() > 0) ? group.item(0).getTextContent() : (parent != null ? parent.getGroupId() : null); String artifactId = (artifact != null && artifact.getLength() > 0) ? artifact.item(0).getTextContent() : null; String versionId = (version != null && version.getLength() > 0) ? version.item(0).getTextContent() : (parent != null ? parent.getVersion() : null); return (groupId != null && artifactId != null && versionId != null) ? (Artifact) new DefaultArtifact(getGAV(groupId, artifactId, versionId)) : null; }    }
@Test public void readGroupArtifactVersionInPomXml() throws Exception { Artifact artifact = OrienteerClassLoaderUtil.readGroupArtifactVersionInPomXml(pomXml); assertNotNull("Artifact from pom.xml", artifact); }