-
Notifications
You must be signed in to change notification settings - Fork 78
Dependency Graph Design
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 is 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.
Project Coordinates: Project coordinates are a colon separated string that uniquely identifies a Maven project. The exact syntax of the coordinates is defined by the Maven Project's POM reference. Project coordinates contain exactly three colon separated strings:
- Group ID
- Artifact ID
- Version
Two strings that are character by character identical identify the same project.
Maven artifacts belong to the project that has same Group ID, Artifact ID, and version the artifact has.
Dependency
Project: a Maven project is defined by a pom.xml file. It has a single group ID, artifact ID, and version. It contains zero or more dependencies of the project. It also contains one or more artifacts. Most projects contain a single artifact. However a project can use different classifiers and packaging types to produce multiple artifacts.
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.
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.