Class AbstractValidateMojo

  • All Implemented Interfaces:
    org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo
    Direct Known Subclasses:
    ValidateFilesMojo, ValidatePackageMojo

    public abstract class AbstractValidateMojo
    extends org.apache.maven.plugin.AbstractMojo
    Common ancestor for all validation related mojos
    • Field Detail

      • project

        @Parameter(defaultValue="${project}",
                   readonly=true,
                   required=false)
        protected org.apache.maven.project.MavenProject project
        The Maven project (never null, but might be dummy project returning null for all methods if running outside a pom.xml context)
      • mojoExecution

        @Parameter(defaultValue="${mojoExecution}",
                   readonly=true,
                   required=true)
        protected org.apache.maven.plugin.MojoExecution mojoExecution
      • session

        @Parameter(defaultValue="${session}",
                   readonly=true,
                   required=false)
        protected org.apache.maven.execution.MavenSession session
      • failOnValidationWarnings

        @Parameter(property="vault.failOnValidationWarning",
                   defaultValue="false")
        protected boolean failOnValidationWarnings
        If set to true will lead to all validation errors or warnings failing the build, otherwise only validation errors lead to a build failure
      • dependencies

        @Parameter(property="vault.dependencies")
        protected Collection<MavenBasedPackageDependency> dependencies
        Defines the list of dependencies. A dependency is declared as a <dependency> element of a list style <dependencies> element:
         <dependency>
             <group>theGroup</group>
             <name>theName</name>
             <version>1.5</version>
         </dependency>
         

        The dependency can also reference a maven project dependency, this is preferred as it yields to more robust builds.

         <dependency>
             <groupId>theGroup</groupId>
             <artifactId>theName</artifactId>
         </dependency>
         

        The versionRange may be indicated as a single version, in which case the version range has no upper bound and defines the minimal version accepted. Otherwise, the version range defines a lower and upper bound of accepted versions, where the bounds are either included using parentheses () or excluded using brackets []

      • repositoryStructurePackages

        @Parameter(property="vault.repository.structure.packages")
        protected Collection<MavenBasedPackageDependency> repositoryStructurePackages
        Defines the packages that define the repository structure. They are sharing the same format as the elements used in dependencies.

        The repoinit feature of Sling can define initial content that will be available in the repository before the first package is installed. Packages that depend on those nodes have no way to reference a regular dependency package that provides these nodes. A "real" package that would creates those nodes cannot be installed in the repository, because it would void the repoinit structure. On the other hand FileVault would complain, if the package was listed as dependency but not installed in the repository. Therefore these repository-structure packages serve as build-time only dependency that help satisfy the structural dependencies, but are not added as real (i.e. run-time) dependencies to the package. Repository-structure packages are only evaluated for their contained filter rules' root attributes. Currently these packages are only used to define the validRoots of the validator jackrabbit-filter.

      • mapPackageDependencyToMavenGa

        @Parameter(property="vault.package.dependency.to.maven.ga")
        protected Collection<String> mapPackageDependencyToMavenGa
        Mapping of package dependencies given via group and name to Maven identifiers for enhanced validation. Each entry must have the format <group>:<name>=<groupId>:<artifactId>. To disable lookup (e.g. because referenced artifact is not available in a Maven repository) use <group>:<name>=ignore. This will also prevent the WARNING which would be otherwise be emitted.
      • csvReportFile

        @Parameter(property="vault.validation.csvReportFile")
        protected File csvReportFile
        The file where to write a report of all found validation violations (warnings and errors) in CSV format as defined in RFC 4180. The generated file is using UTF-8 character encoding. No CSV report is written if this parameter is not set (default).
      • repositorySystem

        @Component
        protected org.apache.maven.repository.RepositorySystem repositorySystem
      • resolutionErrorHandler

        @Component
        protected org.apache.maven.artifact.resolver.ResolutionErrorHandler resolutionErrorHandler
      • buildContext

        @Component
        protected org.sonatype.plexus.build.incremental.BuildContext buildContext
      • validationExecutorFactory

        protected final org.apache.jackrabbit.vault.validation.ValidationExecutorFactory validationExecutorFactory
      • IGNORE_ARTIFACT

        public static final org.apache.maven.artifact.Artifact IGNORE_ARTIFACT
        Artificial Maven artifact which indicates that it should not be considered for further lookup!
    • Constructor Detail

      • AbstractValidateMojo

        public AbstractValidateMojo()
    • Method Detail

      • getProjectRelativeFilePath

        protected String getProjectRelativeFilePath​(Path path)
      • getRelativeFilePath

        public static String getRelativeFilePath​(@NotNull
                                                 @NotNull Path path,
                                                 @Nullable
                                                 @Nullable Path baseDir)
      • shouldSkip

        protected boolean shouldSkip()
        Returns:
        true to skip execution of the mojo. Default is false.
      • execute

        public void execute()
                     throws org.apache.maven.plugin.MojoExecutionException,
                            org.apache.maven.plugin.MojoFailureException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
        org.apache.maven.plugin.MojoFailureException
      • doExecute

        public abstract void doExecute​(ValidationMessagePrinter validationHelper)
                                throws org.apache.maven.plugin.MojoExecutionException,
                                       org.apache.maven.plugin.MojoFailureException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
        org.apache.maven.plugin.MojoFailureException
      • getEffectiveValidatorSettingsForPackage

        protected Map<String,​ValidatorSettings> getEffectiveValidatorSettingsForPackage​(org.apache.jackrabbit.vault.packaging.PackageId packageId,
                                                                                              boolean isSubPackage)
                                                                                       throws org.apache.maven.plugin.MojoFailureException
        Throws:
        org.apache.maven.plugin.MojoFailureException
      • getEffectiveValidatorSettingsForPackage

        protected static Map<String,​ValidatorSettings> getEffectiveValidatorSettingsForPackage​(Map<String,​ValidatorSettings> validatorsSettings,
                                                                                                     org.apache.jackrabbit.vault.packaging.PackageId packageId,
                                                                                                     boolean isSubPackage)