Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use IAM credentials for S3 Maven Repository in Gradle Kotlin DSL

I've configured an S3 backed Maven repository per the instructions here, eg:

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

I am trying to convert my script to use the Kotlin DSL instead of groovy, but can't figure out the equivalent code, specifically for the authentication portion.

What is the equivalent Kotlin DSL for the Groovy snippet above?

like image 565
AwesomeTown Avatar asked Dec 30 '25 04:12

AwesomeTown


1 Answers

I just managed to configure a HttpHeaderAuthentication through the following:

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

So I guess yours should be something like

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

HTH

like image 179
Luc Boutier Avatar answered Jan 01 '26 23:01

Luc Boutier



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!