Get AWS credentials for S3 maven repos from default AWS credentials provider chain
Gradle now supports S3 maven repos out-of-the-box:
- Official Documentation
- Blog post: Using an AWS S3 Bucket as your Maven repository in a Gradle project
-
Add this plugin to your project, see https://plugins.gradle.org/plugin/com.github.kaklakariada.awsm-credentials-gradle
plugins { id "com.github.kaklakariada.awsm-credentials-gradle" version "0.2.1" }
-
Configure your AWS credentials as named profiles in
~/.aws/credentials(not in~/.aws/config). Userole_arnandsource_profilefor role delegation:[root-credentials] aws_access_key_id = ... aws_secret_access_key = ... [delegate-account1] role_arn = arn:aws:iam::<account>:role/<role name> source_profile = root-credentials [delegate-account2] role_arn = arn:aws:iam::<account>:role/<role name> source_profile = root-credentials
-
Configure the AWS profile you want to use in
~/.gradle/gradle.properties:systemProp.aws.profile = delegate-account1 -
Add S3 maven repositories without specifying credentials. The plugin will automatically add credentials for repositories with
s3://urls in all projects.
-
Dependency repositories:
repositories { maven { url "s3://bucket/path/to/repo" } }
-
Publishing repositories:
plugins { id "maven-publish" } publishing { repositories { maven { url "s3://bucket/path/to/repo" } } publications { // ... } }
$ git clone https://github.com/hamstercommunity/awsm-credentials-gradle.gitImport into eclipse using buildship plugin:
- Select File > Import... > Gradle > Gradle Project
- Click "Next"
- Select Project root directory
- Click "Finish"
$ ./gradlew licenseFormatMain licenseFormatTestPublish to plugins.gradle.org
See https://plugins.gradle.org/docs/submit for details.
-
Add API Key from https://plugins.gradle.org to
~/.gradle/gradle.properties:gradle.publish.key = ... gradle.publish.secret = ... -
Run
./gradlew publishPlugins