use of javax.xml.xpath.XPath in project flyway by flyway.
the class MavenTestCase method getPomVersion.
/**
* Retrieves the version embedded in the project pom. Useful for running these tests in IntelliJ.
*
* @return The POM version.
*/
private String getPomVersion() {
try {
File pom = new File("pom.xml");
if (!pom.exists()) {
return "unknown";
}
XPath xPath = XPathFactory.newInstance().newXPath();
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(false);
Document document = documentBuilderFactory.newDocumentBuilder().parse(pom);
return xPath.evaluate("/project/version", document);
} catch (Exception e) {
throw new IllegalStateException("Unable to read POM version", e);
}
}
use of javax.xml.xpath.XPath in project buck by facebook.
the class AndroidXPathFactory method newXPath.
/**
* Creates a new XPath object, specifying which prefix in the query is used for the
* android namespace.
* @param androidPrefix The namespace prefix.
*/
public static XPath newXPath(String androidPrefix) {
XPath xpath = sFactory.newXPath();
xpath.setNamespaceContext(new AndroidNamespaceContext(androidPrefix));
return xpath;
}
use of javax.xml.xpath.XPath in project buck by facebook.
the class AndroidXPathFactory method newXPath.
/**
* Creates a new XPath object using the default prefix for the android namespace.
* @see #DEFAULT_NS_PREFIX
*/
public static XPath newXPath() {
XPath xpath = sFactory.newXPath();
xpath.setNamespaceContext(AndroidNamespaceContext.getDefault());
return xpath;
}
use of javax.xml.xpath.XPath in project flyway by flyway.
the class AntLargeTest method getPomVersion.
/**
* Retrieves the version embedded in the project pom. Useful for running these tests in IntelliJ.
*
* @return The POM version.
*/
private String getPomVersion() {
try {
File pom = new File("pom.xml");
if (!pom.exists()) {
return "unknown";
}
XPath xPath = XPathFactory.newInstance().newXPath();
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(false);
Document document = documentBuilderFactory.newDocumentBuilder().parse(pom);
return xPath.evaluate("/project/version", document);
} catch (Exception e) {
throw new IllegalStateException("Unable to read POM version", e);
}
}
use of javax.xml.xpath.XPath in project flyway by flyway.
the class CommandLineLargeTest method getPomVersion.
/**
* Retrieves the version embedded in the project pom. Useful for running these tests in IntelliJ.
*
* @return The POM version.
*/
protected String getPomVersion() {
try {
File pom = new File("pom.xml");
if (!pom.exists()) {
return "unknown";
}
XPath xPath = XPathFactory.newInstance().newXPath();
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(false);
Document document = documentBuilderFactory.newDocumentBuilder().parse(pom);
return xPath.evaluate("/project/version", document);
} catch (Exception e) {
throw new IllegalStateException("Unable to read POM version", e);
}
}
Aggregations