簡體   English   中英

在 Gradle Kotlin DSL 中為 S3 Maven 存儲庫使用 IAM 憑證

[英]Use IAM credentials for S3 Maven Repository in Gradle Kotlin DSL

我已經按照此處的說明配置了 S3 支持的 Maven 存儲庫,例如:

repositories {
    maven {
        url "s3://myCompanyBucket/maven2"
        authentication {
           awsIm(AwsImAuthentication) // load from EC2 role or env var
        }
    }
}

我正在嘗試將我的腳本轉換為使用 Kotlin DSL 而不是 groovy,但無法找出等效的代碼,特別是對於authentication部分。

上面 Groovy 代碼段的等效 Kotlin DSL 是什么?

我只是設法通過以下方式配置了 HttpHeaderAuthentication:

maven {
    credentials(HttpHeaderCredentials::class.java) {
        name = "Private-Token"
        value = "xxxxxxx"
    }
    authentication {
        val header by registering(HttpHeaderAuthentication::class)
    }
    url = uri("https://xxxxxxxx/")
}

所以我想你的應該是這樣的

repositories {
  maven {
    url = uri("s3://myCompanyBucket/maven2")
    authentication {
       val awsIm by registering(AwsImAuthentication::class) // load from EC2 role or env var
    }
  }
}

HTH

我能夠讓它像這樣工作:

maven {
    url = uri("s3://$repoBucketName/release")
    authentication {
        register("awsIm", AwsImAuthentication::class)
    }
}

至少沒有來自未使用變量的警告。 =)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM