Search in sources :

Example 81 with Xpp3Dom

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);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) ArrayList(java.util.ArrayList) Plugin(org.apache.maven.model.Plugin)

Example 82 with Xpp3Dom

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);
}
Also used : PluginExecution(org.apache.maven.model.PluginExecution) Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) ArrayList(java.util.ArrayList)

Example 83 with Xpp3Dom

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;
}
Also used : PluginExecution(org.apache.maven.model.PluginExecution) Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) Plugin(org.apache.maven.model.Plugin)

Example 84 with Xpp3Dom

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());
    }
}
Also used : Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) Element(org.jdom.Element) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) Collection(java.util.Collection)

Example 85 with Xpp3Dom

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;
}
Also used : Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom)

Aggregations

Xpp3Dom (org.codehaus.plexus.util.xml.Xpp3Dom)156 Plugin (org.apache.maven.model.Plugin)39 File (java.io.File)26 ArrayList (java.util.ArrayList)18 PluginExecution (org.apache.maven.model.PluginExecution)18 IOException (java.io.IOException)13 HashMap (java.util.HashMap)11 Test (org.junit.Test)11 MavenSession (org.apache.maven.execution.MavenSession)10 MavenProject (org.apache.maven.project.MavenProject)10 Model (org.apache.maven.model.Model)9 Reader (java.io.Reader)8 Build (org.apache.maven.model.Build)8 TargetPlatformConfiguration (org.eclipse.tycho.core.TargetPlatformConfiguration)8 BuildFailureException (org.eclipse.tycho.core.shared.BuildFailureException)8 MojoExecution (org.apache.maven.plugin.MojoExecution)7 XmlPullParserException (org.codehaus.plexus.util.xml.pull.XmlPullParserException)7 Map (java.util.Map)6 Dependency (org.apache.maven.model.Dependency)6 StringReader (java.io.StringReader)5