Search in sources :

Example 76 with Xpp3Dom

use of org.codehaus.plexus.util.xml.Xpp3Dom in project jetty.project by eclipse.

the class WarPluginInfo method getDependentMavenWarIncludes.

/**
     * Get value of dependentWarIncludes for maven-war-plugin
     * @return the list of dependent war includes
     */
public List<String> getDependentMavenWarIncludes() {
    if (_dependentMavenWarIncludes == null) {
        getPlugin();
        if (_plugin == null)
            return null;
        Xpp3Dom node = (Xpp3Dom) _plugin.getConfiguration();
        if (node == null)
            return null;
        node = node.getChild("dependentWarIncludes");
        if (node == null)
            return null;
        String val = node.getValue();
        _dependentMavenWarIncludes = StringUtil.csvSplit(null, val, 0, val.length());
    }
    return _dependentMavenWarIncludes;
}
Also used : Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom)

Example 77 with Xpp3Dom

use of org.codehaus.plexus.util.xml.Xpp3Dom in project jetty.project by eclipse.

the class WarPluginInfo method getDependentMavenWarExcludes.

/**
     * Get value of dependentWarExcludes for maven-war-plugin
     * @return the list of dependent war excludes
     */
public List<String> getDependentMavenWarExcludes() {
    if (_dependentMavenWarExcludes == null) {
        getPlugin();
        if (_plugin == null)
            return null;
        Xpp3Dom node = (Xpp3Dom) _plugin.getConfiguration();
        if (node == null)
            return null;
        node = node.getChild("dependentWarExcludes");
        if (node == null)
            return null;
        String val = node.getValue();
        _dependentMavenWarExcludes = StringUtil.csvSplit(null, val, 0, val.length());
    }
    return _dependentMavenWarExcludes;
}
Also used : Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom)

Example 78 with Xpp3Dom

use of org.codehaus.plexus.util.xml.Xpp3Dom in project intellij-community by JetBrains.

the class MavenModelConverter method xppToElement.

private static Element xppToElement(Xpp3Dom xpp) throws RemoteException {
    Element result;
    try {
        result = new Element(xpp.getName());
    } catch (IllegalNameException e) {
        Maven3ServerGlobals.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;
}
Also used : Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) Element(org.jdom.Element) IllegalNameException(org.jdom.IllegalNameException)

Example 79 with Xpp3Dom

use of org.codehaus.plexus.util.xml.Xpp3Dom in project bnd by bndtools.

the class BndMavenPlugin method loadProjectProperties.

private File loadProjectProperties(Builder builder, MavenProject project) throws Exception {
    // Load parent project properties first
    MavenProject parentProject = project.getParent();
    if (parentProject != null) {
        loadProjectProperties(builder, parentProject);
    }
    // Merge in current project properties
    Xpp3Dom configuration = project.getGoalConfiguration("biz.aQute.bnd", "bnd-maven-plugin", mojoExecution.getExecutionId(), mojoExecution.getGoal());
    File baseDir = project.getBasedir();
    if (baseDir != null) {
        // file system based pom
        File pomFile = project.getFile();
        builder.updateModified(pomFile.lastModified(), "POM: " + pomFile);
        // check for bnd file
        String bndFileName = Project.BNDFILE;
        if (configuration != null) {
            Xpp3Dom bndfileElement = configuration.getChild("bndfile");
            if (bndfileElement != null) {
                bndFileName = bndfileElement.getValue();
            }
        }
        File bndFile = IO.getFile(baseDir, bndFileName);
        if (bndFile.isFile()) {
            logger.debug("loading bnd properties from file: {}", bndFile);
            // we use setProperties to handle -include
            builder.setProperties(bndFile.getParentFile(), builder.loadProperties(bndFile));
            return bndFile;
        }
    // no bnd file found, so we fall through
    }
    // check for bnd-in-pom configuration
    if (configuration != null) {
        Xpp3Dom bndElement = configuration.getChild("bnd");
        if (bndElement != null) {
            logger.debug("loading bnd properties from bnd element in pom: {}", project);
            UTF8Properties properties = new UTF8Properties();
            properties.load(bndElement.getValue(), project.getFile(), builder);
            if (baseDir != null) {
                String here = baseDir.toURI().getPath();
                here = Matcher.quoteReplacement(here.substring(0, here.length() - 1));
                properties = properties.replaceAll("\\$\\{\\.\\}", here);
            }
            // we use setProperties to handle -include
            builder.setProperties(baseDir, properties);
        }
    }
    return project.getFile();
}
Also used : Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) MavenProject(org.apache.maven.project.MavenProject) IO.getFile(aQute.lib.io.IO.getFile) ZipFile(java.util.zip.ZipFile) File(java.io.File) UTF8Properties(aQute.lib.utf8properties.UTF8Properties)

