Package org.codehaus.plexus.util.xml

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


        {
            throw new MojoExecutionException( Messages.getString( "EclipsePlugin.erroropeningfile" ), ex ); //$NON-NLS-1$
        }

        // create a .component file and write out to it
        XMLWriter writer = new PrettyPrintXMLWriter( w, "UTF-8", null );

        writeModuleTypeComponent( writer, config.getPackaging(), config.getBuildOutputDirectory(),
                                  config.getSourceDirs(), config.getLocalRepository() );

        IOUtil.close( w );
View Full Code Here


        catch ( IOException ex )
        {
            throw new MojoExecutionException( Messages.getString( "EclipsePlugin.erroropeningfile" ), ex ); //$NON-NLS-1$
        }

        XMLWriter writer = new PrettyPrintXMLWriter( w, "UTF-8", null );

        writer.startElement( MYECLIPSE_METADATA_PROJECT );
        writer.addAttribute( MYECLIPSE_METADATA_PROJECT_TYPE, getMyEclipseProjectType( packaging ) );
        writer.addAttribute( MYECLIPSE_METADATA_PROJECT_NAME, config.getEclipseProjectName() );
        writer.addAttribute( MYECLIPSE_METADATA_PROJECT_ID, config.getEclipseProjectName() );

        if ( Constants.PROJECT_PACKAGING_WAR.equalsIgnoreCase( packaging ) )
        {
            // Find web application context root from maven-war-plugin configuration.
            // ArtifactId is used as the default value
            String warContextRoot =
                IdeUtils.getPluginSetting( config.getProject(), JeeUtils.ARTIFACT_MAVEN_WAR_PLUGIN, "warContextRoot",//$NON-NLS-1$
                                           "/" + config.getProject().getArtifactId() );

            writer.addAttribute( MYECLIPSE_METADATA_PROJECT_CONTEXT_ROOT, warContextRoot );

            writer.addAttribute( MYECLIPSE_METADATA_PROJECT_J2EE_SPEC, getJeeVersion() );
            // TODO : use maven final name
            writer.addAttribute( MYECLIPSE_METADATA_PROJECT_ARCHIVE, config.getEclipseProjectName() + ".war" );
        }

        if ( Constants.PROJECT_PACKAGING_EAR.equalsIgnoreCase( packaging ) )
        {
            // TODO : use maven final name
            writer.addAttribute( MYECLIPSE_METADATA_PROJECT_ARCHIVE, config.getEclipseProjectName() + ".ear" );
        }

        writer.startElement( MYECLIPSE_METADATA_PROJECT_ATTRIBUTES );
        if ( Constants.PROJECT_PACKAGING_WAR.equalsIgnoreCase( packaging ) )
        {
            writer.startElement( MYECLIPSE_METADATA_PROJECT_ATTRIBUTE );
            writer.addAttribute( "name", "webrootdir" );
            // TODO : retrieve this from project configuration
            writer.addAttribute( "value", "src/main/webapp" );
            writer.endElement();
        }
        // Close <attributes>
        writer.endElement();

        // Close <project-module>
        writer.endElement();

        IOUtil.close( w );
    }
View Full Code Here

        catch ( IOException ex )
        {
            throw new MojoExecutionException( Messages.getString( "EclipsePlugin.erroropeningfile" ), ex ); //$NON-NLS-1$
        }

        XMLWriter writer = new PrettyPrintXMLWriter( springFileWriter, "UTF-8", null );

        writer.startElement( MYECLIPSE_SPRING_BEANS_PROJECT_DESCRIPTION );
        // Configuration extension
        writer.startElement( MYECLIPSE_SPRING_CONFIG_EXTENSIONS );
        writer.startElement( MYECLIPSE_SPRING_CONFIG_EXTENSION );
        writer.writeText( "xml" );
        writer.endElement();
        writer.endElement();

        // Configuration files
        writer.startElement( MYECLIPSE_SPRING_CONFIGS );

        // maven's cwd stays at the top of hierarchical projects so we
        // do this with full path so it works as we descend through various modules (projects)
        File basedir = config.getEclipseProjectDirectory();
        Iterator onConfigFiles =
            getConfigurationFilesList( new File( basedir, (String) springConfig.get( "basedir" ) ),
                                       (String) springConfig.get( "file-pattern" ) ).iterator();

        while ( onConfigFiles.hasNext() )
        {
            String onConfigFileName = (String) onConfigFiles.next();
            File onConfigFile = new File( onConfigFileName );
            String relativeFileName = IdeUtils.toRelativeAndFixSeparator( basedir, onConfigFile, false );

            writer.startElement( MYECLIPSE_SPRING_CONFIG );
            writer.writeText( relativeFileName );
            writer.endElement();
        }
        writer.endElement();

        // Configuration sets
        writer.startElement( MYECLIPSE_SPRING_CONFIGSETS );
        writer.endElement();

        // Spring version
        writer.startElement( MYECLIPSE_SPRING_VERSION );
        writer.writeText( (String) springConfig.get( "version" ) );
        writer.endElement();

        writer.endElement();

        IOUtil.close( springFileWriter );
    }
