use of org.codehaus.plexus.util.xml.Xpp3Dom in project sling by apache.
the class MavenProjectUtils method getModelDirectoryCandidateLocations.
/**
* Returns a set of candidate locations for the project's model directory
*
* <p>The heuristics are based on the logic from <tt>org.apache.sling.maven.slingstart.ModelPreprocessor</tt>.
* The returned values may or may not exist on the filesystem, it is up to the client to check that.
* The values are ordered from the most likely to the least likely, so clients should iterate
* the returned candidates in order and pick the first one that exists.</p>
*
* @param mavenProject the project, must not be null
* @return an ordered set of candidates, never empty
*/
public static Set<String> getModelDirectoryCandidateLocations(MavenProject mavenProject) {
List<String> candidates = new ArrayList<>();
candidates.add("src/main/provisioning");
candidates.add("src/test/provisioning");
Plugin slingstartPlugin = mavenProject.getPlugin("org.apache.sling:slingstart-maven-plugin");
if (slingstartPlugin != null && slingstartPlugin.getConfiguration() instanceof Xpp3Dom) {
Xpp3Dom config = (Xpp3Dom) slingstartPlugin.getConfiguration();
Xpp3Dom modelDir = config.getChild("modelDirectory");
if (modelDir != null) {
candidates.add(0, modelDir.getValue());
}
}
return new LinkedHashSet<>(candidates);
}
use of org.codehaus.plexus.util.xml.Xpp3Dom in project kie-wb-common by kiegroup.
the class DefaultPomEditor method disableMavenCompilerAlreadyPresent.
protected void disableMavenCompilerAlreadyPresent(Plugin plugin) {
Xpp3Dom skipMain = new Xpp3Dom(MavenConfig.MAVEN_SKIP_MAIN);
skipMain.setValue(TRUE);
Xpp3Dom skip = new Xpp3Dom(MavenConfig.MAVEN_SKIP);
skip.setValue(TRUE);
Xpp3Dom configuration = new Xpp3Dom(MavenConfig.MAVEN_PLUGIN_CONFIGURATION);
configuration.addChild(skipMain);
configuration.addChild(skip);
plugin.setConfiguration(configuration);
PluginExecution exec = new PluginExecution();
exec.setId(MavenConfig.MAVEN_DEFAULT_COMPILE);
exec.setPhase(MavenConfig.MAVEN_PHASE_NONE);
List<PluginExecution> executions = new ArrayList<>();
executions.add(exec);
plugin.setExecutions(executions);
}
use of org.codehaus.plexus.util.xml.Xpp3Dom in project kie-wb-common by kiegroup.
the class DefaultPomEditor method getNewCompilerPlugin.
protected Plugin getNewCompilerPlugin() {
Plugin newCompilerPlugin = new Plugin();
newCompilerPlugin.setGroupId(conf.get(ConfigurationKey.ALTERNATIVE_COMPILER_PLUGINS));
newCompilerPlugin.setArtifactId(conf.get(ConfigurationKey.ALTERNATIVE_COMPILER_PLUGIN));
newCompilerPlugin.setVersion(conf.get(ConfigurationKey.ALTERNATIVE_COMPILER_PLUGIN_VERSION));
PluginExecution execution = new PluginExecution();
execution.setId(MavenCLIArgs.COMPILE);
execution.setGoals(Arrays.asList(MavenCLIArgs.COMPILE));
execution.setPhase(MavenCLIArgs.COMPILE);
Xpp3Dom compilerId = new Xpp3Dom(MavenConfig.MAVEN_COMPILER_ID);
compilerId.setValue(compiler.name().toLowerCase());
Xpp3Dom configuration = new Xpp3Dom(MavenConfig.MAVEN_PLUGIN_CONFIGURATION);
configuration.addChild(compilerId);
execution.setConfiguration(configuration);
newCompilerPlugin.setExecutions(Arrays.asList(execution));
return newCompilerPlugin;
}
use of org.codehaus.plexus.util.xml.Xpp3Dom in project felix by apache.
the class MavenJDOMWriter method replaceXpp3DOM.
// -- void iterateResource(Counter, Element, java.util.Collection, java.lang.String, java.lang.String)
/**
* Method replaceXpp3DOM
*
* @param parent
* @param counter
* @param parentDom
*/
protected void replaceXpp3DOM(Element parent, Xpp3Dom parentDom, Counter counter) {
if (parentDom.getChildCount() > 0) {
Xpp3Dom[] childs = parentDom.getChildren();
Collection domChilds = new ArrayList();
Collections.addAll(domChilds, childs);
// int domIndex = 0;
for (Object o : parent.getChildren()) {
Element elem = (Element) o;
Iterator it2 = domChilds.iterator();
Xpp3Dom corrDom = null;
while (it2.hasNext()) {
Xpp3Dom dm = (Xpp3Dom) it2.next();
if (dm.getName().equals(elem.getName())) {
corrDom = dm;
break;
}
}
if (corrDom != null) {
domChilds.remove(corrDom);
replaceXpp3DOM(elem, corrDom, new Counter(counter.getDepth() + 1));
counter.increaseCount();
} else {
parent.removeContent(elem);
}
}
for (Object domChild : domChilds) {
Xpp3Dom dm = (Xpp3Dom) domChild;
Element elem = factory.element(dm.getName(), parent.getNamespace());
insertAtPreferredLocation(parent, elem, counter);
counter.increaseCount();
replaceXpp3DOM(elem, dm, new Counter(counter.getDepth() + 1));
}
} else if (parentDom.getValue() != null) {
parent.setText(parentDom.getValue());
}
}
use of org.codehaus.plexus.util.xml.Xpp3Dom in project felix by apache.
the class XMLReport method createTestSuiteElement.
/**
* Creates a XML test suite element.
* @param test the test
* @param runTime the elapsed time to execute the test suite.
* @return the XML element describing the given test suite.
*/
private Xpp3Dom createTestSuiteElement(Test test, long runTime) {
Xpp3Dom testCase = new Xpp3Dom("testsuite");
testCase.setAttribute("name", getReportName(test));
testCase.setAttribute("time", Long.toString(runTime));
return testCase;
}
Aggregations