Example 80 with Xpp3Dom

use of org.codehaus.plexus.util.xml.Xpp3Dom in project sling by apache.

the class MavenBundlePluginProjectConfigurator method isSupportingM2eIncrementalBuild.

@Override
protected boolean isSupportingM2eIncrementalBuild(MavenProject mavenProject, Logger logger) {
    Plugin bundlePlugin = mavenProject.getPlugin(MAVEN_BUNDLE_PLUGIN_KEY);
    if (bundlePlugin == null) {
        logger.warn("maven-bundle-plugin not configured!");
        return false;
    } else {
        // check if m2elipse-tycho is already installed (which supports incremental builds for "bundle" packagings
        if (LifecycleMappingFactory.createProjectConfigurator(M2E_TYCHO_EXTENSION_PROJECT_CONFIGURATOR_ID) != null) {
            logger.trace("Project configurator with id '" + M2E_TYCHO_EXTENSION_PROJECT_CONFIGURATOR_ID + "' found -> m2e-tycho installed.");
            return true;
        }
        String version = bundlePlugin.getVersion();
        if (version == null) {
            logger.warn("Could not retrieve used version of maven-bundle-plugin!");
            return false;
        }
        ComparableVersion comparableVersion = new ComparableVersion(version);
        // with https://issues.apache.org/jira/browse/FELIX-4009 m2e support for incremental builds was added to maven-bundle-plugin in version 3.2.0
        if (comparableVersion.compareTo(new ComparableVersion("3.2.0")) >= 0) {
            // therefore check configuration
            for (PluginExecution pluginExecution : bundlePlugin.getExecutions()) {
                if (!pluginExecution.getGoals().contains("manifest")) {
                    continue;
                }
                Xpp3Dom configuration = (Xpp3Dom) pluginExecution.getConfiguration();
                Xpp3Dom supportIncrementalBuildConfiguration = configuration.getChild("supportIncrementalBuild");
                // https://issues.apache.org/jira/browse/FELIX-3324
                Xpp3Dom exportScrConfiguration = configuration.getChild("exportScr");
                if (supportIncrementalBuildConfiguration == null || !Boolean.parseBoolean(supportIncrementalBuildConfiguration.getValue())) {
                    logger.warn("Although using maven-bundle-plugin in a version >= 3.2.0, the incremental build support was not enabled.");
                } else if (exportScrConfiguration == null || !Boolean.parseBoolean(exportScrConfiguration.getValue())) {
                    logger.warn("Although using maven-bundle-plugin in a version >= 3.2.0 with incremental build support enabled, component descriptors are not exported (exportScr=false) .");
                } else {
                    logger.trace("Using maven-bundle-plugin in a version >= 3.2.0 with the incremental build support correctly enabled.");
                    return true;
                }
            }
        } else {
            logger.warn("maven-bundle-plugin in a version < 3.2.0 does not natively support incremental builds.");
        }
    }
    return false;
}
Also used : PluginExecution(org.apache.maven.model.PluginExecution) Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) ComparableVersion(org.apache.maven.artifact.versioning.ComparableVersion) Plugin(org.apache.maven.model.Plugin)

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