api / org.gradle.api.artifacts

Package org.gradle.api.artifacts

Types

ArtifactCollection

interface ArtifactCollection : MutableIterable<ResolvedArtifactResult>

A collection of artifacts resolved for a configuration. The configuration is resolved on demand when the collection is queried.

ArtifactIdentifier

interface ArtifactIdentifier

The identifier for a module artifact.

ArtifactRepositoryContainer

interface ArtifactRepositoryContainer : NamedDomainObjectList<ArtifactRepository>, Configurable

A ResolverContainer is responsible for managing a set of ArtifactRepository instances. Repositories are arranged in a sequence.

You can obtain a ResolverContainer instance by calling org.gradle.api.Project#getRepositories() or using the repositories property in your build script.

The resolvers in a container are accessible as read-only properties of the container, using the name of the resolver as the property name. For example:

 repositories.maven { name 'myResolver' } repositories.myResolver.url = 'some-url' 

A dynamic method is added for each resolver which takes a configuration closure. This is equivalent to calling #getByName(String, groovy.lang.Closure). For example:

 repositories.maven { name 'myResolver' } repositories.myResolver { url 'some-url' } 

ArtifactView

interface ArtifactView : HasAttributes

A view over the artifacts resolved for this set of dependencies. By default, the view returns all files and artifacts, but this can be restricted by component identifier or by attributes.

ClientModule

interface ClientModule : ExternalModuleDependency

To model a module in your dependency declarations. Usually you can either declare a single dependency artifact or you declare a module dependency that depends on a module descriptor in a repository. With a client module you can declare a module dependency without the need of a module descriptor in a remote repository.

ComponentMetadata

interface ComponentMetadata : HasAttributes

Provides a read-only view of a resolved component's metadata, which typically originates from a component descriptor (Ivy file, Maven POM).

ComponentMetadataBuilder

interface ComponentMetadataBuilder

A component metadata builder.

ComponentMetadataContext

interface ComponentMetadataContext

Provides access to compoment metadata from a ComponentMetadataRule.

ComponentMetadataDetails

interface ComponentMetadataDetails : ComponentMetadata, HasConfigurableAttributes<ComponentMetadataDetails>

Describes a resolved component's metadata, which typically originates from a component descriptor (Ivy file, Maven POM). Some parts of the metadata can be changed via metadata rules (see org.gradle.api.artifacts.dsl.ComponentMetadataHandler.

ComponentMetadataListerDetails

interface ComponentMetadataListerDetails

Allows a custom version lister to specify the list of versions known for a specific module.

ComponentMetadataRule

interface ComponentMetadataRule : Action<ComponentMetadataContext>

A rule that modify ComponentMetadataDetails.

ComponentMetadataSupplier

interface ComponentMetadataSupplier : Action<ComponentMetadataSupplierDetails>

A component metadata rule is responsible for providing the initial metadata of a component from a remote repository, in place of parsing the descriptor. Users may implement a provider to make dependency resolution faster.

ComponentMetadataSupplierDetails

interface ComponentMetadataSupplierDetails

A component metadata rule details, giving access to the identifier of the component being resolved, the metadata builder, and the repository resource accessor for this.

ComponentMetadataVersionLister

interface ComponentMetadataVersionLister : Action<ComponentMetadataListerDetails>

Interface for custom version listers. A version lister is reponsible for returning the list of versions of a module which are available in a specific repository. For this, Gradle is going to call the lister once for each module it needs the list of versions. This will typically happen in case a dynamic version is requested, in which case we need to know the list of versions published for this module. It will not, however, be called for fixed version numbers.

ComponentModuleMetadata

interface ComponentModuleMetadata

Contains immutable component module metadata information.

ComponentModuleMetadataDetails

interface ComponentModuleMetadataDetails : ComponentModuleMetadata

Contains and allows configuring component module metadata information. For information and examples please see org.gradle.api.artifacts.dsl.ComponentModuleMetadataHandler

ComponentSelection

interface ComponentSelection

* Represents a tuple of the component selector of a module and a candidate version to be evaluated in a component selection rule.

ComponentSelectionRules

interface ComponentSelectionRules

