api / org.gradle.api.artifacts.repositories / MavenArtifactRepository

MavenArtifactRepository

interface MavenArtifactRepository : ArtifactRepository, AuthenticationSupported, MetadataSupplierAware

An artifact repository which uses a Maven format to store artifacts and meta-data.

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

Types

MetadataSources

interface MetadataSources

Allows configuring the sources of metadata for a specific repository.

Functions

artifactUrls

abstract fun artifactUrls(vararg urls: Any): Unit

Adds some additional URLs to use to find artifact files. Note that these URLs are not used to find POM files.

The provided values are evaluated as per org.gradle.api.Project#uri(Object). This means, for example, you can pass in a File object, or a relative path to be evaluated relative to the project directory.

getArtifactUrls

abstract fun getArtifactUrls(): MutableSet<URI>

Returns the additional URLs to use to find artifact files. Note that these URLs are not used to find POM files.

getUrl

abstract fun getUrl(): URI

The base URL of this repository. This URL is used to find both POMs and artifact files. You can add additional URLs to use to look for artifact files, such as jars, using .

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.

setArtifactUrls

abstract fun setArtifactUrls(urls: MutableSet<URI>): Unit

Sets the additional URLs to use to find artifact files. Note that these URLs are not used to find POM files.

abstract fun setArtifactUrls(urls: MutableIterable<*>): Unit

Sets the additional URLs to use to find artifact files. Note that these URLs are not used to find POM files.

The provided values are evaluated as per org.gradle.api.Project#uri(Object). This means, for example, you can pass in a File object, or a relative path to be evaluated relative to the project directory.

setUrl

abstract fun setUrl(url: URI): Unit

Sets the base URL of this repository. This URL is used to find both POMs and artifact files. You can add additional URLs to use to look for artifact files, such as jars, using .

abstract fun setUrl(url: Any): Unit

Sets the base URL of this repository. This URL is used to find both POMs and artifact files. You can add additional URLs to use to look for artifact files, such as jars, using .

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 to be evaluated relative to the project directory.

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.

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.

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.