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.AbstractMojo
Common infrastructure for the various plugin goals.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate charQuote character to use when writing attributes.private FileThe base directory of the project.private StringThe encoding format.private String[]A set of file patterns that allow you to exclude certain files/folders from the formatting.private booleanWhether or not to expand empty elements to <tagName></tagName>.private String[]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.private intIndicates the number of spaces to apply when indenting.private booleanWhether to keep blank lines.private LineEndingSets the line-ending of files after formatting.private StringDeprecated.private booleanWhether or not to print new line after the XML declaration.private intControls when to output a line.separator every so many tags in case of no lines and total text trimming.private booleanThe default new line flag, set to do new lines only as in original document.private booleanWhether or not to output the encoding in the XML declaration.private booleanPad string-element boundaries with whitespace.private booleanSkip XML formatting.private booleanIn addition to the exclusions, the project build directory (typicallytarget) is always excluded if true.private booleanWhether or not to suppress the XML declaration.private booleanUse tabs instead of spaces for indents.private FileThe project target directory.private booleanShould we preserve whitespace or not in text nodes.private booleanWhether or not to use XHTML standard.Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidafterAllProcessed(boolean neededFormatting) Invoked after all files in the project have been processed.private XmlOutputFormatprivate Stringvoidexecute()private String[]find()private voidprivate voidprotected abstract booleanprocessFile(File input, XmlOutputFormat fmt) Processes a single file found in the project.(package private) voidsetBaseDirectory(File baseDirectory) (package private) voidsetExcludes(String... excludes) (package private) voidsetIncludes(String... includes) (package private) voidsetSkip(boolean skip) (package private) voidsetSkipTargetFolder(boolean skipTargetFolder) (package private) voidsetTargetDirectory(File targetDirectory) Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
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 File baseDirectoryThe base directory of the project. -
encoding
The encoding format. -
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
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
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
lineSeparatorhas its default value. Do not set any value forlineSeparator. -
lineSeparator
Deprecated.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 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.
-
-
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.MojoExecutionExceptionorg.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 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 parsedIOException- 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
-
setExcludes
-
setIncludes
-
setSkip
void setSkip(boolean skip) -
setSkipTargetFolder
void setSkipTargetFolder(boolean skipTargetFolder) -
setTargetDirectory
-
buildFormatter
-
determineLineSeparator
-
find
-
initializeExcludes
private void initializeExcludes() -
initializeIncludes
private void initializeIncludes()
-
lineEndinginstead