Package org.codehaus.mojo.xml
Class CheckFormatMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.codehaus.mojo.xml.AbstractXmlMojo
-
- org.codehaus.mojo.xml.CheckFormatMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
@Mojo(defaultPhase=VALIDATE, name="check-format", threadSafe=true) public class CheckFormatMojo extends AbstractXmlMojoAn XML indentation check over a set of files.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classCheckFormatMojo.ViolationCollector-
Nested classes/interfaces inherited from class org.codehaus.mojo.xml.AbstractXmlMojo
AbstractXmlMojo.CatalogHandling
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringencodingThe encoding of files included informatFileSets.private booleanfailOnFormatViolationTells the mojo what to do in case XML formatting violations are found.private java.util.List<FormatFileSet>formatFileSetsFile patterns to include.private intindentSizeThe number of spaces expected for indentation.private javax.xml.parsers.SAXParserFactorysaxParserFactoryASAXParserFactoryprivate booleanuseDefaultFormatFileSetIf set totrue, the result ofFormatFileSet#getDefault(String, int)will be appended toformatFileSetsbefore the processing.
-
Constructor Summary
Constructors Constructor Description CheckFormatMojo()Creates a newCheckFormatMojoinstance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcheck(java.io.File file, java.lang.String encoding, XmlFormatViolationHandler violationHandler)Checks the formatting of the givenfile.voidexecute()Called by Maven for executing the Mojo.private java.lang.String[]scan(org.apache.maven.model.FileSet fileSet)ADirectoryScannerboiler plate.voidsetIndentSize(int indentSize)Sets the number of spaces for indentation.-
Methods inherited from class org.codehaus.mojo.xml.AbstractXmlMojo
activateProxy, asAbsoluteFile, asFiles, checkCatalogHandling, getBasedir, getCatalogHandling, getExcludes, getFileNames, getFiles, getLocator, getProject, getResolver, getResource, isSkipping, passivateProxy, setCatalogs
-
-
-
-
Field Detail
-
encoding
@Parameter(property="xml.encoding", defaultValue="${project.build.sourceEncoding}") private java.lang.String encodingThe encoding of files included informatFileSets. Note that theencoding can be set also per FormatFileSet.
-
failOnFormatViolation
@Parameter(property="xml.failOnFormatViolation", defaultValue="true") private boolean failOnFormatViolationTells the mojo what to do in case XML formatting violations are found. iftrue, all violations will be reported on the console as ERRORs and the build will fail. iffalse, all violations will be reported on the console as WARNs and the build will proceed further.
-
formatFileSets
@Parameter private java.util.List<FormatFileSet> formatFileSets
File patterns to include. The patterns are relative to the current project'sbaseDir.
-
indentSize
@Parameter(property="xml.indentSize", defaultValue="2") private int indentSizeThe number of spaces expected for indentation. Note thatindentSizecan be configuread also perFormatFileSet.
-
saxParserFactory
private javax.xml.parsers.SAXParserFactory saxParserFactory
ASAXParserFactory
-
useDefaultFormatFileSet
@Parameter(property="xml.useDefaultFormatFileSet", defaultValue="true") private boolean useDefaultFormatFileSetIf set totrue, the result ofFormatFileSet#getDefault(String, int)will be appended toformatFileSetsbefore the processing.
-
-
Constructor Detail
-
CheckFormatMojo
public CheckFormatMojo()
Creates a newCheckFormatMojoinstance.
-
-
Method Detail
-
check
private void check(java.io.File file, java.lang.String encoding, XmlFormatViolationHandler violationHandler) throws org.apache.maven.plugin.MojoExecutionExceptionChecks the formatting of the givenfile. The file is read using the givenencodingand the violations are reported to the givenviolationHandler.- Parameters:
file- the file to checkencoding- the encoding to use for reading thefileviolationHandler- theXmlFormatViolationHandlerto report violations- Throws:
org.apache.maven.plugin.MojoExecutionException- if there is any lover level exception reading or parsing the file.
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureExceptionCalled by Maven for executing the Mojo.- Throws:
org.apache.maven.plugin.MojoExecutionException- Running the Mojo failed.org.apache.maven.plugin.MojoFailureException- A configuration error was detected.
-
scan
private java.lang.String[] scan(org.apache.maven.model.FileSet fileSet)
ADirectoryScannerboiler plate.- Parameters:
fileSet-FileSetto scan- Returns:
- the included paths
-
setIndentSize
public void setIndentSize(int indentSize)
Sets the number of spaces for indentation.- Parameters:
indentSize- the number of spaces
-
-