Class AbstractXmlPlugin

java.lang.Object
org.apache.maven.plugin.AbstractMojo
au.com.acegi.xmlformat.AbstractXmlPlugin
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo
Direct Known Subclasses:
XmlCheckPlugin, XmlFormatPlugin

public abstract class AbstractXmlPlugin extends org.apache.maven.plugin.AbstractMojo
Common infrastructure for the various plugin goals.
  • Field Details

    • attributeQuoteChar

      @Parameter(property="attributeQuoteChar", defaultValue="\"") private char attributeQuoteChar
      Quote character to use when writing attributes.
    • baseDirectory

      @Parameter(defaultValue=".", readonly=true, required=true, property="project.basedir") private File baseDirectory
      The base directory of the project.
    • encoding

      @Parameter(property="encoding", defaultValue="UTF-8") private String encoding
      The encoding format.
    • excludes

      @Parameter(property="excludes") private String[] excludes
      A set of file patterns that allow you to exclude certain files/folders from the formatting. In addition to these exclusions, the project build directory (typically target) is always excluded if skipTargetFolder is true.
    • expandEmptyElements

      @Parameter(property="expandEmptyElements", defaultValue="false") private boolean expandEmptyElements
      Whether or not to expand empty elements to <tagName></tagName>.
    • includes

      @Parameter(property="includes") private String[] includes
      A set of file patterns that dictate which files should be included in the formatting with each file pattern being relative to the base directory.
    • indentSize

      @Parameter(property="indentSize", defaultValue="2") private int indentSize
      Indicates the number of spaces to apply when indenting.
    • tabIndent

      @Parameter(property="tabIndent", defaultValue="false") private boolean tabIndent
      Use tabs instead of spaces for indents. If set to true, indentSize will be ignored.
    • lineEnding

      @Parameter(property="lineEnding", defaultValue="LF") private LineEnding lineEnding
      Sets the line-ending of files after formatting. Valid values are:
      • "SYSTEM" - Use line endings of current system
      • "LF" - Use Unix and Mac style line endings
      • "CRLF" - Use DOS and Windows style line endings
      • "CR" - Use early Mac style line endings
      This property is only used if lineSeparator has its default value. Do not set any value for lineSeparator.
    • lineSeparator

      @Parameter(property="lineSeparator", defaultValue="\n") @Deprecated private String lineSeparator
      Deprecated.
      Please do not set this value; use lineEnding instead
      New line separator.
    • newLineAfterDeclaration

      @Parameter(property="newLineAfterDeclaration", defaultValue="false") private boolean newLineAfterDeclaration
      Whether or not to print new line after the XML declaration.
    • newLineAfterNTags

      @Parameter(property="newLineAfterNTags", defaultValue="0") private int newLineAfterNTags
      Controls when to output a line.separator every so many tags in case of no lines and total text trimming.
    • newlines

      @Parameter(property="newlines", defaultValue="true") private boolean newlines
      The default new line flag, set to do new lines only as in original document.
    • omitEncoding

      @Parameter(property="omitEncoding", defaultValue="false") private boolean omitEncoding
      Whether or not to output the encoding in the XML declaration.
    • padText

      @Parameter(property="padText", defaultValue="false") private boolean padText
      Pad string-element boundaries with whitespace.
    • skip

      @Parameter(property="xml-format.skip", defaultValue="false") private boolean skip
      Skip XML formatting.
    • skipTargetFolder

      @Parameter(property="skipTargetFolder", defaultValue="true") private boolean skipTargetFolder
      In addition to the exclusions, the project build directory (typically target) is always excluded if true.
    • suppressDeclaration

      @Parameter(property="suppressDeclaration", defaultValue="false") private boolean suppressDeclaration
      Whether or not to suppress the XML declaration.
    • targetDirectory

      @Parameter(defaultValue="${project.build.directory}", readonly=true, required=true) private File targetDirectory
      The project target directory. This is always excluded from formatting.
    • trimText

      @Parameter(property="trimText", defaultValue="true") private boolean trimText
      Should we preserve whitespace or not in text nodes.
    • xhtml

      @Parameter(property="xhtml", defaultValue="false") private boolean xhtml
      Whether or not to use XHTML standard.
    • keepBlankLines

      @Parameter(property="keepBlankLines", defaultValue="false") private boolean keepBlankLines
      Whether to keep blank lines. A maximum of one line is preserved between each tag.
  • Constructor Details

    • AbstractXmlPlugin

      public AbstractXmlPlugin()
  • Method Details

    • execute

      public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
      org.apache.maven.plugin.MojoFailureException
    • processFile

      protected abstract boolean processFile(File input, XmlOutputFormat fmt) throws org.dom4j.DocumentException, IOException
      Processes a single file found in the project.
      Parameters:
      input - the file to process
      fmt - the formatting options
      Returns:
      true if the file required changes to match the formatting style
      Throws:
      org.dom4j.DocumentException - if input XML could not be parsed
      IOException - if output XML stream could not be written
    • afterAllProcessed

      protected abstract void afterAllProcessed(boolean neededFormatting) throws org.apache.maven.plugin.MojoExecutionException
      Invoked after all files in the project have been processed.
      Parameters:
      neededFormatting - whether any processed file required changes to match the formatting style
      Throws:
      org.apache.maven.plugin.MojoExecutionException - if the build must be failed
    • setBaseDirectory

      void setBaseDirectory(File baseDirectory)
    • setExcludes

      void setExcludes(String... excludes)
    • setIncludes

      void setIncludes(String... includes)
    • setSkip

      void setSkip(boolean skip)
    • setSkipTargetFolder

      void setSkipTargetFolder(boolean skipTargetFolder)
    • setTargetDirectory

      void setTargetDirectory(File targetDirectory)
    • buildFormatter

      private XmlOutputFormat buildFormatter()
    • determineLineSeparator

      private String determineLineSeparator()
    • find

      private String[] find()
    • initializeExcludes

      private void initializeExcludes()
    • initializeIncludes

      private void initializeIncludes()