api / org.gradle.api.artifacts.repositories / IvyArtifactRepository

IvyArtifactRepository

interface IvyArtifactRepository : ArtifactRepository, AuthenticationSupported, MetadataSupplierAware

An artifact repository which uses an Ivy format to store artifacts and meta-data.

When used to resolve metadata and artifact files, all available patterns will be searched.

When used to upload metadata and artifact files, only a single, primary pattern will be used:

  1. If a URL is specified via #setUrl(Object) then that URL will be used for upload, combined with the applied #layout(String).
  2. If no URL has been specified but additional patterns have been added via #artifactPattern or #ivyPattern, then the first defined pattern will be used.

Repositories of this type are created by the org.gradle.api.artifacts.dsl.RepositoryHandler#ivy(org.gradle.api.Action) group of methods.

Types

MetadataSources

interface MetadataSources

Allows configuring the sources of metadata for a specific repository.

Properties

GRADLE_ARTIFACT_PATTERN

static val GRADLE_ARTIFACT_PATTERN: String

GRADLE_IVY_PATTERN

static val GRADLE_IVY_PATTERN: String

IVY_ARTIFACT_PATTERN

static val IVY_ARTIFACT_PATTERN: String

MAVEN_ARTIFACT_PATTERN

static val MAVEN_ARTIFACT_PATTERN: String

MAVEN_IVY_PATTERN

static val MAVEN_IVY_PATTERN: String

Functions

artifactPattern

abstract fun artifactPattern(pattern: String): Unit

Adds an independent pattern that will be used to locate artifact files in this repository. This pattern will be used to locate ivy files as well, unless a specific ivy pattern is supplied via #ivyPattern(String). If this pattern is not a fully-qualified URL, it will be interpreted as a file relative to the project directory. It is not interpreted relative the URL specified in #setUrl(Object). Patterns added in this way will be in addition to any layout-based patterns added via #setUrl(Object).

getResolve

abstract fun getResolve(): IvyArtifactRepositoryMetaDataProvider

Returns the meta-data provider used when resolving artifacts from this repository. The provider is responsible for locating and interpreting the meta-data for the modules and artifacts contained in this repository. Using this provider, you can fine tune how this resolution happens.

getUrl

abstract fun getUrl(): URI

The base URL of this repository.

ivyPattern

abstract fun ivyPattern(pattern: String): Unit

Adds an independent pattern that will be used to locate ivy files in this repository. If this pattern is not a fully-qualified URL, it will be interpreted as a file relative to the project directory. It is not interpreted relative the URL specified in #setUrl(Object). Patterns added in this way will be in addition to any layout-based patterns added via #setUrl(Object).

layout

abstract fun layout(layoutName: String): Unit

Specifies the layout to use with this repository, based on the root url. See #layout(String, Closure).

abstract fun layout(layoutName: String, config: Action<out RepositoryLayout>): Unit

Specifies how the items of the repository are organized.

The layout is configured with the supplied closure.

Recognised values are as follows:

'gradle'

