/**
* Returns the version
*
* @return String
*/
public static String getVersion() {
String jarImplementation = VISNode.class.getPackage().getImplementationVersion();
if (jarImplementation != null) {
return jarImplementation;
}
String file = VISNode.class.getResource(".").getFile();
String pack = VISNode.class.getPackage().getName().replace(".", "/") + '/';
File pomXml = new File(file.replace("target/classes/" + pack, "pom.xml"));
if (pomXml.exists()) {
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(new InputSource(new FileReader(pomXml)));
XPath xPath = XPathFactory.newInstance().newXPath();
return (String) xPath.evaluate("/project/version", document, XPathConstants.STRING);
} catch (IOException | ParserConfigurationException | XPathExpressionException | SAXException e) { }
}
return "Unknown version";
}
VersionFinder.java 文件源码
java
阅读 20
收藏 0
点赞 0
评论 0
项目:VISNode
作者:
评论列表
文章目录