Class SchemaValidatorMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.spf4j.maven.plugin.avro.avscp.SchemaValidatorMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo,ValidatorMojo
@Mojo(name="avro-validate", defaultPhase=TEST, requiresProject=true) public final class SchemaValidatorMojo extends org.apache.maven.plugin.AbstractMojo implements ValidatorMojoMojo that runs all Schema validators on this project schemas
Built in validators:
- docValidator (schema documentation),
- compatibility (schema compatibility),
- namesValidator (schema named types and field name validation)
By default validation issues will fail the build. This can be disabled at validator level with:
<validatorConfigs> <[validatorName].failOnIssue></[validatorName].failOnIssue> </validatorConfigs>A particular validator can be sckipped at schema level with:
@ignoreValidators(["validatorname"])
Custom validators can be built and used. A custom validator, will need to implement the org.spf4j.maven.plugin.avro.avscp.validation.Validator interface, and will be loaded via the java Service Loader api.
-
-
Field Summary
Fields Modifier and Type Field Description protected FiledependenciesDirectoryThe directory where all schema dependencies (avsc, avpr, avdl) are made vailableprotected FilegeneratedAvscTargetthe destination for the generated avro schema json files (will be published along with the java code).protected FilegeneratedJavaTargetthe destination for the java generated files.protected org.apache.maven.project.MavenProjectmavenProjectprotected org.apache.maven.execution.MavenSessionmavenSessionThe current build mavenSession instance.protected org.eclipse.aether.RepositorySystemrepoSystemThe entry point to Aether, i.e.protected StringschemaArtifactClassifierthe schema artifact classifier.protected StringschemaArtifactExtensionthe schema artifact extension.protected FilesourceDirectoryThe source directory of avro files.protected Filetargetthe target folder.protected booleanuseSchemaReferencesForAvscThis option will use schema references when writing schemas that depend of schemas from other projects, instead of baking them in.
-
Constructor Summary
Constructors Constructor Description SchemaValidatorMojo()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidexecute()Children must call this.FilegetGeneratedAvscTarget()org.apache.maven.project.MavenProjectgetMavenProject()org.apache.maven.execution.MavenSessiongetMavenSession()org.eclipse.aether.RepositorySystemgetRepoSystem()String[]getSchemaFiles()FilegetTarget()Map<String,String>getValidatorConfigs()voidhandleValidation(Map<String,Validator.Result> vresult, org.apache.maven.plugin.logging.Log logger, String detail)StringtoString()will be overwritten as needed, and override will include this result.-
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.spf4j.maven.plugin.avro.avscp.ValidatorMojo
getGeneratedAvscTarget, getLog, getMavenProject, getMavenSession, getRepoSystem, getTarget
-
-
-
-
Field Detail
-
mavenProject
@Parameter(defaultValue="${project}", required=true, readonly=true) protected org.apache.maven.project.MavenProject mavenProject
-
dependenciesDirectory
@Parameter(name="dependenciesDirectory", defaultValue="${project.build.directory}/schema-dependencies", readonly=true) protected File dependenciesDirectoryThe directory where all schema dependencies (avsc, avpr, avdl) are made vailable
-
sourceDirectory
@Parameter(name="sourceDirectory", defaultValue="${basedir}/src/main/avro") protected File sourceDirectoryThe source directory of avro files. This directory is added to the classpath at schema compiling time. All files can therefore be referenced as classpath resources following the directory structure under the source directory.
-
generatedJavaTarget
@Parameter(name="generatedJavaTarget", defaultValue="${project.build.directory}/generated-sources/avro") protected File generatedJavaTargetthe destination for the java generated files.
-
generatedAvscTarget
@Parameter(name="generatedAvscTarget", defaultValue="${project.build.directory}/generated-sources/avsc") protected File generatedAvscTargetthe destination for the generated avro schema json files (will be published along with the java code).
-
target
@Parameter(name="target", defaultValue="${project.build.directory}") protected File targetthe target folder.
-
mavenSession
@Parameter(defaultValue="${session}", required=true, readonly=true) protected org.apache.maven.execution.MavenSession mavenSessionThe current build mavenSession instance.
-
useSchemaReferencesForAvsc
@Parameter(name="useSchemaReferencesForAvsc", defaultValue="false") protected boolean useSchemaReferencesForAvscThis option will use schema references when writing schemas that depend of schemas from other projects, instead of baking them in. by default (false) all schema references will be inlined.
-
schemaArtifactClassifier
@Parameter(name="schemaArtifactClassifier", defaultValue="avsc") protected String schemaArtifactClassifierthe schema artifact classifier.
-
schemaArtifactExtension
@Parameter(name="schemaArtifactExtension", defaultValue="jar") protected String schemaArtifactExtensionthe schema artifact extension.
-
repoSystem
@Component protected org.eclipse.aether.RepositorySystem repoSystem
The entry point to Aether, i.e. the component doing all the work.
-
-
Method Detail
-
getValidatorConfigs
public Map<String,String> getValidatorConfigs()
- Specified by:
getValidatorConfigsin interfaceValidatorMojo
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureExceptionChildren must call this.- Specified by:
executein interfaceorg.apache.maven.plugin.Mojo- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException
-
handleValidation
public void handleValidation(Map<String,Validator.Result> vresult, org.apache.maven.plugin.logging.Log logger, String detail) throws org.apache.maven.plugin.MojoExecutionException
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
getSchemaFiles
public String[] getSchemaFiles()
-
toString
public String toString()
will be overwritten as needed, and override will include this result.
-
getRepoSystem
public final org.eclipse.aether.RepositorySystem getRepoSystem()
-
getMavenSession
public final org.apache.maven.execution.MavenSession getMavenSession()
-
getMavenProject
public final org.apache.maven.project.MavenProject getMavenProject()
-
getGeneratedAvscTarget
public final File getGeneratedAvscTarget()
-
getTarget
public final File getTarget()
-
-