API 文档 | AuthenticationSupported |
---|
支持用户名/密码认证的构件仓库。
属性 | 描述 |
authentication | 此仓库的认证方案。 |
credentials | 用于对此仓库进行认证的指定类型的凭据。 |
方法 | 描述 |
authentication(action) | 配置此仓库的认证方案。 |
credentials(credentialsType) | 配置此仓库将由构建提供的凭据。 |
credentials(credentialsType, action) | 使用提供的动作配置此仓库的凭据。 |
credentials(action) | 使用提供的动作配置此仓库的用户名和密码凭据。 |
AuthenticationContainer
authentication
(只读)
此仓库的认证方案。
void
authentication
(Action
<? super AuthenticationContainer
>
action)
Action
<? super AuthenticationContainer
>配置此仓库的认证方案。
此方法针对此项目的 AuthenticationContainer
执行给定动作。AuthenticationContainer
作为闭包的委托传递给闭包。
如果未为此仓库分配任何认证方案,则将根据仓库的传输方案使用默认认证方案集。
repositories {
maven {
url = "https://example.com/m2"
authentication {
basic(BasicAuthentication)
}
}
}
支持的认证方案类型扩展 Authentication
。
void
credentials
(Class
<? extends Credentials
>
credentialsType)
Class
<? extends Credentials
>配置此仓库将由构建提供的凭据。
凭据将根据仓库名称从 Gradle 属性中提供。如果无法解析此仓库的凭据,并且该仓库将在当前构建中使用,则构建将无法启动并指向缺失的配置。
repositories {
maven {
url = "https://example.com/m2"
credentials(PasswordCredentials)
}
}
目前 credentialsType
参数支持以下凭据类型
使用提供的动作配置此仓库的凭据。
如果未为此仓库分配任何凭据,则将为此仓库分配指定类型的空凭据集,并将其提供给配置动作。如果已为此仓库指定凭据,则这些凭据将传递给给定配置动作。
repositories { maven { url = "https://example.com/aws/proxy" credentials(AwsCredentials) { accessKey = "myAccessKey" secretKey = "mySecret" } } }
目前 credentialsType
参数支持以下凭据类型
void
credentials
(Action
<? super PasswordCredentials
>
action)
Action
<? super PasswordCredentials
>使用提供的动作配置此仓库的用户名和密码凭据。
如果未为此仓库分配任何凭据,则将为此仓库分配空用户名和密码凭据集,并将其传递给动作。
repositories { maven { url = "https://example.com/m2" credentials { username = 'joe' password = 'secret' } } }