View Full Code Here

        catch ( IOException ex )
        {
            throw new MojoExecutionException( Messages.getString( "EclipsePlugin.erroropeningfile" ), ex ); //$NON-NLS-1$
        }

        XMLWriter writer = new PrettyPrintXMLWriter( w, "UTF-8", null );

        writer.startElement( "launchConfiguration" );
        writer.addAttribute( "type", getLaunchConfigurationType() );

        writeAttribute( writer, "org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND", isLaunchInBackground() );

        writeAttribute( writer, "org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS",
                        StringUtils.join( getRunBuildKinds(), "," ) );

        // i think this one means if the ATTR_RUN_BUILD_KINDS is not default.
        writeAttribute( writer, "org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED", true );

        writeAttribute( writer, "org.eclipse.debug.core.appendEnvironmentVariables", isAppendEnvironmentVariables() );

        writeAttribute( writer, "org.eclipse.jdt.launching.PROJECT_ATTR", config.getEclipseProjectName() );

        writeAttribute( writer, "org.eclipse.jdt.launching.DEFAULT_CLASSPATH", true );

        writeAttribute( writer, "org.eclipse.ui.externaltools.ATTR_LOCATION", getBuilderLocation() );

        if ( getWorkingDirectory() != null )
        {
            writeAttribute( writer, "org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY", getWorkingDirectory() );
        }

        if ( getRefreshScope() != null )
        {
            writeAttribute( writer, "org.eclipse.debug.core.ATTR_REFRESH_SCOPE", getRefreshScope() );
        }

        writeAttribute( writer, "org.eclipse.debug.core.capture_output", isCaptureOutput() );

        String workingSet =
            "<?xml version='1.0'?>"
                + "<launchConfigurationWorkingSet editPageId='org.eclipse.ui.resourceWorkingSetPage'"
                + " factoryID='org.eclipse.ui.internal.WorkingSetFactory'" + " label='workingSet'"
                + " name='workingSet'>";

        for ( Iterator it = getMonitoredResources().iterator(); it.hasNext(); )
        {
            MonitoredResource monitoredResource = (MonitoredResource) it.next();

            workingSet += monitoredResource.print();
        }

        workingSet += "</launchConfigurationWorkingSet>";

        writeAttribute( writer, "org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE", "${working_set:" + workingSet + "}" );

        addAttributes( writer );

        writer.endElement();

        IOUtil.close( w );
    }
View Full Code Here

            }
            catch ( IOException ex )
            {
                throw new MojoExecutionException( Messages.getString( "EclipsePlugin.erroropeningfile" ), ex ); //$NON-NLS-1$
            }
            XMLWriter writer = new PrettyPrintXMLWriter( w, "UTF-8", null );
            Xpp3DomWriter.write( writer, classpath );
            IOUtil.close( w );
        }
    }
View Full Code Here

        }
        catch ( IOException ex )
        {
            throw new MojoExecutionException( Messages.getString( "EclipsePlugin.erroropeningfile" ), ex ); //$NON-NLS-1$
        }
        XMLWriter writer = new PrettyPrintXMLWriter( w, "UTF-8", null );
        Xpp3DomWriter.write( writer, xmlDomTree );
        IOUtil.close( w );
    }