A Repository Layout that applies the following patterns:

  • Artifacts: $baseUri/{@value #GRADLE_ARTIFACT_PATTERN}
  • Ivy: $baseUri/{@value #GRADLE_IVY_PATTERN}
'maven'

A Repository Layout that applies the following patterns:

  • Artifacts: $baseUri/{@value #MAVEN_ARTIFACT_PATTERN}
  • Ivy: $baseUri/{@value #MAVEN_IVY_PATTERN}

Following the Maven convention, the 'organisation' value is further processed by replacing '.' with '/'.

'ivy'

A Repository Layout that applies the following patterns:

  • Artifacts: $baseUri/{@value #IVY_ARTIFACT_PATTERN}
  • Ivy: $baseUri/{@value #IVY_ARTIFACT_PATTERN}

Note: this pattern is currently org.gradle.api.Incubating.

'pattern'

A repository layout that allows custom patterns to be defined. eg:

 repositories { ivy { layout 'pattern' , { artifact '[module]/[revision]/[artifact](.[ext])' ivy '[module]/[revision]/ivy.xml' } } } 

The available pattern tokens are listed as part of Ivy's Main Concepts documentation.

abstract fun layout(layoutName: String, config: Closure<Any>): Unit

Specifies how the items of the repository are organized. See #layout(String, org.gradle.api.Action)

metadataSources

abstract fun metadataSources(configureAction: Action<in MetadataSources>): Unit

Configures the metadata sources for this repository. This method will replace any previously configured sources of metadata.

setMetadataSupplier

abstract fun setMetadataSupplier(rule: Class<out ComponentMetadataSupplier>): Unit

Sets a custom metadata rule, which is capable of supplying the metadata of a component (status, status scheme, changing flag) whenever a dynamic version is requested. It can be used to provide metadata directly, instead of having to parse the Ivy descriptor.

abstract fun setMetadataSupplier(rule: Class<out ComponentMetadataSupplier>, configureAction: Action<in ActionConfiguration>): Unit

Sets a custom metadata rule, possibly configuring the rule.

setUrl

abstract fun setUrl(url: URI): Unit

Sets the base URL of this repository.

abstract fun setUrl(url: Any): Unit

Sets the base URL of this repository. The provided value is evaluated as per org.gradle.api.Project#uri(Object). This means, for example, you can pass in a File object or a relative path which is evaluated relative to the project directory. File are resolved based on the supplied URL and the configured #layout(String, Closure) for this repository.

Inherited Functions

authentication

abstract fun authentication(action: Action<in AuthenticationContainer>): Unit

Configures the authentication schemes for this repository.

This method executes the given action against the AuthenticationContainer for this project. The is passed to the closure as the closure's delegate.

If no authentication schemes have been assigned to this repository, a default set of authentication schemes are used based on the repository's transport scheme.

 repositories { maven { url "${url}" authentication { basic(BasicAuthentication) } } } 

Supported authentication scheme types extend org.gradle.authentication.Authentication.

credentials

abstract fun credentials(action: Action<in PasswordCredentials>): Unit

Configures the username and password credentials for this repository using the supplied action.

If no credentials have been assigned to this repository, an empty set of username and password credentials is assigned to this repository and passed to the action.

 repositories { maven { url "${url}" credentials { username = 'joe' password = 'secret' } } } 

abstract fun <T : Credentials> credentials(credentialsType: Class<T>, action: Action<in T>): Unit

Configures the credentials for this repository using the supplied action.

If no credentials have been assigned to this repository, an empty set of credentials of the specified type will be assigned to this repository and given to the configuration action. If credentials have already been specified for this repository, they will be passed to the given configuration action.

 repositories { maven { url "${url}" credentials(AwsCredentials) { accessKey "myAccessKey" secretKey "mySecret" } } } 

The following credential types are currently supported for the credentialsType argument:

  • org.gradle.api.artifacts.repositories.PasswordCredentials
  • org.gradle.api.credentials.AwsCredentials

getAuthentication

abstract fun getAuthentication(): AuthenticationContainer

Returns the authentication schemes for this repository.

getCredentials

abstract fun getCredentials(): PasswordCredentials

Returns the username and password credentials used to authenticate to this repository.

If no credentials have been assigned to this repository, an empty set of username and password credentials is assigned to this repository and returned.

If you are using a different type of credentials than PasswordCredentials, please use #getCredentials(Class) to obtain the credentials.

abstract fun <T : Credentials> getCredentials(credentialsType: Class<T>): T

Returns the credentials of the specified type used to authenticate with this repository.

If no credentials have been assigned to this repository, an empty set of credentials of the specified type is assigned to this repository and returned.

getName

abstract fun getName(): String

Returns the name for this repository. A name must be unique amongst a repository set. A default name is provided for the repository if none is provided.

The name is used in logging output and error reporting to point to information related to this repository.

setComponentVersionsLister

abstract fun setComponentVersionsLister(lister: Class<out ComponentMetadataVersionLister>): Unit
abstract fun setComponentVersionsLister(lister: Class<out ComponentMetadataVersionLister>, configureAction: Action<in ActionConfiguration>): Unit

Sets a custom component versions lister. A versions lister will be called whenever a dynamic version is requested.

setName

abstract fun setName(name: String): Unit

Sets the name for this repository. If this repository is to be added to an org.gradle.api.artifacts.ArtifactRepositoryContainer (including org.gradle.api.artifacts.dsl.RepositoryHandler), its name cannot be changed after it has been added to the container.