@Mojo(defaultPhase=VALIDATE,
name="check-format",
threadSafe=true)
public class CheckFormatMojo
extends AbstractXmlMojo
| Modifier and Type | Class and Description |
|---|---|
private class |
CheckFormatMojo.ViolationCollector |
AbstractXmlMojo.CatalogHandling| Modifier and Type | Field and Description |
|---|---|
private java.lang.String |
encoding
The encoding of files included in
formatFileSets. |
private boolean |
failOnFormatViolation
Tells the mojo what to do in case XML formatting violations are found.
|
private java.util.List<FormatFileSet> |
formatFileSets
File patterns to include.
|
private int |
indentSize
The number of spaces expected for indentation.
|
private javax.xml.parsers.SAXParserFactory |
saxParserFactory
A
SAXParserFactory |
private boolean |
useDefaultFormatFileSet
If set to
true, the result of FormatFileSet#getDefault(String, int) will be appended to
formatFileSets before the processing. |
| Constructor and Description |
|---|
CheckFormatMojo()
Creates a new
CheckFormatMojo instance. |
| Modifier and Type | Method and Description |
|---|---|
private void |
check(java.io.File file,
java.lang.String encoding,
XmlFormatViolationHandler violationHandler)
Checks the formatting of the given
file. |
void |
execute()
Called by Maven for executing the Mojo.
|
private java.lang.String[] |
scan(org.apache.maven.model.FileSet fileSet)
A
DirectoryScanner boiler plate. |
void |
setIndentSize(int indentSize)
Sets the number of spaces for indentation.
|
activateProxy, asAbsoluteFile, asFiles, checkCatalogHandling, getBasedir, getCatalogHandling, getExcludes, getFileNames, getFiles, getLocator, getProject, getResolver, getResource, isSkipping, passivateProxy, setCatalogs@Parameter(property="xml.encoding",
defaultValue="${project.build.sourceEncoding}")
private java.lang.String encoding
formatFileSets. Note that the
encoding can be set also per FormatFileSet.@Parameter(property="xml.failOnFormatViolation",
defaultValue="true")
private boolean failOnFormatViolation
true, all violations will be
reported on the console as ERRORs and the build will fail. if false, all violations will be reported on
the console as WARNs and the build will proceed further.@Parameter private java.util.List<FormatFileSet> formatFileSets
baseDir.@Parameter(property="xml.indentSize",
defaultValue="2")
private int indentSize
indentSize can be configuread also per
FormatFileSet.private javax.xml.parsers.SAXParserFactory saxParserFactory
SAXParserFactory@Parameter(property="xml.useDefaultFormatFileSet",
defaultValue="true")
private boolean useDefaultFormatFileSet
true, the result of FormatFileSet#getDefault(String, int) will be appended to
formatFileSets before the processing.public CheckFormatMojo()
CheckFormatMojo instance.private void check(java.io.File file,
java.lang.String encoding,
XmlFormatViolationHandler violationHandler)
throws org.apache.maven.plugin.MojoExecutionException
file. The file is read using the given encoding and the
violations are reported to the given violationHandler.file - the file to checkencoding - the encoding to use for reading the fileviolationHandler - the XmlFormatViolationHandler to report violationsorg.apache.maven.plugin.MojoExecutionException - if there is any lover level exception reading or parsing the file.public void execute()
throws org.apache.maven.plugin.MojoExecutionException,
org.apache.maven.plugin.MojoFailureException
org.apache.maven.plugin.MojoExecutionException - Running the Mojo failed.org.apache.maven.plugin.MojoFailureException - A configuration error was detected.private java.lang.String[] scan(org.apache.maven.model.FileSet fileSet)
DirectoryScanner boiler plate.fileSet - FileSet to scanpublic void setIndentSize(int indentSize)
indentSize - the number of spaces