View Full Code Here

        catch ( IOException ex )
        {
            throw new MojoExecutionException( Messages.getString( "EclipsePlugin.erroropeningfile" ), ex ); //$NON-NLS-1$
        }

        XMLWriter writer = new PrettyPrintXMLWriter( w, "UTF-8", null );

        writer.startElement( "projectDescription" ); //$NON-NLS-1$

        writer.startElement( ELT_NAME );
        writer.writeText( config.getEclipseProjectName() );
        writer.endElement();

        addComment( writer, config.getProject().getDescription() );

        writer.startElement( "projects" ); //$NON-NLS-1$

        IdeDependency[] dependencies = config.getDeps();
       
        // referenced projects should not be added for plugins
        if ( !config.isPde() )
        {
            List duplicates = new ArrayList();
            for ( int j = 0; j < dependencies.length; j++ )
            {
                IdeDependency dep = dependencies[j];
                // Avoid duplicates entries when same project is refered using multiple types
                // (ejb, test-jar ...)
                if ( dep.isReferencedProject() && !duplicates.contains( dep.getEclipseProjectName() ) )
                {
                    writer.startElement( "project" ); //$NON-NLS-1$
                    writer.writeText( dep.getEclipseProjectName() );
                    writer.endElement();
                    duplicates.add( dep.getEclipseProjectName() );
                }
            }
        }

        writer.endElement(); // projects

        writer.startElement( ELT_BUILD_SPEC );

        for ( Iterator it = buildCommands.iterator(); it.hasNext(); )
        {
            ( (BuildCommand) it.next() ).print( writer );
        }

        writer.endElement(); // buildSpec

        writer.startElement( ELT_NATURES );

        for ( Iterator it = projectnatures.iterator(); it.hasNext(); )
        {
            writer.startElement( ELT_NATURE );
            writer.writeText( (String) it.next() );
            writer.endElement(); // name
        }

        writer.endElement(); // natures

        boolean addLinks = !config.getProjectBaseDir().equals( config.getEclipseProjectDirectory() );

        if ( addLinks || ( config.isPde() && dependencies.length > 0 ) || linkedResources.size() > 0 )
        {
            writer.startElement( "linkedResources" ); //$NON-NLS-1$
            // preserve the symbolic links
            if ( linkedResources.size() > 0 )
            {
                for ( Iterator it = linkedResources.iterator(); it.hasNext(); )
                {
                    ( (LinkedResource) it.next() ).print( writer );
                }
            }

            if ( addLinks )
            {

                addFileLink( writer, config.getProjectBaseDir(), config.getEclipseProjectDirectory(),
                             config.getProject().getFile() );

                addSourceLinks( writer, config.getProjectBaseDir(), config.getEclipseProjectDirectory(),
                                config.getProject().getCompileSourceRoots() );
                addResourceLinks( writer, config.getProjectBaseDir(), config.getEclipseProjectDirectory(),
                                  config.getProject().getBuild().getResources() );

                addSourceLinks( writer, config.getProjectBaseDir(), config.getEclipseProjectDirectory(),
                                config.getProject().getTestCompileSourceRoots() );
                addResourceLinks( writer, config.getProjectBaseDir(), config.getEclipseProjectDirectory(),
                                  config.getProject().getBuild().getTestResources() );

            }

            if ( config.isPde() )
            {
                for ( int j = 0; j < dependencies.length; j++ )
                {
                    IdeDependency dep = dependencies[j];

                    if ( dep.isAddedToClasspath() && !dep.isProvided() && !dep.isReferencedProject()
                        && !dep.isTestDependency() && !dep.isOsgiBundle() )
                    {
                        String name = dep.getFile().getName();
                        addLink( writer, name, IdeUtils.fixSeparator( IdeUtils.getCanonicalPath( dep.getFile() ) ),
                                 LINK_TYPE_FILE );
                    }
                }
            }

            writer.endElement(); // linkedResources
        }

        writer.endElement(); // projectDescription

        IOUtil.close( w );
    }
View Full Code Here

            catch ( IOException ex )
            {
                throw new MojoExecutionException( Messages.getString( "EclipsePlugin.erroropeningfile" ), ex ); //$NON-NLS-1$
            }

            XMLWriter writer = new PrettyPrintXMLWriter( w, "UTF-8", null );
            writeModuleTypeFacetCore( writer );
            IOUtil.close( w );
        }
    }
