DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
DocumentBuilder db = dbf.newDocumentBuilder();
Document document = db.parse(mavenSettingsFile);
XPath xpath = XPathFactory.newInstance().newXPath();
SimpleNamespaceContext nc = new SimpleNamespaceContext();
nc.addPrefix("m", "http://maven.apache.org/POM/4.0.0");
xpath.setNamespaceContext(nc);
String localRepository = xpath.evaluate("string(/m:settings/m:localRepository)", document);
if (localRepository != null && localRepository.length() > 0) {
return new File(localRepository);