Class AnalyzeExclusionsMojo

  • All Implemented Interfaces:
    org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

    @Mojo(name="analyze-exclusions",
          requiresDependencyCollection=TEST,
          threadSafe=true)
    public class AnalyzeExclusionsMojo
    extends org.apache.maven.plugin.AbstractMojo
    Analyzes the exclusions defined on dependencies in this project and reports if any of them are unneeded.

    Relevant use case is when an artifact in a later version has removed usage of a dependency, making the exclusion no longer necessary.

    Since:
    3.7.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private boolean exclusionFail
      Whether to fail the build if invalid exclusions is found.
      private org.apache.maven.project.MavenProject project  
      private java.lang.String projectModelId
      Current project modelId.
      private ResolverUtil resolverUtil  
      private org.apache.maven.execution.MavenSession session  
      private boolean skip
      Skip plugin execution completely.
      • Fields inherited from interface org.apache.maven.plugin.Mojo

        ROLE
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void execute()  
      private java.util.Collection<org.apache.maven.model.Exclusion> getExclusionsForDependency​(org.apache.maven.model.Dependency dependency)  
      private boolean isExclusionInProject​(org.apache.maven.model.Exclusion exclusion)  
      private void logViolations​(java.lang.String name, java.util.Map<Coordinates,​java.util.List<Coordinates>> violations, java.util.function.Consumer<java.lang.String> logger)  
      • 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, toString, wait, wait, wait
    • Field Detail

      • project

        @Component
        private org.apache.maven.project.MavenProject project
      • resolverUtil

        @Component
        private ResolverUtil resolverUtil
      • session

        @Component
        private org.apache.maven.execution.MavenSession session
      • exclusionFail

        @Parameter(property="mdep.exclusion.fail",
                   defaultValue="false")
        private boolean exclusionFail
        Whether to fail the build if invalid exclusions is found.
        Since:
        3.7.0
      • skip

        @Parameter(property="mdep.skip",
                   defaultValue="false")
        private boolean skip
        Skip plugin execution completely.
        Since:
        3.7.0
      • projectModelId

        private java.lang.String projectModelId
        Current project modelId.
    • Constructor Detail

      • AnalyzeExclusionsMojo

        public AnalyzeExclusionsMojo()
    • Method Detail

      • execute

        public void execute()
                     throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • getExclusionsForDependency

        private java.util.Collection<org.apache.maven.model.Exclusion> getExclusionsForDependency​(org.apache.maven.model.Dependency dependency)
      • isExclusionInProject

        private boolean isExclusionInProject​(org.apache.maven.model.Exclusion exclusion)
      • logViolations

        private void logViolations​(java.lang.String name,
                                   java.util.Map<Coordinates,​java.util.List<Coordinates>> violations,
                                   java.util.function.Consumer<java.lang.String> logger)