Skip to content

kordamp/oci-gradle-build-cache-plugin

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

oci-gradle-build-cache-plugin

ASL2 Licensed Build Status Gradle Plugin Portal, link=


This is a custom Gradle build cache implementation which uses the Oracle Cloud to store the cache objects.

Warning
This plugin is not endorsed by Oracle nor does the company provide any support for it.

Prerequisites

  1. An Oracle Cloud account. Sign up for an Always Free tier account at http://oracle.com/cloud/free.

  2. A resource compartment. It’s recommended to use a compartment different from the default root.

  3. Setup an Object Lifecycle Policy on the compartment. Refer to https://docs.cloud.oracle.com/iaas/Content/Object/Tasks/usinglifecyclepolicies.htm

Gradle 6.x and Java 8 are the minimum requirements to run this plugin.

Usage

Add the following to your settings.gradle file

buildscript {
    repositories {
        jcenter()
        gradlePluginPortal()
    }
    dependencies {
        classpath 'org.kordamp.gradle:oci-gradle-build-cache-plugin:0.6.0'
    }
}

apply plugin: 'org.kordamp.gradle.oci-build-cache'

Configuration

Add the following to your settings.gradle file

ext.isCiServer = System.getenv().containsKey('CI')

buildCache {
    local {
        enabled = !isCiServer
    }
    remote(org.kordamp.gradle.plugin.buildcache.OCIBuildCache) {
        compartmentId = <compartment-id>
        push = isCiServer
    }
}

The plugin offers the following configuration properties

Configuration Key Description Mandatory Default Value

configFile

Location of the config file

no

~/.oci/config

profile

Name of the OCI profile to use

no

DEFAULT

compartmentId

Compartment that owns the bucket

yes

bucket

Bucket name

no

build-cache

policy

Object lifecycle policy (DELETE)

no

amount: 30L, unit: days

The default object lifecycle policy is to delete cached items after 30 days. You can change these defaults with the following snippet

settings.gradle
buildCache {
    local {
        enabled = !isCiServer
    }
    remote(org.kordamp.gradle.plugin.buildcache.OCIBuildCache) {
        compartmentId = <compartment-id>
        push = isCiServer
        policy {
            amount = 90L // 3 months
        }
    }
}

You can configure authentication in two ways:

  1. Using the standard configuration file, typically located at ~/.oci/config.

  2. Defining a config block on the remote block.

Standard Config File

The format of the configuration file is specified at this page, it looks something similar to

~/.oci/config
[DEFAULT]
user=ocid1.user.oc1...
tenancy=ocid1.tenancy.oc1...
region=eu-frankfurt-1
key_file=~/.oci/oci_api_key.pem
pass_phrase=<secret>
fingerprint=f9:14:d0:...

Config Block

Alternatively you may define a config block. This block defines properties that match settings found on the config file

settings.gradle
buildCache {
    local {
        enabled = !isCiServer
    }
    remote(org.kordamp.gradle.plugin.buildcache.OCIBuildCache) {
        compartmentId = <compartment-id>
        bucket = <bucket-name>
        push = isCiServer
        config {
            userId      = 'ocid1.user.oc1...'
            tenantId    = 'ocid1.tenancy.oc1...'
            region      = 'eu-frankfurt-1'
            keyfile     = '~/.oci/oci_api_key.pem'
            passphrase  = '<secret>'
            fingerprint = 'f9:14:d0:...'
        }
    }
}

More details about configuring the Gradle build cache can be found in the official Gradle documentation.