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. |
-
An Oracle Cloud account. Sign up for an Always Free tier account at http://oracle.com/cloud/free.
-
A resource compartment. It’s recommended to use a compartment different from the default
root
. -
Setup an Object Lifecycle Policy on the compartment. Refer to https://docs.cloud.oracle.com/iaas/Content/Object/Tasks/usinglifecyclepolicies.htm
Gradle 8.x and Java 11 are the minimum requirements to run this plugin.
Add the following to your settings.gradle
file
buildscript {
repositories {
mavenCentral()
gradlePluginPortal()
}
dependencies {
classpath 'org.kordamp.gradle:oci-gradle-build-cache-plugin:0.10.0'
}
}
apply plugin: 'org.kordamp.gradle.oci-build-cache'
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 |
failOnError |
Fail the build on config error |
no |
true |
The default object lifecycle policy is to delete cached items after 30 days. You can change these defaults with the following snippet
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:
-
Using the standard configuration file, typically located at
~/.oci/config
. -
Defining a
config
block on theremote
block.
The format of the configuration file is specified at this page, it looks something similar to
[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:...
Alternatively you may define a config
block. This block defines properties that match settings found on the config file
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.