This is the gradle task for synchronizing a local directory with a AWS S3 bucket and vice-versa.
This task depends on JetS3t, a open-source Java toolkit for AWS.
Situation - upload
This task assumes the case, for example, a web site would be published in a AWS S3 bucket.
Usage - upload
// Gradle Script
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "com.monochromeroad.gradle-plugins:gradle-aws-s3-sync:0.10"
}
}
import com.monochromeroad.gradle.plugin.aws.s3.S3Sync
task deploy(type: S3Sync){
description = "Deploys my site on a s3 bucket."
accessKey awsAccessKey
secretKey awsSecretKey
configFile "jets3t.properties"
mimeTypesFile "my-mime.types"
from "local-site"
into "my.bucket.name/subdirectory-optional"
}
Situation - download
This task assumes the case, for example, a set of files has to be fetched from an S3 bucket to a local directory.
Usage - download
// Gradle Script
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "com.monochromeroad.gradle-plugins:gradle-aws-s3-sync:0.10"
}
}
import com.monochromeroad.gradle.plugin.aws.s3.S3Sync
task deploy(type: S3Sync){
description = "Downloads files from s3 bucket to a local directory"
accessKey awsAccessKey
secretKey awsSecretKey
configFile "jets3t.properties"
// follows the jets3t conventions for action names
action = 'DOWN'
from "my.bucket.name/subdirectory-optional"
from "local-site"
}
Options
Name * required | Description | Default Value |
---|---|---|
* accessKey() | AWS Access Key | - |
* secretKey() | AWS Secret Key | - |
* from() | The local directory which would be synchronized with the S3 bucket | - |
* into() | The S3 bucket name which would be synchronized with the local directory. If needed, some sub directory could be added. (e.g. buc.ket/sub.d) | - |
configFile() | JetS3t properties file path. Interpreted relative to the project directory, as for project.file() method. | - See also: JetS3t's Default |
mimeTypesFile() | Mime types file path for determing Mime type on deploying to S3. Interpreted relative to the project directory, as for project.file() method. | - See also: Default |
quiet() | JetS3t option -q | false |
noProgress() | JetS3t option -n | false |
force() | JetS3t option -f | false |
keepFiles() | JetS3t option -k | false |
noDelete() | JetS3t option -d | false |
moveEnabled() | JetS3t option -m | false |
batchMode() | JetS3t option -b | false |
gzipEnabled() | JetS3t option -g | false |
encryptionEnabled() | JetS3t option -c | false |
acl() | JetS3t option --acl, from enum "ACL" | com.monochromeroad.gradle.plugin.aws.s3.ACL.Private |
reportLevel(ReportLevel) | JetS3t option --reportlevel, from enum "ReportLevel" | com.monochromeroad.gradle.plugin.aws.s3.ReportLevel.All |
action() | Either 'UP' for uploading into S3 or 'DOWN' for downloading from S3. | UP |