/** * Convenience method to repeat <code>CRLF</code>. * * @param writer not null * @param repeat positive number */ public static void writeLineBreak( XMLWriter writer, int repeat ) { for ( int i = 0; i < repeat; i++ ) { writer.writeMarkup( LS ); } }
/** * Convenience method to write XML comment line break with <code>columnSize</code> as length. * * @param writer not null * @param columnSize positive number */ public static void writeCommentLineBreak( XMLWriter writer, int columnSize ) { if ( columnSize < 10 ) { columnSize = DEFAULT_COLUMN_LINE; } writer.writeMarkup( "<!-- " + StringUtils.repeat( "=", columnSize - 10 ) + " -->" + LS ); }
writer.writeMarkup( line.toString() ); writer.writeMarkup( line.toString() );
writer.writeMarkup( StringUtils.repeat( " ", indent * indentSize ) ); writeCommentLineBreak( writer, columnSize ); writer.writeMarkup( StringUtils.repeat( " ", indent * indentSize ) ); writeCommentLineBreak( writer, columnSize );
public static void write( XMLWriter xmlWriter, Xpp3Dom dom, boolean escape ) { // TODO: move to XMLWriter? xmlWriter.startElement( dom.getName() ); String[] attributeNames = dom.getAttributeNames(); for ( String attributeName : attributeNames ) { xmlWriter.addAttribute( attributeName, dom.getAttribute( attributeName ) ); } Xpp3Dom[] children = dom.getChildren(); for ( Xpp3Dom aChildren : children ) { write( xmlWriter, aChildren, escape ); } String value = dom.getValue(); if ( value != null ) { if ( escape ) { xmlWriter.writeText( value ); } else { xmlWriter.writeMarkup( value ); } } xmlWriter.endElement(); }
private static void writeMarkupElement( XMLWriter w, String name, String markup ) { w.startElement( name ); w.writeMarkup( markup ); w.endElement(); }
private void writeEffectiveSite( DecorationModel decorationModel, XMLWriter writer ) throws MojoExecutionException { String effectiveSite; StringWriter sWriter = new StringWriter(); DecorationXpp3Writer siteWriter = new DecorationXpp3Writer(); try { siteWriter.write( sWriter, decorationModel ); } catch ( IOException e ) { throw new MojoExecutionException( "Cannot serialize site descriptor to XML.", e ); } effectiveSite = sWriter.toString(); effectiveSite = effectiveSite.substring( effectiveSite.indexOf( "<project " ) ); // remove "<?xml" header writeComment( writer, "Effective site descriptor for project \'" + project.getId() + "\'" ); writer.writeMarkup( effectiveSite ); }
/** * @param param not null * @param value could be null * @param w not null */ private void writeDetail( String param, String value, XMLWriter w ) { if ( StringUtils.isNotEmpty( value ) ) { w.startElement( "li" ); w.writeMarkup( format( "pluginxdoc.detail", new String[]{ param, value } ) ); w.endElement(); //li } }
/** * @param param not null * @param value could be null * @param w not null */ private void writeDetail( String param, String value, XMLWriter w ) { if ( StringUtils.isNotEmpty( value ) ) { w.startElement( "li" ); w.writeMarkup( format( "pluginxdoc.detail", new String[]{ param, value } ) ); w.endElement(); //li } }
/** * @param param not null * @param value could be null * @param w not null */ private void writeDetail( String param, String value, XMLWriter w ) { if ( StringUtils.isNotEmpty( value ) ) { w.startElement( "li" ); w.writeMarkup( format( "pluginxdoc.detail", new String[]{ param, value } ) ); w.endElement(); //li } }
/** {@inheritDoc} */ public void close() { super.close(); String xdocContent = xdocWriter.toString(); if ( getLog().isDebugEnabled() ) { getLog().debug( "Xdoc content: " + xdocContent ); } StringWriter formattedContent = new StringWriter(); try { XmlUtil.prettyFormat( new StringReader( xdocContent ), formattedContent ); } catch ( IOException e ) { if ( getLog().isDebugEnabled() ) { getLog().error( "IOException: " + e.getMessage(), e ); } formattedContent = new StringWriter(); formattedContent.write( xdocContent ); } xmlWriter.writeMarkup( formattedContent.toString() ); } }
/** * @param mojoDescriptor not null * @param w not null */ private void writeReportNotice( MojoDescriptor mojoDescriptor, XMLWriter w ) { if ( GeneratorUtils.isMavenReport( mojoDescriptor.getImplementation(), project ) ) { w.startElement( "p" ); w.writeMarkup( getString( "pluginxdoc.mojodescriptor.notice.note" ) ); w.writeText( getString( "pluginxdoc.mojodescriptor.notice.isMavenReport" ) ); w.endElement(); //p } }
private void writeEclipseMetadataXml(OutputStream out, List<String> goals) throws IOException { OutputStreamWriter writer = new OutputStreamWriter(out, "UTF-8"); XMLWriter w = new PrettyPrintXMLWriter(writer, "UTF-8", null); w.writeMarkup("\n<!-- Generated by " + this.getClass().getSimpleName() + " -->\n\n"); w.startElement("lifecycleMappingMetadata"); if (!goals.isEmpty()) { w.startElement("pluginExecutions"); w.startElement("pluginExecution"); w.startElement("pluginExecutionFilter"); w.startElement("goals"); goals.forEach(g -> writeGoalElement(w, g)); w.endElement(); // goals w.endElement(); // pluginExecutionFilter w.startElement("action"); w.startElement("configurator"); w.startElement("id"); w.writeText("io.takari.m2e.incrementalbuild.builderMojoExecutionConfigurator"); w.endElement(); // id w.endElement(); // configurator w.endElement(); // action w.endElement(); // pluginExecution w.endElement(); // pluginExecutions } w.endElement(); // lifecycleMappingMetadata writer.close(); }
private void writeEclipseMetadataXml(OutputStream out, List<String> goals) throws IOException { OutputStreamWriter writer = new OutputStreamWriter(out, "UTF-8"); XMLWriter w = new PrettyPrintXMLWriter(writer, "UTF-8", null); w.writeMarkup("\n<!-- Generated by " + this.getClass().getSimpleName() + " -->\n\n"); w.startElement("lifecycleMappingMetadata"); if (!goals.isEmpty()) { w.startElement("pluginExecutions"); w.startElement("pluginExecution"); w.startElement("pluginExecutionFilter"); w.startElement("goals"); goals.forEach(g -> writeGoalElement(w, g)); w.endElement(); // goals w.endElement(); // pluginExecutionFilter w.startElement("action"); w.startElement("configurator"); w.startElement("id"); w.writeText("io.takari.m2e.incrementalbuild.builderMojoExecutionConfigurator"); w.endElement(); // id w.endElement(); // configurator w.endElement(); // action w.endElement(); // pluginExecution w.endElement(); // pluginExecutions } w.endElement(); // lifecycleMappingMetadata writer.close(); }
public void writeDescriptor(OutputStream outputStream, PluginDescriptor pluginDescriptor) throws IOException { OutputStreamWriter writer = new OutputStreamWriter(outputStream, encoding); XMLWriter w = new PrettyPrintXMLWriter(writer, encoding, null); w.writeMarkup("\n<!-- Generated by takari-plugin-tools -->\n\n"); w.startElement("plugin"); element(w, "name", pluginDescriptor.getName()); element(w, "description", pluginDescriptor.getDescription()); element(w, "groupId", pluginDescriptor.getGroupId()); element(w, "artifactId", pluginDescriptor.getArtifactId()); element(w, "version", pluginDescriptor.getVersion()); element(w, "goalPrefix", pluginDescriptor.getGoalPrefix()); element(w, "isolatedRealm", String.valueOf(pluginDescriptor.isIsolatedRealm())); element(w, "inheritedByDefault", String.valueOf(pluginDescriptor.isInheritedByDefault())); writeMojos(w, pluginDescriptor); writeDependencies(w, pluginDescriptor); w.endElement(); writer.flush(); }
public void writeDescriptor(OutputStream outputStream, PluginDescriptor pluginDescriptor) throws IOException { OutputStreamWriter writer = new OutputStreamWriter(outputStream, encoding); XMLWriter w = new PrettyPrintXMLWriter(writer, encoding, null); w.writeMarkup("\n<!-- Generated by takari-plugin-tools -->\n\n"); w.startElement("plugin"); element(w, "name", pluginDescriptor.getName()); element(w, "description", pluginDescriptor.getDescription()); element(w, "groupId", pluginDescriptor.getGroupId()); element(w, "artifactId", pluginDescriptor.getArtifactId()); element(w, "version", pluginDescriptor.getVersion()); element(w, "goalPrefix", pluginDescriptor.getGoalPrefix()); element(w, "isolatedRealm", String.valueOf(pluginDescriptor.isIsolatedRealm())); element(w, "inheritedByDefault", String.valueOf(pluginDescriptor.isInheritedByDefault())); writeMojos(w, pluginDescriptor); writeDependencies(w, pluginDescriptor); w.endElement(); writer.flush(); }
/** * @param mojoDescriptor not null * @param w not null */ private void writeGoalParameterTable( MojoDescriptor mojoDescriptor, XMLWriter w ) { List parameterList = mojoDescriptor.getParameters(); //remove components and read-only parameters List list = filterParameters( parameterList ); if ( list != null && list.size() > 0 ) { writeParameterSummary( mojoDescriptor, list, w ); writeParameterDetails( mojoDescriptor, list, w ); } else { w.startElement( "subsection" ); w.addAttribute( "name", getString( "pluginxdoc.mojodescriptor.parameters" ) ); w.startElement( "p" ); w.writeMarkup( getString( "pluginxdoc.mojodescriptor.noParameter" ) ); w.endElement(); //p w.endElement(); } }
/** * @param mojoDescriptor not null * @param w not null */ private void writeGoalParameterTable( MojoDescriptor mojoDescriptor, XMLWriter w ) { List<Parameter> parameterList = mojoDescriptor.getParameters(); // remove components and read-only parameters List<Parameter> list = filterParameters( parameterList ); if ( !list.isEmpty() ) { writeParameterSummary( mojoDescriptor, list, w ); writeParameterDetails( mojoDescriptor, list, w ); } else { w.startElement( "subsection" ); w.addAttribute( "name", getString( "pluginxdoc.mojodescriptor.parameters" ) ); w.startElement( "p" ); w.writeMarkup( getString( "pluginxdoc.mojodescriptor.noParameter" ) ); w.endElement(); //p w.endElement(); } }
/** * @param mojoDescriptor not null * @param w not null */ private void writeGoalParameterTable( MojoDescriptor mojoDescriptor, XMLWriter w ) { List parameterList = mojoDescriptor.getParameters(); //remove components and read-only parameters List list = filterParameters( parameterList ); if ( list != null && list.size() > 0 ) { writeParameterSummary( mojoDescriptor, list, w ); writeParameterDetails( mojoDescriptor, list, w ); } else { w.startElement( "subsection" ); w.addAttribute( "name", getString( "pluginxdoc.mojodescriptor.parameters" ) ); w.startElement( "p" ); w.writeMarkup( getString( "pluginxdoc.mojodescriptor.noParameter" ) ); w.endElement(); //p w.endElement(); } }
w.writeMarkup( getDescription( contentField ) );