* Represents a container for component selection rules. Rules can be applied as part of the resolutionStrategy of a configuration and individual components can be explicitly accepted or rejected by rule. Components that are neither accepted or rejected will be subject to the default version matching strategies.

 configurations { conf { resolutionStrategy { componentSelection { all { ComponentSelection selection -> if (selection.candidate.module == 'someModule' && selection.candidate.version == '1.1') { selection.reject("bad version '1.1' for 'someModule'") } } all { ComponentSelection selection, IvyModuleDescriptor descriptor, ComponentMetadata metadata -> if (selection.candidate.module == 'someModule' && descriptor.branch == 'testing') { if (metadata.status != 'milestone') { selection.reject("only use milestones for someModule:testing") } } } withModule("org.sample:api") { ComponentSelection selection -> if (selection.candidate.version == "1.1") { selection.reject("known bad version") } } } } } } 

ConfigurablePublishArtifact

interface ConfigurablePublishArtifact : PublishArtifact

A PublishArtifact whose properties can be modified.

Configuration

interface Configuration : FileCollection, HasConfigurableAttributes<Configuration>

A Configuration represents a group of artifacts and their dependencies. Find more information about declaring dependencies to a configuration or about managing configurations in docs for ConfigurationContainer

Configuration is an instance of a FileCollection that contains all dependencies (see also #getAllDependencies()) but not artifacts. If you want to refer to the artifacts declared in this configuration please use #getArtifacts() or #getAllArtifacts(). Read more about declaring artifacts in the configuration in docs for org.gradle.api.artifacts.dsl.ArtifactHandler Please see the Managing Dependency Configurations User Guide chapter for more information.

ConfigurationContainer

interface ConfigurationContainer : NamedDomainObjectContainer<Configuration>

A ConfigurationContainer is responsible for declaring and managing configurations. See also Configuration.

You can obtain a ConfigurationContainer instance by calling org.gradle.api.Project#getConfigurations(), or using the configurations property in your build script.

The configurations in a container are accessible as read-only properties of the container, using the name of the configuration as the property name. For example:

 configurations.create('myConfiguration') configurations.myConfiguration.transitive = false 

A dynamic method is added for each configuration which takes a configuration closure. This is equivalent to calling #getByName(String, groovy.lang.Closure). For example:

 configurations.create('myConfiguration') configurations.myConfiguration { transitive = false } 
Examples An example showing how to refer to a given configuration by name in order to get hold of all dependencies (e.g. jars, but only)
 apply plugin: 'java' //so that I can use 'compile' configuration //copying all dependencies attached to 'compile' into a specific folder task copyAllDependencies(type: Copy) { //referring to the 'compile' configuration from configurations.compile into 'allLibs' } 
An example showing how to declare and configure configurations
 apply plugin: 'java' //so that I can use 'compile', 'testCompile' configurations configurations { //adding a configuration: myConfiguration //adding a configuration that extends existing configuration: //(testCompile was added by the java plugin) myIntegrationTestsCompile.extendsFrom(testCompile) //configuring existing configurations not to put transitive dependencies on the compile classpath //this way you can avoid issues with implicit dependencies to transitive libraries compile.transitive = false testCompile.transitive = false } 
Examples on configuring the resolution strategy - see docs for ResolutionStrategy Please see the Managing Dependency Configurations User Guide chapter for more information.

ConfigurationPublications

interface ConfigurationPublications : HasConfigurableAttributes<ConfigurationPublications>

Represents the outgoing artifacts associated with a configuration. These artifacts are used when the configuration is referenced during dependency resolution.

You can use this interface associate artifacts with a configuration using the #artifact(Object) methods. You can also define several variants of the configuration's artifacts. Each variant represents a set of artifacts that form some mutually exclusive usage of the component.

An implicit variant is defined for a configuration whenever any artifacts are attached directly to this object or inherited from another configuration.

ConfigurationVariant

interface ConfigurationVariant : Named, HasConfigurableAttributes<ConfigurationVariant>

Represents some variant of an outgoing configuration.

DependenciesMetadata

interface DependenciesMetadata<T : DependencyMetadata<DependencyMetadata<*>>> : MutableCollection<T>

Describes metadata about a dependency - direct dependencies or dependency constraints - declared in a resolved component's metadata.

Dependency

interface Dependency

A Dependency represents a dependency on the artifacts from a particular source. A source can be an Ivy module, a Maven POM, another Gradle project, a collection of Files, etc... A source can have zero or more artifacts.

DependencyArtifact

interface DependencyArtifact

An Artifact represents an artifact included in a org.gradle.api.artifacts.Dependency.

An artifact is an (immutable) value object.

DependencyConstraint

interface DependencyConstraint : ModuleVersionSelector, HasConfigurableAttributes<DependencyConstraint>

Represents a constraints over all, including transitive, dependencies.

DependencyConstraintMetadata

interface DependencyConstraintMetadata : DependencyMetadata<DependencyConstraintMetadata>

Describes a dependency constraint declared in a resolved component's metadata, which typically originates from a component descriptor (Gradle metadata file). This interface can be used to adjust a dependency constraint's properties via metadata rules (see org.gradle.api.artifacts.dsl.ComponentMetadataHandler.

DependencyConstraintSet

interface DependencyConstraintSet : DomainObjectSet<DependencyConstraint>

A set of dependency constraint definitions that are associated with a configuration.

DependencyConstraintsMetadata

interface DependencyConstraintsMetadata : DependenciesMetadata<DependencyConstraintMetadata>

Describes the dependency constraints of a variant declared in a resolved component's metadata, which typically originate from a component descriptor (Gradle metadata file). This interface can be used to adjust the dependencies of a published component via metadata rules (see org.gradle.api.artifacts.dsl.ComponentMetadataHandler.

DependencyMetadata

interface DependencyMetadata<SELF : DependencyMetadata<DependencyMetadata<*>>>

Describes a metadata about a dependency - direct dependency or dependency constraint - declared in a resolved component's metadata.

DependencyResolutionListener

interface DependencyResolutionListener

A DependencyResolutionListener is notified as dependencies are resolved.

DependencyResolveDetails

interface DependencyResolveDetails

Provides details about a dependency when it is resolved. Provides means to manipulate dependency metadata when it is resolved.

DependencySet

interface DependencySet : DomainObjectSet<Dependency>, Buildable

A set of artifact dependencies.

DependencySubstitution

interface DependencySubstitution

Provides means to substitute a different dependency during resolution.

DependencySubstitutions

interface DependencySubstitutions

Allows replacing dependencies with other dependencies.

DirectDependenciesMetadata

interface DirectDependenciesMetadata : DependenciesMetadata<DirectDependencyMetadata>

Describes the dependencies of a variant declared in a resolved component's metadata, which typically originate from a component descriptor (Gradle metadata file, Ivy file, Maven POM). This interface can be used to adjust the dependencies of a published component via metadata rules (see org.gradle.api.artifacts.dsl.ComponentMetadataHandler.

DirectDependencyMetadata

interface DirectDependencyMetadata : DependencyMetadata<DirectDependencyMetadata>

Describes a dependency declared in a resolved component's metadata, which typically originates from a component descriptor (Gradle metadata file, Ivy file, Maven POM). This interface can be used to adjust a dependency's properties via metadata rules (see org.gradle.api.artifacts.dsl.ComponentMetadataHandler.

ExcludeRule

interface ExcludeRule

An ExcludeRule is used to describe transitive dependencies that should be excluded when resolving dependencies.

ExcludeRuleContainer

interface ExcludeRuleContainer

A container for adding exclude rules for dependencies.

ExternalDependency

interface ExternalDependency : ModuleDependency, ModuleVersionSelector

An ExternalDependency is a Dependency on a source outside the current project hierarchy.

ExternalModuleDependency

interface ExternalModuleDependency : ExternalDependency

A ModuleDependency is a Dependency on a module outside the current project hierarchy.

FileCollectionDependency

interface FileCollectionDependency : SelfResolvingDependency

A FileCollectionDependency is a Dependency on a collection of local files which are not stored in a repository.

LenientConfiguration

interface LenientConfiguration

Resolved configuration that does not fail eagerly when some dependencies are not resolved, or some artifacts do not exist.

ModuleDependency

interface ModuleDependency : Dependency, HasConfigurableAttributes<ModuleDependency>

A ModuleDependency is a org.gradle.api.artifacts.Dependency on a module outside the current project.

For examples on configuring the exclude rules please refer to #exclude(java.util.Map).

ModuleIdentifier

interface ModuleIdentifier : Serializable

The identifier of a module.

ModuleVersionIdentifier

interface ModuleVersionIdentifier : Serializable

The identifier of a module version.

ModuleVersionSelector

interface ModuleVersionSelector

Selects a module version. If you need to change this interface, you're probably doing it wrong: it is superceded by org.gradle.api.artifacts.component.ModuleComponentSelector, so check this first, and only add methods here if it's for bridging.

MutableVersionConstraint

interface MutableVersionConstraint : VersionConstraint

A configurable version constraint. This is exposed to the build author, so that one can express more constraints on a version,

ProjectDependency

interface ProjectDependency : ModuleDependency, SelfResolvingDependency

A ProjectDependency is a Dependency on another project in the current project hierarchy.

PublishArtifact

interface PublishArtifact : Buildable

A PublishArtifact is an artifact produced by a project.

PublishArtifactSet

interface PublishArtifactSet : DomainObjectSet<PublishArtifact>, Buildable

A set of artifacts to be published.

ResolutionStrategy

interface ResolutionStrategy

Defines the strategies around dependency resolution. For example, forcing certain dependency versions, substitutions, conflict resolutions or snapshot timeouts.

Examples:

 apply plugin: 'java' //so that there are some configurations configurations.all { resolutionStrategy { // fail eagerly on version conflict (includes transitive dependencies) // e.g. multiple different versions of the same dependency (group and name are equal) failOnVersionConflict() // prefer modules that are part of this build (multi-project or composite build) over external modules preferProjectModules() // force certain versions of dependencies (including transitive) // *append new forced modules: force 'asm:asm-all:3.3.1', 'commons-io:commons-io:1.4' // *replace existing forced modules with new ones: forcedModules = ['asm:asm-all:3.3.1'] // add dependency substitution rules dependencySubstitution { substitute module('org.gradle:api') with project(':api') substitute project(':util') with module('org.gradle:util:3.0') } // cache dynamic versions for 10 minutes cacheDynamicVersionsFor 10*60, 'seconds' // don't cache changing modules at all cacheChangingModulesFor 0, 'seconds' } } 

ResolvableDependencies

interface ResolvableDependencies : ArtifactView

A set of Dependency objects which can be resolved to a set of files. There are various methods on this type that you can use to get the result in different forms:

  • #getFiles() returns a FileCollection that provides the result as a set of java.io.File instances.
  • #getResolutionResult() returns a ResolutionResult that provides information about the dependency graph.
  • #getArtifacts() returns an ArtifactCollection that provides the files with additional metadata.

The dependencies are resolved once only, when the result is first requested. The result is reused and returned for subsequent calls. Once resolved, any mutation to the dependencies will result in an error.

ResolveException

open class ResolveException : DefaultMultiCauseException

A ResolveException is thrown when dependency resolution fails for some reason.

ResolvedArtifact

interface ResolvedArtifact

Information about a resolved artifact.

ResolvedConfiguration

interface ResolvedConfiguration

A ResolvedConfiguration represents the result of resolving a Configuration, and provides access to both the artifacts and the meta-data of the result.

ResolvedDependency

interface ResolvedDependency

Information about a resolved dependency.

ResolvedModuleVersion

interface ResolvedModuleVersion

Represents meta-data about a resolved module version.

SelfResolvingDependency

interface SelfResolvingDependency : Dependency, Buildable

A SelfResolvingDependency is a Dependency which is able to resolve itself, independent of a repository.

UnresolvedDependency

interface UnresolvedDependency

Unsuccessfully resolved dependency.

VariantMetadata

interface VariantMetadata : HasConfigurableAttributes<VariantMetadata>

Represents the metadata of one variant of a component, see ComponentMetadataDetails#withVariant(String, Action).

VersionConstraint

interface VersionConstraint

Represents a constrained version. By default, when a dependency has a version number, it is assumed that the version can be upgraded during conflict resolution (typically, version 1.15 can be upgraded to 1.16). However in some cases we don't want this behavior. This class represents the base spec of module constraints.

Annotations

CacheableRule

class CacheableRule

Denotates a rule which execution is subject to caching.

Exceptions

PublishException

open class PublishException : GradleException

A PublishException is thrown when a dependency configuration cannot be published for some reason.

UnknownConfigurationException

open class UnknownConfigurationException : UnknownDomainObjectException

An UnknownConfigurationException is thrown when a configuration referenced by name cannot be found.

UnknownRepositoryException

open class UnknownRepositoryException : UnknownDomainObjectException

An UnknownRepositoryException is thrown when a repository referenced by name cannot be found.