use of org.codehaus.plexus.util.xml.Xpp3Dom in project intellij-community by JetBrains.
the class Maven2ModelConverter method xppToElement.
private static Element xppToElement(Xpp3Dom xpp) throws RemoteException {
Element result;
try {
result = new Element(xpp.getName());
} catch (IllegalNameException e) {
Maven2ServerGlobals.getLogger().info(e);
return null;
}
Xpp3Dom[] children = xpp.getChildren();
if (children == null || children.length == 0) {
result.setText(xpp.getValue());
} else {
for (Xpp3Dom each : children) {
Element child = xppToElement(each);
if (child != null)
result.addContent(child);
}
}
return result;
}
use of org.codehaus.plexus.util.xml.Xpp3Dom in project asterixdb by apache.
the class SupplementalModelHelper method loadSupplements.
static Map<String, Model> loadSupplements(Log log, String[] models) throws MojoExecutionException {
if (models == null) {
log.debug("Supplemental data models won't be loaded. " + "No models specified.");
return Collections.emptyMap();
}
List<Supplement> supplements = new ArrayList<>();
for (String set : models) {
log.debug("Preparing ruleset: " + set);
try {
File f = new File(set);
if (!f.exists()) {
throw new MojoExecutionException("Cold not resolve " + set);
}
if (!f.canRead()) {
throw new MojoExecutionException("Supplemental data models won't be loaded. " + "File " + f.getAbsolutePath() + " cannot be read, check permissions on the file.");
}
log.debug("Loading supplemental models from " + f.getAbsolutePath());
SupplementalDataModelXpp3Reader reader = new SupplementalDataModelXpp3Reader();
try (FileInputStream fis = new FileInputStream(f);
Reader fileReader = new InputStreamReader(fis)) {
SupplementalDataModel supplementalModel = reader.read(fileReader);
supplements.addAll(supplementalModel.getSupplement());
}
} catch (Exception e) {
String msg = "Error loading supplemental data models: " + e.getMessage();
log.error(msg, e);
throw new MojoExecutionException(msg, e);
}
}
log.debug("Loading supplements complete.");
Map<String, Model> supplementMap = new HashMap<>();
for (Supplement sd : supplements) {
Xpp3Dom dom = (Xpp3Dom) sd.getProject();
Model m = getSupplement(log, dom);
supplementMap.put(generateSupplementMapKey(m.getGroupId(), m.getArtifactId()), m);
}
return supplementMap;
}
use of org.codehaus.plexus.util.xml.Xpp3Dom in project felix by apache.
the class XMLReport method generateReport.
/**
* Generates the XML reports.
* @param test the test
* @param tr the test result
* @param reportsDirectory the directory in which reports are created.
* @param bc the bundle context (to get installed bundles)
* @param configuration the Felix configuration
* @throws Exception when the XML report cannot be generated correctly
*/
public void generateReport(Test test, TestResult tr, File reportsDirectory, BundleContext bc, Map configuration) throws Exception {
long runTime = this.m_endTime - this.m_startTime;
Xpp3Dom testSuite = createTestSuiteElement(test, runTime);
showProperties(testSuite, bc, configuration);
testSuite.setAttribute("tests", String.valueOf(tr.runCount()));
testSuite.setAttribute("errors", String.valueOf(tr.errorCount()));
testSuite.setAttribute("failures", String.valueOf(tr.failureCount()));
for (Iterator i = m_results.iterator(); i.hasNext(); ) {
Xpp3Dom testcase = (Xpp3Dom) i.next();
testSuite.addChild(testcase);
}
File reportFile = new File(reportsDirectory, "TEST-" + getReportName(test).replace(' ', '_') + ".xml");
File reportDir = reportFile.getParentFile();
reportDir.mkdirs();
PrintWriter writer = null;
try {
writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(reportFile), "UTF-8")));
writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + NL);
Xpp3DomWriter.write(new PrettyPrintXMLWriter(writer), testSuite);
} catch (UnsupportedEncodingException e) {
throw new Exception("Unable to use UTF-8 encoding", e);
} catch (FileNotFoundException e) {
throw new Exception("Unable to create file: " + e.getMessage(), e);
} finally {
IOUtil.close(writer);
}
}
use of org.codehaus.plexus.util.xml.Xpp3Dom in project felix by apache.
the class XMLReport method testSucceeded.
/**
* A test ends successfully.
* @param test the test executed successfully.
*/
public void testSucceeded(Test test) {
super.testSucceeded();
long runTime = this.m_endTime - this.m_startTime;
Xpp3Dom testCase = createTestElement(test, runTime);
m_results.add(testCase);
}
use of org.codehaus.plexus.util.xml.Xpp3Dom in project felix by apache.
the class SCRDescriptorMojo method getBundlePluginConfiguration.
private String getBundlePluginConfiguration(final String key) {
String value = null;
Plugin bundlePlugin = this.getBundlePlugin();
if (bundlePlugin != null) {
final Xpp3Dom config = (Xpp3Dom) bundlePlugin.getConfiguration();
if (config != null) {
final Xpp3Dom instructionsConfig = config.getChild(BUNDLE_PLUGIN_INSTRUCTIONS);
if (instructionsConfig != null) {
final Xpp3Dom keyConfig = instructionsConfig.getChild(key);
if (keyConfig != null) {
return keyConfig.getValue();
}
}
}
}
return value;
}
Aggregations