Package org.apache.maven.shared.artifact.filter.collection

## Class ArtifactTransitivityFilter

- java.lang.Object
- - org.apache.maven.shared.artifact.filter.collection.AbstractArtifactsFilter
  - - org.apache.maven.shared.artifact.filter.collection.ArtifactTransitivityFilter

All Implemented Interfaces:
  `ArtifactsFilter`

    public class ArtifactTransitivityFilter
    extends AbstractArtifactsFilter

This filter will exclude everything that is not a dependency of the selected artifact.

Version:
  $Id: ArtifactTransitivityFilter.java 1716978 2015-11-28 14:47:04Z khmarbaise $
Author:
  Brian Fox

### Constructor Summary

Constructors
`ArtifactTransitivityFilter​(org.apache.maven.artifact.Artifact artifact, org.apache.maven.project.ProjectBuildingRequest buildingRequest, org.apache.maven.project.ProjectBuilder projectBuilder)` Use `MavenSession.getProjectBuildingRequest()` to get the buildingRequest.

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`boolean` `artifactIsATransitiveDependency​(org.apache.maven.artifact.Artifact artifact)` Compares the artifact to the list of dependencies to see if it is directly included by this project
`java.util.Set<org.apache.maven.artifact.Artifact>` `filter​(java.util.Set<org.apache.maven.artifact.Artifact> artifacts)`
`protected static boolean` `isMaven31()`

### Methods inherited from class org.apache.maven.shared.artifact.filter.collection.AbstractArtifactsFilter

`isArtifactIncluded`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### ArtifactTransitivityFilter

    public ArtifactTransitivityFilter​(org.apache.maven.artifact.Artifact artifact,
                                      org.apache.maven.project.ProjectBuildingRequest buildingRequest,
                                      org.apache.maven.project.ProjectBuilder projectBuilder)
                               throws org.apache.maven.project.ProjectBuildingException

Use `MavenSession.getProjectBuildingRequest()` to get the buildingRequest. The projectBuilder should be resolved with CDI.

       // For Mojo
       @Component
       private ProjectBuilder projectBuilder;

       // For Components
       @Requirement // or @Inject
       private ProjectBuilder projectBuilder;

Parameters:
  `artifact` - the artifact to resolve the dependencies from
  `buildingRequest` - the buildingRequest
  `projectBuilder` - the projectBuilder
Throws:
  `org.apache.maven.project.ProjectBuildingException` - if the project descriptor could not be successfully built

### Method Detail

#### isMaven31

    protected static boolean isMaven31()

Returns:
  true if the current Maven version is Maven 3.1.

#### filter

    public java.util.Set<org.apache.maven.artifact.Artifact> filter​(java.util.Set<org.apache.maven.artifact.Artifact> artifacts)

Parameters:
  `artifacts` - `Artifact`
Returns:
  Set of artifacts.

#### artifactIsATransitiveDependency

    public boolean artifactIsATransitiveDependency​(org.apache.maven.artifact.Artifact artifact)

Compares the artifact to the list of dependencies to see if it is directly included by this project

Parameters:
  `artifact` - representing the item to compare.
Returns:
  true if artifact is a transitive dependency