Skip to content

Dependency Graph Design

Elliotte Rusty Harold edited this page Jan 22, 2020 · 16 revisions

Definitions

Artifact: an artifact is a resource in the Maven repository system that has Maven coordinates. An artifact has a name, Maven coordinates, and a sequence of bytes. It is often instantiated as a file or a Web resource. However, the absolute and relative paths to the file, the created and modified times of the file, and other file system metadata are not part of the artifact. Furthermore, the same artifact can exist in many files and many file systems at the same time. Two copies of a resource with the same name, Maven coordinates, and bytes in two different repositories are the same artifact. An artifact does not have dependencies.

Maven Coordinates: Maven coordinates are a colon separated string that uniquely identifies a Maven artifact. The exact syntax of the coordinates are defined by the Maven Project's POM reference. Maven coordinates contain up to five colon separated parts:

  • Group ID
  • Artifact ID
  • Version
  • Classifier
  • Packaging

Two strings that are character by character identical identify the same artifact. Furthermore the classifier and packaging have the default values of the empty string and "jar" respectively if they're omitted.

Dependency

Project

Dependency Graph

Dependency Tree: there is no such thing. A Maven dependency graph is not a tree. It can and more often than not does contain cycles.

Classpath: an ordered list of jar files, zip files, and directories, each of which contains Java class files. Maven-repository-based Build tools such as Maven, Gradle, and Ivy use different algorithms to convert a dependency graph into a classpath. That is, there is not a unique classpath for each dependency graph. javac and the Java virtual machine only read the classpath and do not consider the dependency graph.

Library Design (not yet implemented)

This is how we model the above concepts.

Artifacts are represented by the Aether Artifact class.

Dependencies are represented by the Dependency class.

Dependency graphs are represented by the DependencyGraph class.

Instead of producing a pure classpath, we produce an annotated classpath. This is an ordered list of jar files, the same as Maven or Gradle would produce. However in our data structure each node in the list is annotated with its Maven coordinates and with a pointer to the corresponding Dependency node in the graph.

Clone this wiki locally