View Full Code Here

        catch ( IOException ex )
        {
            throw new MojoExecutionException( Messages.getString( "EclipsePlugin.erroropeningfile" ), ex ); //$NON-NLS-1$
        }

        XMLWriter writer = new PrettyPrintXMLWriter( w, "UTF-8", null );
        writer.startElement( ELT_PROJECT_MODULES );
        writer.addAttribute( ATTR_MODULE_ID, "moduleCoreId" ); //$NON-NLS-1$

        writer.startElement( ELT_WB_MODULE );
        // we should use the configured eclipse project name.
        writer.addAttribute( ATTR_DEPLOY_NAME, this.config.getEclipseProjectName() );

        writer.startElement( ELT_MODULE_TYPE );
        writeModuleTypeAccordingToPackaging( config.getProject(), writer, config.getBuildOutputDirectory() );
        writer.endElement(); // module-type

        // source and resource paths.
        // deploy-path is "/" for utility and ejb projects, "/WEB-INF/classes" for webapps

        String target = "/"; //$NON-NLS-1$
        if ( Constants.PROJECT_PACKAGING_WAR.equals( config.getPackaging() ) ) //$NON-NLS-1$
        {
            String warSourceDirectory =
                IdeUtils.getPluginSetting( config.getProject(), JeeUtils.ARTIFACT_MAVEN_WAR_PLUGIN,
                                           "warSourceDirectory", //$NON-NLS-1$
                                           config.getProject().getBasedir() + "/src/main/webapp" ); //$NON-NLS-1$

            writer.startElement( ELT_WB_RESOURCE );
            writer.addAttribute( ATTR_DEPLOY_PATH, "/" ); //$NON-NLS-1$
            writer.addAttribute( ATTR_SOURCE_PATH, "/" //$NON-NLS-1$
                + IdeUtils.toRelativeAndFixSeparator( config.getEclipseProjectDirectory(),
                                                      new File( warSourceDirectory ), false ) );
            writer.endElement();

            writeWarOrEarResources( writer, config.getProject(), config.getLocalRepository() );

            target = "/WEB-INF/classes"; //$NON-NLS-1$
        }
        else if ( Constants.PROJECT_PACKAGING_EAR.equals( config.getPackaging() ) ) //$NON-NLS-1$
        {
            writer.startElement( ELT_WB_RESOURCE );
            writer.addAttribute( ATTR_DEPLOY_PATH, "/" ); //$NON-NLS-1$
            writer.addAttribute( ATTR_SOURCE_PATH, "/" ); //$NON-NLS-1$
            writer.endElement();

            writeWarOrEarResources( writer, config.getProject(), config.getLocalRepository() );
        }

        for ( int j = 0; j < config.getSourceDirs().length; j++ )
        {
            EclipseSourceDir dir = config.getSourceDirs()[j];
            // test src/resources are not added to wtpmodules
            if ( !dir.isTest() )
            {
                // <wb-resource deploy-path="/" source-path="/src/java" />
                writer.startElement( ELT_WB_RESOURCE );
                writer.addAttribute( ATTR_DEPLOY_PATH, target );
                writer.addAttribute( ATTR_SOURCE_PATH, dir.getPath() );
                writer.endElement();
            }
        }

        writer.endElement(); // wb-module
        writer.endElement(); // project-modules

        IOUtil.close( w );
    }
View Full Code Here

            catch ( IOException ex )
            {
                throw new MojoExecutionException( Messages.getString( "EclipsePlugin.erroropeningfile" ), ex ); //$NON-NLS-1$
            }

            XMLWriter writer = new PrettyPrintXMLWriter( w, "UTF-8", null );

            writer.startElement( MYECLIPSE_STRUTS_PROPERTIES );

            writer.startElement( MYECLIPSE_STRUTS_VERSION );
            writer.writeText( getStrutsVersion() );
            writer.endElement();

            writer.startElement( MYECLIPSE_STRUTS_BASE_PACKAGE );
            writer.writeText( getBasePackage() );
            writer.endElement();

            writer.startElement( MYECLIPSE_STRUTS_PATTERN );
            writer.writeText( getStrutsPattern() );
            writer.endElement();

            writer.startElement( MYECLIPSE_STRUTS_SERVLET_NAME );
            writer.writeText( getStrutsServletName() );
            writer.endElement();

            // Close <MyEclipseStrutsProperties>
            writer.endElement();

            IOUtil.close( w );
        }
    }
View Full Code Here

TOP

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

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.