Giter VIP home page Giter VIP logo

gradle-s3-plugin's Introduction

Gradle S3 Plugin

This plugin can be used to download files from S3 buckets. You can upload artifacts to S3 as well. The link configuration attribute can be used to create amz-website-redirect-location based redirects. Technically this is not a symbolic link, but it can behave like one when trying to reference same file from multiple locations.

The plugin creates two tasks:

s3Upload

As the name suggests, the s3Upload task can be used to upload a local file to a bucket with a given key name.

s3Download

Similarly, the s3Download task can be used to download a given file from a chosen bucket to a local directory.

The plugin uses a ProfileCredentialsProvider strategy to figure out AWS access and secret key. The name of the credentials profile to use when connecting to AWS can be specified by the awsProfile propterty.

See com.github.skhatri.s3aws.client.S3Client for implementation.

Pull requests are welcome if you want to modify to your needs.

Plugin Configuration in your build.gradle

buildscript {
    dependencies {
        classpath 'com.github.skhatri:gradle-s3-plugin:1.0.0'
        classpath 'joda-time:joda-time:2.3'
    }
    repositories {
        mavenCentral()
    }
}
apply plugin: 's3'

s3 {
    bucket = 'skhatri-bucket'
    awsProfile = 'default'
    upload {
        key =  new org.joda.time.LocalDate().toString('yyyy/MM/dd')+'/gradle-s3-plugin-1.0.0-SNAPSHOT.jar'
        file = '../build/libs/gradle-s3-plugin-1.0.0-SNAPSHOT.jar'
        link = 'latest/gradle-plugin.jar'
    }
    download {
        key = 'latest/gradle-plugin.jar'
        saveTo = 'gradle-pugin.jar'
    }
}


Using Upload Task to upload more artifacts

task uploadAppJar(type: com.github.skhatri.s3aws.plugin.S3UploadTask) {
    key = 'gradle-s3-plugin-1.0.0-something.jar'
    file = '../build/libs/gradle-s3-plugin-master-1.0.1-SNAPSHOT.jar'
    link = 'latest/gradle-plugin.jar'
}

Then I can call "gradle uploadAppJar" to upload yet another artifact to S3.

This can be useful, if uploading hash checksums of the artifacts. For instance, I can upload sha1 value of the artifact so my automated artifact deployment task could download checksum file first to decide whether downloading the big artifact is worth it.

task writeHash() {
    String hashValue = computeHash('../build/libs/gradle-s3-plugin-master-1.0.1-SNAPSHOT.jar')
    file('../build/libs/gradle-s3-plugin-master-1.0.1-SNAPSHOT.sha1').write(hashValue)
}

task uploadHash(type: com.github.skhatri.s3aws.plugin.S3UploadTask) {
    key = 'gradle-s3-plugin-1.0.0-something.sha1'
    file = '../build/libs/gradle-s3-plugin-master-1.0.1-SNAPSHOT.sha1'
    link = 'latest/gradle-plugin.sha1'
}

task awsUpload(dependsOn:['uploadAppJar', 'writeHash', 'uploadHash']) {
}

Now, calling awsUpload will upload jar and the hash file.

Downloading more than one artifact

Similarly, I can download more artifacts by simply creating ad-hoc Download task. I am downloading the previously uploaded sha1 file of the artifact using the task below.

task awsDownload(type: com.github.skhatri.s3aws.plugin.S3DownloadTask) {
    key = 'latest/gradle-plugin.sha1'
    saveTo = 'gradle-plugin.txt'
}

gradle-s3-plugin's People

Contributors

skhatri avatar andershammar avatar dj80hd avatar

Watchers

David Lee avatar James Cloos 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.