Class 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 ValidatorMojo

    Mojo 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.

    See Also:
    Interface to implement a custom validator., Built in validator implementations.
    • 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 dependenciesDirectory
        The directory where all schema dependencies (avsc, avpr, avdl) are made vailable
      • sourceDirectory

        @Parameter(name="sourceDirectory",
                   defaultValue="${basedir}/src/main/avro")
        protected File sourceDirectory
        The 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 generatedJavaTarget
        the destination for the java generated files.
      • generatedAvscTarget

        @Parameter(name="generatedAvscTarget",
                   defaultValue="${project.build.directory}/generated-sources/avsc")
        protected File generatedAvscTarget
        the 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 target
        the target folder.
      • mavenSession

        @Parameter(defaultValue="${session}",
                   required=true,
                   readonly=true)
        protected org.apache.maven.execution.MavenSession mavenSession
        The current build mavenSession instance.
      • useSchemaReferencesForAvsc

        @Parameter(name="useSchemaReferencesForAvsc",
                   defaultValue="false")
        protected boolean useSchemaReferencesForAvsc
        This 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 schemaArtifactClassifier
        the schema artifact classifier.
      • schemaArtifactExtension

        @Parameter(name="schemaArtifactExtension",
                   defaultValue="jar")
        protected String schemaArtifactExtension
        the schema artifact extension.
      • repoSystem

        @Component
        protected org.eclipse.aether.RepositorySystem repoSystem
        The entry point to Aether, i.e. the component doing all the work.
    • Constructor Detail

      • SchemaValidatorMojo

        public SchemaValidatorMojo()
    • Method Detail

      • execute

        public void execute()
                     throws org.apache.maven.plugin.MojoExecutionException,
                            org.apache.maven.plugin.MojoFailureException
        Children must call this.
        Specified by:
        execute in interface org.apache.maven.plugin.Mojo
        Throws:
        org.apache.maven.plugin.MojoExecutionException
        org.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()