Package au.com.acegi.xmlformat
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.AbstractMojoCommon infrastructure for the various plugin goals.
-
-
Field Summary
Fields Modifier and Type Field Description private charattributeQuoteCharQuote character to use when writing attributes.private java.io.FilebaseDirectoryThe base directory of the project.private java.lang.StringencodingThe encoding format.private java.lang.String[]excludesA set of file patterns that allow you to exclude certain files/folders from the formatting.private booleanexpandEmptyElementsWhether or not to expand empty elements to <tagName></tagName>.private java.lang.String[]includesA set of file patterns that dictate which files should be included in the formatting with each file pattern being relative to the base directory.private intindentSizeIndicates the number of spaces to apply when indenting.private booleankeepBlankLinesWhether to keep blank lines.private LineEndinglineEndingSets the line-ending of files after formatting.private java.lang.StringlineSeparatorDeprecated.Please do not set this value; uselineEndinginsteadprivate booleannewLineAfterDeclarationWhether or not to print new line after the XML declaration.private intnewLineAfterNTagsControls when to output a line.separator every so many tags in case of no lines and total text trimming.private booleannewlinesThe default new line flag, set to do new lines only as in original document.private booleanomitEncodingWhether or not to output the encoding in the XML declaration.private booleanpadTextPad string-element boundaries with whitespace.private booleanskipSkip XML formatting.private booleanskipTargetFolderIn addition to the exclusions, the project build directory (typicallytarget) is always excluded if true.private booleansuppressDeclarationWhether or not to suppress the XML declaration.private booleantabIndentUse tabs instead of spaces for indents.private java.io.FiletargetDirectoryThe project target directory.private booleantrimTextShould we preserve whitespace or not in text nodes.private booleanxhtmlWhether or not to use XHTML standard.
-
Constructor Summary
Constructors Constructor Description AbstractXmlPlugin()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voidafterAllProcessed(boolean neededFormatting)Invoked after all files in the project have been processed.private XmlOutputFormatbuildFormatter()private java.lang.StringdetermineLineSeparator()voidexecute()private java.lang.String[]find()private voidinitializeExcludes()private voidinitializeIncludes()protected abstract booleanprocessFile(java.io.File input, XmlOutputFormat fmt)Processes a single file found in the project.(package private) voidsetBaseDirectory(java.io.File baseDirectory)(package private) voidsetExcludes(java.lang.String... excludes)(package private) voidsetIncludes(java.lang.String... includes)(package private) voidsetSkip(boolean skip)(package private) voidsetSkipTargetFolder(boolean skipTargetFolder)(package private) voidsetTargetDirectory(java.io.File targetDirectory)
-
-
-
Field Detail
-
attributeQuoteChar
@Parameter(property="attributeQuoteChar", defaultValue="\"") private char attributeQuoteCharQuote character to use when writing attributes.
-
baseDirectory
@Parameter(defaultValue=".", readonly=true, required=true, property="project.basedir") private java.io.File baseDirectoryThe base directory of the project.
-
encoding
@Parameter(property="encoding", defaultValue="UTF-8") private java.lang.String encodingThe encoding format.
-
excludes
@Parameter(property="excludes") private java.lang.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 (typicallytarget) is always excluded if skipTargetFolder is true.
-
expandEmptyElements
@Parameter(property="expandEmptyElements", defaultValue="false") private boolean expandEmptyElementsWhether or not to expand empty elements to <tagName></tagName>.
-
includes
@Parameter(property="includes") private java.lang.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 indentSizeIndicates the number of spaces to apply when indenting.
-
tabIndent
@Parameter(property="tabIndent", defaultValue="false") private boolean tabIndentUse tabs instead of spaces for indents. If set totrue,indentSizewill be ignored.
-
lineEnding
@Parameter(property="lineEnding", defaultValue="LF") private LineEnding lineEndingSets 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
lineSeparatorhas its default value. Do not set any value forlineSeparator.
-
lineSeparator
@Parameter(property="lineSeparator", defaultValue="\n") @Deprecated private java.lang.String lineSeparatorDeprecated.Please do not set this value; uselineEndinginsteadNew line separator.
-
newLineAfterDeclaration
@Parameter(property="newLineAfterDeclaration", defaultValue="false") private boolean newLineAfterDeclarationWhether or not to print new line after the XML declaration.
-
newLineAfterNTags
@Parameter(property="newLineAfterNTags", defaultValue="0") private int newLineAfterNTagsControls 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 newlinesThe default new line flag, set to do new lines only as in original document.
-
omitEncoding
@Parameter(property="omitEncoding", defaultValue="false") private boolean omitEncodingWhether or not to output the encoding in the XML declaration.
-
padText
@Parameter(property="padText", defaultValue="false") private boolean padTextPad string-element boundaries with whitespace.
-
skip
@Parameter(property="xml-format.skip", defaultValue="false") private boolean skipSkip XML formatting.
-
skipTargetFolder
@Parameter(property="skipTargetFolder", defaultValue="true") private boolean skipTargetFolderIn addition to the exclusions, the project build directory (typicallytarget) is always excluded if true.
-
suppressDeclaration
@Parameter(property="suppressDeclaration", defaultValue="false") private boolean suppressDeclarationWhether or not to suppress the XML declaration.
-
targetDirectory
@Parameter(defaultValue="${project.build.directory}", readonly=true, required=true) private java.io.File targetDirectoryThe project target directory. This is always excluded from formatting.
-
trimText
@Parameter(property="trimText", defaultValue="true") private boolean trimTextShould we preserve whitespace or not in text nodes.
-
xhtml
@Parameter(property="xhtml", defaultValue="false") private boolean xhtmlWhether or not to use XHTML standard.
-
keepBlankLines
@Parameter(property="keepBlankLines", defaultValue="false") private boolean keepBlankLinesWhether to keep blank lines. A maximum of one line is preserved between each tag.
-
-
Method Detail
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException
-
processFile
protected abstract boolean processFile(java.io.File input, XmlOutputFormat fmt) throws org.dom4j.DocumentException, java.io.IOExceptionProcesses a single file found in the project.- Parameters:
input- the file to processfmt- 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 parsedjava.io.IOException- if output XML stream could not be written
-
afterAllProcessed
protected abstract void afterAllProcessed(boolean neededFormatting) throws org.apache.maven.plugin.MojoExecutionExceptionInvoked 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(java.io.File baseDirectory)
-
setExcludes
void setExcludes(java.lang.String... excludes)
-
setIncludes
void setIncludes(java.lang.String... includes)
-
setSkip
void setSkip(boolean skip)
-
setSkipTargetFolder
void setSkipTargetFolder(boolean skipTargetFolder)
-
setTargetDirectory
void setTargetDirectory(java.io.File targetDirectory)
-
buildFormatter
private XmlOutputFormat buildFormatter()
-
determineLineSeparator
private java.lang.String determineLineSeparator()
-
find
private java.lang.String[] find()
-
initializeExcludes
private void initializeExcludes()
-
initializeIncludes
private void initializeIncludes()
-
-