projectInfo.put("basePackage", XPathUtils.evaluateExpression(pomDoc, "/mvn:project/mvn:groupId", nsContext, XPathConstants.STRING));
projectInfo.put("name", XPathUtils.evaluateExpression(pomDoc, "/mvn:project/mvn:artifactId", nsContext, XPathConstants.STRING));
projectInfo.put("version", XPathUtils.evaluateExpression(pomDoc, "/mvn:project/mvn:properties/mvn:citrus.version", nsContext, XPathConstants.STRING));
projectInfo.put("description", XPathUtils.evaluateExpression(pomDoc, "/mvn:project/mvn:description", nsContext, XPathConstants.STRING));
} catch (IOException e) {
throw new CitrusAdminRuntimeException("Unable to open Maven pom.xml file", e);
}
} else if (isAntProject()) {
try {
String buildXml = FileUtils.readToString(new FileSystemResource(new File(getAntBuildFilePath())));
SimpleNamespaceContext nsContext = new SimpleNamespaceContext();
Document buildDoc = XMLUtils.parseMessagePayload(buildXml);
projectInfo.put("name", XPathUtils.evaluateExpression(buildDoc, "/project/@name", nsContext, XPathConstants.STRING));
projectInfo.put("version", XPathUtils.evaluateExpression(buildDoc, "/project/property[@name='citrus.version']/@value", nsContext, XPathConstants.STRING));
projectInfo.put("description", XPathUtils.evaluateExpression(buildDoc, "/project/@description", nsContext, XPathConstants.STRING));
} catch (IOException e) {
throw new CitrusAdminRuntimeException("Unable to open ANT build.xml file", e);
}
} else {
projectInfo.put("basePackage", basePackage);
projectInfo.put("name", name);
projectInfo.put("version", version);
projectInfo.put("description", description);
}
FileOutputStream fos = null;
try {
fos = new FileOutputStream(getProjectInfoFile());
fos.write(projectInfo.toJSONString().getBytes());
fos.flush();
} catch (FileNotFoundException e) {
throw new CitrusRuntimeException("Unable to open project info file", e);
} catch (IOException e) {
throw new CitrusAdminRuntimeException("Unable to write project info file", e);
} finally {
if (fos != null) {
try {
fos.close();
} catch (IOException e) {