How to use the default AWS credentials chain for an S3 backed Maven repository in a Gradle build?

后端 未结 3 1183
轮回少年
轮回少年 2021-02-14 13:39

According to Gradle documention (Example 50.27), we can use S3 backed Maven repositories with Gradle 2.4. However, the only example given in the docs passes explicit AWS credent

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-14 14:09

    Untested, but I would try:

    buildscript { 
        repositories { 
            mavenCentral() 
        } 
    
        dependencies { 
            classpath 'com.amazonaws:aws-java-sdk:1.10.58' 
        } 
    }
    
    import com.amazonaws.auth.DefaultAWSCredentialsProviderChain
    
    repositories {
        maven {
            url "s3://someS3Bucket/maven2"
            credentials(AwsCredentials) {
    
                def defaultCredentials = new DefaultAWSCredentialsProviderChain().getCredentials()
                accessKey defaultCredentials.getAWSAccessKeyId()
                secretKey defaultCredentials.getAWSSecretKey()
            }
        }
    }
    

提交回复
热议问题