blob: 25a4091d711fa405990675f6cff079ab6b4145bb [file] [log] [blame]
-----
Comparison: Dependency vs Artifact vs MavenProject
-----
Robert Scholte
-----
2015-12-28
-----
~~ Licensed to the Apache Software Foundation (ASF) under one
~~ or more contributor license agreements. See the NOTICE file
~~ distributed with this work for additional information
~~ regarding copyright ownership. The ASF licenses this file
~~ to you under the Apache License, Version 2.0 (the
~~ "License"); you may not use this file except in compliance
~~ with the License. You may obtain a copy of the License at
~~
~~ http://www.apache.org/licenses/LICENSE-2.0
~~
~~ Unless required by applicable law or agreed to in writing,
~~ software distributed under the License is distributed on an
~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~~ KIND, either express or implied. See the License for the
~~ specific language governing permissions and limitations
~~ under the License.
~~ NOTE: For help with the syntax of this file, see:
~~ http://maven.apache.org/doxia/references/apt-format.html
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 {{{/ref/current/maven-model/maven.html#class_dependency}}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 | {{{/ref/current/maven-core/artifact-handlers.html}}type} | file extension | packaging |
*--------------------+-------------+----------------+---------------+
| version ranges | 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.
However, it is not possible to go from artifact back to dependency, there are several types which have jar as file extension.
* There's no such thing as transitive artifacts. Filtering during resolution is based on DependencyFilters,
ArtifactFilters can only be applied afterwards, hence are less efficient.