GithubHelp home page GithubHelp logo

gcp-gradle-build-cache's Introduction

GCP backed Gradle Remote Cache

An implementation of the Gradle Remote Cache that's backed by Google Cloud Storage buckets.

Using the plugin

In your settings.gradle.kts file add the following

plugins {
    id("androidx.build.gradle.gcpbuildcache") version "1.0.0-beta01"
}

import androidx.build.gradle.gcpbuildcache.GcpBuildCache
import androidx.build.gradle.gcpbuildcache.GcpBuildCacheServiceFactory
import androidx.build.gradle.gcpbuildcache.ExportedKeyGcpCredentials

buildCache {
    registerBuildCacheService(GcpBuildCache::class, GcpBuildCacheServiceFactory::class)
    remote(GcpBuildCache::class) {
        projectId = "foo"
        bucketName = "bar"
        credentials = ExportedKeyGcpCredentials(File("path/to/credentials.json"))
        isPush = inCi
    }
}
  • projectId, bucketName are required
  • credentials defaults to ApplicationDefaultGcpCredentials, but can also be set to ExportedKeyGcpCredentials
  • isPush defaults to false.

If you are using Groovy, then you should do the following:

plugins {
    id("androidx.build.gradle.gcpbuildcache") version "1.0.0-beta01"
}

import androidx.build.gradle.gcpbuildcache.GcpBuildCache
import androidx.build.gradle.gcpbuildcache.GcpBuildCacheServiceFactory
import androidx.build.gradle.gcpbuildcache.ExportedKeyGcpCredentials

buildCache {
    registerBuildCacheService(GcpBuildCache, GcpBuildCacheServiceFactory)
    remote(GcpBuildCache) {
        projectId = "projectName"
        bucketName = "storageBucketName"
        credentials = new ExportedKeyGcpCredentials(new File("path/to/credentials.json"))
        push = inCi
    }
}

Setting up Google Cloud Platform project

  1. Install gcloud CLI on your machine
  2. Create a GCP project YOUR-GCP-PROJECT and set up billing.
  3. Create a Google Cloud Storage bucket
gsutil mb โ€“p YOUR-GCP-PROJECT gs://YOUR-BUCKET-NAME
  1. Create IAM roles for read and read/write
gcloud iam roles create CacheReadWrite --project=YOUR-GCP-PROJECT --title=CacheReadWrite --description="Have access to read and write to remote Gradle cache" --permissions=storage.buckets.get,storage.objects.create,storage.objects.delete,storage.objects.get,storage.objects.getIamPolicy,storage.objects.list
gcloud iam roles create CacheRead --project=YOUR-GCP-PROJECT --title=CacheRead --description="Have access to read from remote Gradle cache" --permissions=storage.buckets.get,storage.objects.get,storage.objects.getIamPolicy,storage.objects.list
  1. Create IAM Service Accounts
gcloud iam service-accounts create cache-read-write  --project=YOUR-GCP-PROJECT
gcloud iam service-accounts create cache-read  --project=YOUR-GCP-PROJECT
  1. Grant the service account roles that we just created
gcloud projects add-iam-policy-binding YOUR-GCP-PROJECT --member=serviceAccount:[email protected] --role=projects/YOUR-GCP-PROJECT/roles/CacheRead
gcloud projects add-iam-policy-binding YOUR-GCP-PROJECT --member=serviceAccount:[email protected] --role=projects/YOUR-GCP-PROJECT/roles/CacheReadWrite
  1. Use YOUR-GCP-PROJECT and YOUR-BUCKET-NAME in the plugin configuration with exported service account credentials.

gcp-gradle-build-cache's People

Contributors

liutikas avatar tikurahul avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.