Comparison: Dependency vs Artifact vs MavenProject

Here's a small matrix which should help you choosing the right instance.

In general:

  • an Artifact holds a file mapped on a certain coordinate (GAV + classifier + extension),
  • a Dependency contains an artifact and has transitive information,
  • a MavenProject holds a pom-file, an optional main file derived from the packaging, and can have attached files (= with classifier and extension), all using the same GAV.
Dependency Artifact MavenProject
Has dependencies yes no yes
filetype reference type file extension packaging
version ranges yes no no
scope yes no no
attached artifacts no no yes

This implies the following:

  • From dependency to artifact is possible, since you can map a type to an extension (see default dependency types). However, it is not possible to go from artifact back to dependency, there are several types which have jar as file extension for example.
  • There's no such thing as transitive artifacts. Filtering during resolution is based on DependencyFilters, ArtifactFilters can only be applied afterwards, hence are less powerful.

Notice that for historical reasons, Maven internal Artifact API mixes dependency and artifact concepts.