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 AbstractXmlMojo
An XML indentation check over a set of files.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.codehaus.mojo.xml.AbstractXmlMojo
AbstractXmlMojo.CatalogHandling -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate StringThe encoding of files included informatFileSets.private booleanTells the mojo what to do in case XML formatting violations are found.private List<FormatFileSet> File patterns to include.private intThe number of spaces expected for indentation.private SAXParserFactoryprivate booleanIf set totrue, the result ofwill be appended toinvalid reference
FormatFileSet#getDefault(String, int)formatFileSetsbefore the processing.Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcheck(File file, String encoding, XmlFormatViolationHandler violationHandler) Checks the formatting of the givenfile.voidexecute()Called by Maven for executing the Mojo.private 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, setCatalogsMethods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
encoding
@Parameter(property="xml.encoding", defaultValue="${project.build.sourceEncoding}") private 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
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
-
useDefaultFormatFileSet
@Parameter(property="xml.useDefaultFormatFileSet", defaultValue="true") private boolean useDefaultFormatFileSetIf set totrue, the result ofwill be appended toinvalid reference
FormatFileSet#getDefault(String, int)formatFileSetsbefore the processing.
-
-
Constructor Details
-
CheckFormatMojo
public CheckFormatMojo()Creates a newCheckFormatMojoinstance.
-
-
Method Details
-
check
private void check(File file, String encoding, XmlFormatViolationHandler violationHandler) throws org.apache.maven.plugin.MojoExecutionException Checks 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
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
-