Package org.codehaus.plexus.util.xml

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


    } catch (IOException ex) {
      throw new JbiPluginException("Exception while opening file["
          + descriptor.getAbsolutePath() + "]", ex);
    }

    XMLWriter writer = new PrettyPrintXMLWriter(w, encoding, null);
    writer.startElement("jbi");
    writer.addAttribute("xmlns", "http://java.sun.com/xml/ns/jbi");
    writer.addAttribute("version", "1.0");

    writer.startElement("shared-library");
    writer.addAttribute("class-loader-delegation", classLoaderDelegation);
    writer.addAttribute("version", version);

    writer.startElement("identification");
    writer.startElement("name");
    writer.writeText(name);
    writer.endElement();
    writer.startElement("description");
    writer.writeText(description);
    writer.endElement();
    writer.endElement();

    writer.startElement("shared-library-class-path");
    for (Iterator it = uris.iterator(); it.hasNext();) {
      DependencyInformation dependency = (DependencyInformation) it.next();
      writer.startElement("path-element");
      writer.writeText(dependency.getFilename());
      writer.endElement();     
    }
    writer.endElement();

    writer.endElement();
    writer.endElement();

    close(w);
  }
View Full Code Here


    } catch (IOException ex) {
      throw new JbiPluginException("Exception while opening file["
          + descriptor.getAbsolutePath() + "]", ex);
    }

    XMLWriter writer = new PrettyPrintXMLWriter(w, encoding, null);
    writer.startElement("jbi");
    writer.addAttribute("xmlns", "http://java.sun.com/xml/ns/jbi");
    writer.addAttribute("version", "1.0");

    writer.startElement("service-assembly");

    writer.startElement("identification");
    writer.startElement("name");
    writer.writeText(name);
    writer.endElement();
    writer.startElement("description");
    writer.writeText(description);
    writer.endElement();
    writer.endElement();

    for (Iterator it = uris.iterator(); it.hasNext();) {
      DependencyInformation serviceUnitInfo = (DependencyInformation) it
          .next();
      writeServiceUnit(writer, serviceUnitInfo);

    }

    writer.endElement();
    writer.endElement();

    close(w);
  }
View Full Code Here

    } catch (IOException ex) {
      throw new JbiPluginException("Exception while opening file["
          + descriptor.getAbsolutePath() + "]", ex);
    }

    XMLWriter writer = new PrettyPrintXMLWriter(w, encoding, null);   
    writer.startElement("jbi");
    writer.addAttribute("xmlns", "http://java.sun.com/xml/ns/jbi");
    writer.addAttribute("version", "1.0");

    writer.startElement("component");
    writer.addAttribute("type", type);
        writer.addAttribute("component-class-loader-delegation", componentClassLoaderDelegation);
        writer.addAttribute("bootstrap-class-loader-delegation", bootstrapClassLoaderDelegation);

    writer.startElement("identification");
    writer.startElement("name");
    writer.writeText(name);
    writer.endElement();
    writer.startElement("description");
    writer.writeText(description);
    writer.endElement();
    writer.endElement();

    writer.startElement("component-class-name");
    writer.writeText(component);
    writer.endElement();
    writer.startElement("component-class-path");
    for (Iterator it = uris.iterator(); it.hasNext();) {
      DependencyInformation info = (DependencyInformation) it.next();
      if ("jar".equals(info.getType())) {
        writer.startElement("path-element");
        writer.writeText(info.getFilename());
        writer.endElement();
      }
    }
    writer.endElement();

    writer.startElement("bootstrap-class-name");
    writer.writeText(bootstrap);
    writer.endElement();
    writer.startElement("bootstrap-class-path");
    for (Iterator it = uris.iterator(); it.hasNext();) {
      DependencyInformation info = (DependencyInformation) it.next();
      if ("jar".equals(info.getType())) {
        writer.startElement("path-element");
        writer.writeText(info.getFilename());
        writer.endElement();
      }
    }
    writer.endElement();

    for (Iterator it = uris.iterator(); it.hasNext();) {
      DependencyInformation info = (DependencyInformation) it.next();
      if ("jbi-shared-library".equals(info.getType())) {
        writer.startElement("shared-library");
        writer.addAttribute("version", info.getVersion());
        writer.writeText(info.getName());
        writer.endElement();
      }
    }

    writer.endElement();

    writer.endElement();

    close(w);
  }
View Full Code Here

        if ( !artifacts.isEmpty() )
        {
            getLog().info( "Add the following to your pom to correct the missing dependencies: " );

            StringWriter out = new StringWriter();
            PrettyPrintXMLWriter writer = new PrettyPrintXMLWriter( out );

            for ( Artifact artifact : artifacts )
            {
                // called because artifact will set the version to -SNAPSHOT only if I do this. MNG-2961
                artifact.isSnapshot();

                writer.startElement( "dependency" );
                writer.startElement( "groupId" );
                writer.writeText( artifact.getGroupId() );
                writer.endElement();
                writer.startElement( "artifactId" );
                writer.writeText( artifact.getArtifactId() );
                writer.endElement();
                writer.startElement( "version" );
                writer.writeText( artifact.getBaseVersion() );
                if ( !StringUtils.isBlank( artifact.getClassifier() ) )
                {
                    writer.startElement( "classifier" );
                    writer.writeText( artifact.getClassifier() );
                    writer.endElement();
                }
                writer.endElement();

                if ( !Artifact.SCOPE_COMPILE.equals( artifact.getScope() ) )
                {
                    writer.startElement( "scope" );
                    writer.writeText( artifact.getScope() );
                    writer.endElement();
                }
                writer.endElement();
            }

            getLog().info( "\n" + out.getBuffer() );
        }
    }
