| API 文档 | AuthenticationSupported |
|---|
支持用户名/密码认证的artifact仓库。
| 属性 | 描述 |
authentication | 此仓库的认证方案。 |
credentials | 用于此仓库认证的指定类型的凭据。 |
| 方法 | 描述 |
authentication(action) | 配置此仓库的认证方案。 |
credentials(credentialsType) | 配置此仓库将由构建提供的凭据。 |
credentials(credentialsType, action) | 使用提供的action配置此仓库的凭据。 |
credentials(action) | 使用提供的action配置此仓库的用户名和密码凭据。 |
AuthenticationContainer authentication (只读)
此仓库的认证方案。
void authentication(Action<? super AuthenticationContainer> action)
Action<? super AuthenticationContainer>配置此仓库的认证方案。
此方法针对此项目的AuthenticationContainer执行给定的action。此AuthenticationContainer作为action的委托传递给闭包。
如果此仓库未分配认证方案,则会根据仓库的传输方案使用一组默认认证方案。
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参数目前支持以下凭据类型:
使用提供的action配置此仓库的凭据。
如果此仓库未分配凭据,则将指定类型的一组空凭据分配给此仓库,并将其传递给配置action。如果此仓库已指定凭据,则将其传递给给定的配置action。
repositories {
maven {
url = "https://example.com/aws/proxy"
credentials(AwsCredentials) {
accessKey = "myAccessKey"
secretKey = "mySecret"
}
}
}
credentialsType参数目前支持以下凭据类型:
void credentials(Action<? super PasswordCredentials> action)
Action<? super PasswordCredentials>使用提供的action配置此仓库的用户名和密码凭据。
如果此仓库未分配凭据,则将一组空的用户名和密码凭据分配给此仓库并传递给action。
repositories {
maven {
url = "https://example.com/m2"
credentials {
username = 'joe'
password = 'secret'
}
}
}