This addon provides classes for use in other addons. The dependencies addon provides APIs and services for interacting with artifact repositories, artifact dependencies, and dependency metadata. This is typically for the purpose of resolving project libraries and other resources. The dependencies addon provides an abstract API for interacting with an artifact repository.
This addon requires the following installation steps.
To use this addon, you must add it as a dependency in the pom.xml of your forge-addon
classified artifact:
<dependency> <groupId>org.jboss.forge.addon</groupId> <artifactId>dependencies</artifactId> <classifier>forge-addon</classifier> <version>${version}</version> </dependency>
- Abstraction of Dependency Repository systems
-
The dependencies addon provides a layer of abstraction over native repository systems such as maven, ivy, or even osgi and java module repositories. This does not mean that all repositories will be compatible via this API; however, it does mean that methods of interacting with each repository are standardized and consistent.
- DependencyResolver service for dependency resolution
-
The
DependencyResolver
service interface is provided (not implemented) by the dependencies addon, so that other addons may provide implementations. Addons depending on the dependencies addon may then request service instances of theDependencyResolver
and either select a specific resolver, or iterate over the results until a resolver is capable of handling the givenDependencyQuery
.@Inject private DependencyResolver resolver; ... Set<Dependency> dependencies = resolver.resolveDependencies(...); DependencyMetadata metadata = resolver.resolveDependencyMetadata(...);
TipIf your addon uses a container that does not support "@Inject" annotations, services such as the
DependencyResolver
may also be accessed via theAddonRegistry
:AddonRegistry registry = ... Imported<DependencyResolver> imported = registry.getServices(DependencyResolver.class); for(ExportedInstance<DependencyResolver> instance : imported) { DependencyResolver resolver = instance.get(); }
- Comprehensive dependency query API
-
The dependency resolution functions of the dependencies addon functions primarily using the
DependencyQuery
API, with the fluentDependencyQueryBuilder
used to specify query criteria.DependencyQueryBuilder.create(CoordinateBuilder.create() .setGroupId("org.jboss.forge.furnace") .setArtifactId("furnace")) .setFilter(...) .setRepositories(...) .setScopeType(...)
- Consistent programming experience
-
Because the dependencies API provides a consistent set of interfaces for interacting with artifact repositories, it is used in a number of addons and should be considered the standard approach for interacting with artifact and dependency repositories.