AuthenticationSupported

一個支援使用者名稱/密碼驗證的 Artifact 倉庫。

屬性

屬性描述
authentication

此倉庫的驗證方案。

credentials

用於向此倉庫進行驗證的指定類型憑證。

方法

方法描述
authentication(action)

配置此倉庫的驗證方案。

credentials(credentialsType)

配置此倉庫的憑證,這些憑證將由建置提供。

credentials(credentialsType, action)

使用提供的 action 配置此倉庫的憑證。

credentials(action)

使用提供的 action 配置此倉庫的使用者名稱和密碼憑證。

腳本區塊

沒有腳本區塊

屬性詳細資訊

AuthenticationContainer authentication (唯讀)

此倉庫的驗證方案。

T credentials (唯讀)

用於向此倉庫進行驗證的指定類型憑證。

如果沒有憑證被指派給此倉庫,則會將指定類型的空憑證集指派給此倉庫並傳回。

方法詳細資訊

void authentication(Action<? super AuthenticationContainer> action)

配置此倉庫的驗證方案。

此方法針對此專案的 AuthenticationContainer 執行給定的 action。 AuthenticationContainer 作為 closure 的委派傳遞給 closure。

如果沒有驗證方案被指派給此倉庫,則會根據倉庫的傳輸方案使用預設的驗證方案集。

repositories {
    maven {
        url = "https://example.com/m2"
        authentication {
            basic(BasicAuthentication)
        }
    }
}

支援的驗證方案類型擴展了 Authentication

void credentials(Class<? extends Credentials> credentialsType)

配置此倉庫的憑證,這些憑證將由建置提供。

憑證將從基於倉庫名稱的 Gradle 屬性中提供。如果無法解析此倉庫的憑證,並且該倉庫將在當前建置中使用,則建置將無法啟動並指向遺失的配置。

repositories {
    maven {
        url = "https://example.com/m2"
        credentials(PasswordCredentials)
    }
}

目前 credentialsType 參數支援以下憑證類型

void credentials(Class<T> credentialsType, Action<? super T> action)

使用提供的 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 配置此倉庫的使用者名稱和密碼憑證。

如果沒有憑證被指派給此倉庫,則會將一組空的使用者名稱和密碼憑證指派給此倉庫,並傳遞給 action。

repositories {
    maven {
        url = "https://example.com/m2"
        credentials {
            username = 'joe'
            password = 'secret'
        }
    }
}