View Full Code Here

        }
        catch ( IOException ex )
        {
            throw new MojoExecutionException( "Rad6Plugin.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( ELT_CLASSPATH );

        String defaultOutput =
            IdeUtils.toRelativeAndFixSeparator( config.getProjectBaseDir(), config.getBuildOutputDirectory(), false );

        // ----------------------------------------------------------------------
        // Source roots and resources
        // ----------------------------------------------------------------------

        // List<EclipseSourceDir>
        List specialSources = new ArrayList();

        // Map<String,List<EclipseSourceDir>>
        Map byOutputDir = new HashMap();

        for ( int j = 0; j < config.getSourceDirs().length; j++ )
        {
            EclipseSourceDir dir = config.getSourceDirs()[j];

            // List<EclipseSourceDir>
            List byOutputDirs = (List) byOutputDir.get( dir.getOutput() );
            if ( byOutputDirs == null )
            {
                // ArrayList<EclipseSourceDir>
                byOutputDir.put( dir.getOutput() == null ? defaultOutput : dir.getOutput(), byOutputDirs =
                    new ArrayList() );
            }
            byOutputDirs.add( dir );
        }

        for ( int j = 0; j < config.getSourceDirs().length; j++ )
        {
            EclipseSourceDir dir = config.getSourceDirs()[j];

            log.debug( "Processing classpath for: " + dir.toString() + "; default output=" + defaultOutput );

            boolean isSpecial = false;

            // handle resource with nested output folders
            if ( dir.isResource() )
            {
                // Check if the output is a subdirectory of the default output,
                // and if the default output has any sources that copy there.

                if ( dir.getOutput() != null // resource output dir is set
                    && !dir.getOutput().equals( defaultOutput ) // output dir is not default target/classes
                    && dir.getOutput().startsWith( defaultOutput ) // ... but is nested
                    && byOutputDir.get( defaultOutput ) != null // ???
                    && !( (List) byOutputDir.get( defaultOutput ) ).isEmpty() // ???
                )
                {
                    // do not specify as source since the output will be nested. Instead, mark
                    // it as a todo, and handle it with a custom build.xml file later.

                    log.debug( "Marking as special to prevent output folder nesting: " + dir.getPath() + " (output="
                        + dir.getOutput() + ")" );

                    isSpecial = true;
                    specialSources.add( dir );
                }
            }

            writer.startElement( ELT_CLASSPATHENTRY );

            writer.addAttribute( ATTR_KIND, "src" ); //$NON-NLS-1$
            writer.addAttribute( ATTR_PATH, dir.getPath() );

            if ( !isSpecial && dir.getOutput() != null && !defaultOutput.equals( dir.getOutput() ) )
            {
                writer.addAttribute( ATTR_OUTPUT, dir.getOutput() );
            }

            String includes = dir.getIncludeAsString();
            if ( StringUtils.isNotEmpty( includes ) )
            {
                writer.addAttribute( ATTR_INCLUDING, includes );
            }

            String excludes = dir.getExcludeAsString();
            if ( StringUtils.isNotEmpty( excludes ) )
            {
                writer.addAttribute( ATTR_EXCLUDING, excludes );
            }

            writer.endElement();

        }

        // handle the special sources.
        if ( !specialSources.isEmpty() )
        {
            log.info( "Creating maven-eclipse.xml Ant file to handle resources" );

            try
            {
                Writer buildXmlWriter =
                    new OutputStreamWriter( new FileOutputStream( new File( config.getEclipseProjectDirectory(),
                                                                            "maven-eclipse.xml" ) ), "UTF-8" );
                PrettyPrintXMLWriter buildXmlPrinter = new PrettyPrintXMLWriter( buildXmlWriter );

                buildXmlPrinter.startElement( "project" );
                buildXmlPrinter.addAttribute( "default", "copy-resources" );

                buildXmlPrinter.startElement( "target" );
                buildXmlPrinter.addAttribute( NAME, "init" );
                // initialize filtering tokens here
                buildXmlPrinter.endElement();

                buildXmlPrinter.startElement( "target" );
                buildXmlPrinter.addAttribute( NAME, "copy-resources" );
                buildXmlPrinter.addAttribute( "depends", "init" );

                for ( Iterator it = specialSources.iterator(); it.hasNext(); )
                {
                    // TODO: merge source dirs on output path+filtering to reduce
                    // <copy> tags for speed.
                    EclipseSourceDir dir = (EclipseSourceDir) it.next();
                    buildXmlPrinter.startElement( "copy" );
                    buildXmlPrinter.addAttribute( "todir", dir.getOutput() );
                    buildXmlPrinter.addAttribute( "filtering", "" + dir.isFiltering() );

                    buildXmlPrinter.startElement( "fileset" );
                    buildXmlPrinter.addAttribute( "dir", dir.getPath() );
                    if ( dir.getIncludeAsString() != null )
                    {
                        buildXmlPrinter.addAttribute( "includes", dir.getIncludeAsString() );
                    }
                    if ( dir.getExcludeAsString() != null )
                    {
                        buildXmlPrinter.addAttribute( "excludes", dir.getExcludeAsString() );
                    }
                    buildXmlPrinter.endElement();

                    buildXmlPrinter.endElement();
                }

                buildXmlPrinter.endElement();

                buildXmlPrinter.endElement();

                IOUtil.close( buildXmlWriter );
            }
            catch ( IOException e )
            {
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, packaging );
        IOUtil.close( w );
    }
View Full Code Here

        {
            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

TOP

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

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.