api / org.gradle.api.artifacts.repositories / AuthenticationSupported

AuthenticationSupported

interface AuthenticationSupported

An artifact repository which supports username/password authentication.

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.

Inheritors

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.

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.