Skip to content

Latest commit

 

History

History
108 lines (80 loc) · 6.43 KB

README.md

File metadata and controls

108 lines (80 loc) · 6.43 KB

Gradle S3 Build Cache

Build download GitHub license kotlin version codebeat badge

Makes use of the Gradle build cache and stores build artifacts in AWS S3 bucket.

Usage

Apply plugin

settings.gradle

buildscript {
  repositories {
    mavenCentral()
  }
  dependencies {
    classpath "com.talk2duck:gradle-s3-build-cache:1.6.0.1"
  }
}

apply plugin: 'com.talk2duck.gradle-s3-build-cache'

ext.isCiServer = System.getenv().containsKey("CI")
 
buildCache {
  local {
    enabled = !isCiServer
  }
  remote(com.talk2duck.gradle.buildcache.S3BuildCache) {
    region = '<your region>'
    bucket = '<your bucket name>'
    push = isCiServer
  }
}

Configuration

Configuration Key Type Description Mandatory Default Value
awsAccessKeyId String The AWS access key id Using the Default Credential Provider Chain
awsSecretKey String The AWS secret access key Using the Default Credential Provider Chain
awsProfile String The AWS profile to source credentials from Using the Default Credential Provider Chain
sessionToken String The AWS sessionToken Using the Default Credential Provider Chain
region String The AWS region yes
bucket String The name of the AWS S3 bucket where cache objects should be stored. yes
prefix String The prefix of the AWS S3 object key in the bucket cache/
endpoint String The S3 endpoint
reducedRedundancyStorage boolean Whether to use Reduced Redundancy Storage or not true

AWS credentials

By default, this plugin uses Default Credential Provider Chain to lookup the AWS credentials.
See Using the Default Credential Provider Chain - AWS SDK for Java for more details.

You can also select which profile to use for AWS authentication by specifying awsProfile.
See Configuring the AWS CLI - Named profiles for more details.

If you want to set access key id and secret access key manually, configure awsAccessKeyId and awsSecretKey (and sessionToken optionally).

S3 Bucket Policy

The AWS credential must have at least the following permissions to the bucket:

{
  "Version": "2020-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
          "s3:PutObject",
          "s3:GetObject",
          "s3:ListBucket"
      ],
      "Resource": [
          "arn:aws:s3:::your-bucket/*",
          "arn:aws:s3:::your-bucket"
      ]
    }
  ]
}

Run build with build cache

The Gradle build cache is an incubating feature and needs to be enabled per build (--build-cache) or in the Gradle properties (org.gradle.caching=true). See the official doc for details.

Versioning

This project uses explicit versioning Release.Breaking.Feature.Fix as described here.

License

Apache License 2.0