Package org.codehaus.plexus.util.xml

Examples of org.codehaus.plexus.util.xml.Xpp3Dom


        String goalId = mojoDescriptor.getGoal();
        String groupId = pluginDescriptor.getGroupId();
        String artifactId = pluginDescriptor.getArtifactId();
        String executionId = mojoExecution.getExecutionId();

        Xpp3Dom dom = project.getGoalConfiguration( groupId, artifactId, executionId, goalId );
        Xpp3Dom reportDom = project.getReportConfiguration( groupId, artifactId, executionId );
        dom = Xpp3Dom.mergeXpp3Dom( dom, reportDom );
        if ( mojoExecution.getConfiguration() != null )
        {
            dom = Xpp3Dom.mergeXpp3Dom( dom, mojoExecution.getConfiguration() );
        }
View Full Code Here


        ArtifactResolutionException
    {
        MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
        PluginDescriptor descriptor = mojoDescriptor.getPluginDescriptor();

        Xpp3Dom dom = project.getReportConfiguration( descriptor.getGroupId(), descriptor.getArtifactId(),
                                                      mojoExecution.getExecutionId() );
        if ( mojoExecution.getConfiguration() != null )
        {
            dom = Xpp3Dom.mergeXpp3Dom( dom, mojoExecution.getConfiguration() );
        }
View Full Code Here

    }

    public void mapMetadata( ContinuumProjectBuildingResult result, File metadata, Project project, boolean updateDefinition )
        throws MavenOneMetadataHelperException
    {
        Xpp3Dom mavenProject;

        try
        {
            mavenProject = Xpp3DomBuilder.build( new FileReader( metadata ) );
        }
        catch ( XmlPullParserException e )
        {
            result.addError( ContinuumProjectBuildingResult.ERROR_XML_PARSE );

            log.info( "Error while reading maven POM (" + e.getMessage() + ").", e );

            return;
        }
        catch ( FileNotFoundException e )
        {
            result.addError( ContinuumProjectBuildingResult.ERROR_POM_NOT_FOUND );

            log.info( "Error while reading maven POM (" + e.getMessage() + ").", e );

            return;
        }
        catch ( IOException e )
        {
            result.addError( ContinuumProjectBuildingResult.ERROR_UNKNOWN );

            log.info( "Error while reading maven POM (" + e.getMessage() + ").", e );

            return;
        }

        // ----------------------------------------------------------------------
        // We cannot deal with projects that use the <extend/> element because
        // we don't have the whole source tree and we might be missing elements
        // that are present in the parent.
        // ----------------------------------------------------------------------

        String extend = getValue( mavenProject, "extend", null );

        if ( extend != null )
        {
            result.addError( ContinuumProjectBuildingResult.ERROR_EXTEND );

            log.info( "Cannot use a POM with an 'extend' element." );

            return;
        }

        // ----------------------------------------------------------------------
        // Artifact and group id
        // ----------------------------------------------------------------------

        String groupId;

        String artifactId;

        String id = getValue( mavenProject, "id", null );

        if ( !StringUtils.isEmpty( id ) )
        {
            groupId = id;

            artifactId = id;
        }
        else
        {
            groupId = getValue( mavenProject, "groupId", project.getGroupId() );

            if ( StringUtils.isEmpty( groupId ) )
            {
                result.addError( ContinuumProjectBuildingResult.ERROR_MISSING_GROUPID );

                log.info( "Missing 'groupId' element in the POM." );

                // Do not throw an exception or return here, gather up as many results as possible first.
            }

            artifactId = getValue( mavenProject, "artifactId", project.getArtifactId() );

            if ( StringUtils.isEmpty( artifactId ) )
            {
                result.addError( ContinuumProjectBuildingResult.ERROR_MISSING_ARTIFACTID );

                log.info( "Missing 'artifactId' element in the POM." );

                // Do not throw an exception or return here, gather up as many results as possible first.
            }
        }

        // ----------------------------------------------------------------------
        // version
        // ----------------------------------------------------------------------

        String version = getValue( mavenProject, "currentVersion", project.getVersion() );

        if ( StringUtils.isEmpty( project.getVersion() ) && StringUtils.isEmpty( version ) )
        {
            result.addError( ContinuumProjectBuildingResult.ERROR_MISSING_VERSION );

            // Do not throw an exception or return here, gather up as many results as possible first.
        }

        // ----------------------------------------------------------------------
        // name
        // ----------------------------------------------------------------------

        String name = getValue( mavenProject, "name", project.getName() );

        if ( StringUtils.isEmpty( project.getName() ) && StringUtils.isEmpty( name ) )
        {
            result.addError( ContinuumProjectBuildingResult.ERROR_MISSING_NAME );

            // Do not throw an exception or return here, gather up as many results as possible first.
        }

        // ----------------------------------------------------------------------
        // description
        // ----------------------------------------------------------------------

        String shortDescription = getValue( mavenProject, "shortDescription", project.getDescription() );

        String description = getValue( mavenProject, "description", project.getDescription() );

        // ----------------------------------------------------------------------
        // scm
        // ----------------------------------------------------------------------

        Xpp3Dom repository = mavenProject.getChild( "repository" );

        String scmConnection = null;

        if ( repository == null )
        {
            if ( !StringUtils.isEmpty( project.getScmUrl() ) )
            {
                scmConnection = project.getScmUrl();
            }
            else
            {
                result.addError( ContinuumProjectBuildingResult.ERROR_MISSING_REPOSITORY );

                // Do not throw an exception or return here, gather up as many results as possible first.
            }
        }
        else
        {
            scmConnection = getValue( repository, "developerConnection", project.getScmUrl() );

            scmConnection = getValue( repository, "connection", scmConnection );

            if ( StringUtils.isEmpty( scmConnection ) )
            {
                result.addError( ContinuumProjectBuildingResult.ERROR_MISSING_SCM, name );

                // Do not throw an exception or return here, gather up as many results as possible first.
            }
        }

        // ----------------------------------------------------------------------
        // Developers
        // ----------------------------------------------------------------------

        Xpp3Dom developers = mavenProject.getChild( "developers" );

        if ( developers != null )
        {
            Xpp3Dom[] developersList = developers.getChildren();

            List<ProjectDeveloper> cds = new ArrayList<ProjectDeveloper>();

            for ( Xpp3Dom developer : developersList )
            {
                ProjectDeveloper cd = new ProjectDeveloper();

                cd.setScmId( getValue( developer, "id", null ) );

                cd.setName( getValue( developer, "name", null ) );

                cd.setEmail( getValue( developer, "email", null ) );

                cds.add( cd );
            }

            project.setDevelopers( cds );
        }

        // ----------------------------------------------------------------------
        // Dependencies
        // ----------------------------------------------------------------------

        Xpp3Dom dependencies = mavenProject.getChild( "dependencies" );

        if ( dependencies != null )
        {
            Xpp3Dom[] dependenciesList = dependencies.getChildren();

            List<ProjectDependency> deps = new ArrayList<ProjectDependency>();

            for ( Xpp3Dom dependency : dependenciesList )
            {
                ProjectDependency cd = new ProjectDependency();

                if ( getValue( dependency, "groupId", null ) != null )
                {
                    cd.setGroupId( getValue( dependency, "groupId", null ) );

                    cd.setArtifactId( getValue( dependency, "artifactId", null ) );
                }
                else
                {
                    cd.setGroupId( getValue( dependency, "id", null ) );

                    cd.setArtifactId( getValue( dependency, "id", null ) );
                }

                cd.setVersion( getValue( dependency, "version", null ) );

                deps.add( cd );
            }

            project.setDependencies( deps );
        }

        // ----------------------------------------------------------------------
        // notifiers
        // ----------------------------------------------------------------------

        Xpp3Dom build = mavenProject.getChild( "build" );

        List<ProjectNotifier> notifiers = new ArrayList<ProjectNotifier>();

        // Add project Notifier
        if ( build != null )
View Full Code Here

    //
    // ----------------------------------------------------------------------

    private String getValue( Xpp3Dom dom, String key, String defaultValue )
    {
        Xpp3Dom child = dom.getChild( key );

        if ( child == null )
        {
            return defaultValue;
        }

        return child.getValue();
    }
View Full Code Here

                {
                    continue;
                }

                Object value = pluginsAsMap.get( key );
                Xpp3Dom pluginConf = null;

                backupJdk = "Default version for maven-compiler-plugin";
                if ( value instanceof Plugin )
                {
                    Plugin plugin = (Plugin) value;
                    backupJdk = "Default target for maven-compiler-plugin version " + plugin.getVersion();
                    pluginConf = (Xpp3Dom) plugin.getConfiguration();
                }

                if ( value instanceof ReportPlugin )
                {
                    ReportPlugin reportPlugin = (ReportPlugin) value;
                    backupJdk = "Default target for maven-compiler-plugin version " + reportPlugin.getVersion();
                    pluginConf = (Xpp3Dom) reportPlugin.getConfiguration();
                }

                if ( pluginConf == null )
                {
                    continue;
                }

                if ( pluginConf.getChild( "target" ) == null )
                {
                    continue;
                }

                jdk = pluginConf.getChild( "target" ).getValue();
            }

            if ( jdk == null )
            {
                return backupJdk;
View Full Code Here

     */
    private static List<Map<String, String>> pluginConfigurations(PluginExecution execution) {
        List<Map<String, String>> configurations = new ArrayList<Map<String,String>>();
        Map<String, String> topConfiguration = new HashMap<String, String>();
       
        Xpp3Dom dom = (Xpp3Dom)execution.getConfiguration();
        for (Xpp3Dom element: dom.getChildren()) {
            if (element.getChildCount() != 0) {
                // Handle nested configuration element, create a child configuration
                // for each
                for (Xpp3Dom childConfigurationElement: element.getChildren()) {
                    Map<String, String> childConfiguration = new HashMap<String, String>();
View Full Code Here

                    Plugin plugin = (Plugin) iterator.next();
                    if ("org.apache.servicemix.tooling".equals(plugin
                            .getGroupId())
                            && "jbi-maven-plugin"
                                    .equals(plugin.getArtifactId())) {
                        Xpp3Dom o = (Xpp3Dom) plugin.getConfiguration();
                        if (o != null
                                && o.getChild("serviceUnitAnalyzer") != null) {
                            String clazzName = o
                                    .getChild("serviceUnitAnalyzer").getValue();
                            return clazzName;
                        }
                    }
                }
View Full Code Here

    //

    private void testSetCompleted() throws ReporterException {
        long runTime = System.currentTimeMillis() - this.startTime;

        Xpp3Dom testSuite = createTestElement("testsuite", testName, runTime);

        showProperties(testSuite);

        testSuite.setAttribute("tests", "1");
        testSuite.setAttribute("errors", String.valueOf(numErrors));
        testSuite.setAttribute("skipped", "0");
        testSuite.setAttribute("failures", "0");

        for (Iterator i = results.iterator(); i.hasNext();) {
            Xpp3Dom testcase = (Xpp3Dom) i.next();
            testSuite.addChild(testcase);
        }

        PrintWriter writer = null;
View Full Code Here

            IOUtil.close(writer);
        }
    }

    private Xpp3Dom createTestElement(String element, String testName, long runTime) {
        Xpp3Dom testCase = new Xpp3Dom(element);
        testCase.setAttribute("name", testName);
        testCase.setAttribute("time", elapsedTimeAsString(runTime));

        return testCase;
    }
View Full Code Here

        return testCase;
    }

    private Xpp3Dom createElement(Xpp3Dom element, String testName) {
        Xpp3Dom component = new Xpp3Dom(testName);
        element.addChild(component);

        return component;
    }
View Full Code Here

TOP

Related Classes of org.codehaus.plexus.util.xml.Xpp3Dom

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.