[
https://issues.apache.org/jira/browse/MNG-8609?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17954571#comment-17954571
]
Elliotte Rusty Harold commented on MNG-8609:
--------------------------------------------
I don't think it's only a documentation problem, though it is a documentation
problem. Most docs, both Maven's own and third party's and most discussions,
have been cavalier about the distinction between dependencies and artifacts.
However after spending multiple years deep in the weeds of Maven dependency
management, I am increasingly convinced that being very precise about this is
absolutely critical to explaining and understanding how Maven works.
Currently package-info says this and it does describe the current class
inheritance structure. However I don't think that inheritance hierarchy is
correct, and it does lead to confusion.
```
* <p>{@link org.apache.maven.api.DependencyCoordinates} instances represent a
dependency element in a POM.
* A {@code DependencyCoordinates} extends {@code ArtifactCoordinates} with
additional information about how
* the artifact will be used: type, scope and obligation (whether the
dependency is optional or mandatory).
* The version and the obligation may not be defined precisely.</p>
*
* <p>{@link org.apache.maven.api.Dependency} instances represent artifacts in
the repository
* that are dependencies of the project.
* They are created when <dfn>resolving</dfn> a {@code DependencyCoordinates}.
* Resolving is the process that clarifies the obligation (optional or
mandatory),
* selects a particular version, and downloads the artifact into the local
repository.</p>
```
This is a classic example of is-a/has-a confusion in OO. It is true currently
that {@link org.apache.maven.api.Dependency} instances represent artifacts in
the repository. However, that shouldn't be the case. Instead something like
"ResolvedDependency" should contain (not inherit from) an Artifact field.
> Dependency is not an Artifact
> -----------------------------
>
> Key: MNG-8609
> URL: https://issues.apache.org/jira/browse/MNG-8609
> Project: Maven
> Issue Type: Bug
> Components: API
> Reporter: Elliotte Rusty Harold
> Priority: Blocker
> Fix For: 4.1.0
>
>
> org.apache.maven.api.Dependency extends org.apache.maven.api.Artifact. This
> violates the OO principal that inheritance represents an is-A relation. A
> dependency is not an artifact. Arguably it has an artifact. However,
> artifacts are nodes in the graph while dependencies are the arcs. These
> aren't the same thing and mixing them up is a common source of confusion.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)