• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

myniva/gradle-s3-build-cache: An AWS S3 Gradle build cache implementation

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

myniva/gradle-s3-build-cache

开源软件地址(OpenSource Url):

https://github.com/myniva/gradle-s3-build-cache

开源编程语言(OpenSource Language):

Java 100.0%

开源软件介绍(OpenSource Introduction):

AWS S3 Gradle build cache

Apache License 2.0 GitHub version Build status

This is a custom Gradle build cache implementation which uses AWS S3 to store the cache objects.

Compatibility

  • Version >= 0.3.0 - Gradle 4.x
  • Version < 0.3.0 - Gradle 3.5

Use in your project

Please note that this plugin is not yet ready for production. Feedback though is very welcome. Please open an issue if you find a bug or have an idea for an improvement.

Apply plugin

The Gradle build cache needs to be configured on the Settings level. As a first step, add a dependency to the plugin to your settings.gradle file. Get the latest version from Gradle plugin portal.

buildscript {
  repositories {
    maven {
      url "https://plugins.gradle.org/m2/"
    }
  }
  dependencies {
    classpath "gradle.plugin.ch.myniva.gradle:s3-build-cache:<version>"
  }
}

Configuration

The AWS S3 build cache implementation has a few configuration options:

Configuration Key Description Mandatory Default Value
region The AWS region the S3 bucket is located in. yes
bucket The name of the AWS S3 bucket where cache objects should be stored. yes
path The path under which all cache objects should be stored. no
reducedRedundancy Whether or not to use reduced redundancy. no true
endpoint Alternative S3 compatible endpoint no
headers A map with HTTP headers to be added to each request (nulls are ignored). e.g. [ 'x-header-name': 'header-value' ] no
awsAccessKeyId The AWS access key id no from DefaultAWSCredentialsProviderChain
awsSecretKey The AWS secret key no from DefaultAWSCredentialsProviderChain
sessionToken The AWS sessionToken when you use temporal credentials no from DefaultAWSCredentialsProviderChain

The buildCache configuration block might look like this:

 apply plugin: 'ch.myniva.s3-build-cache'
 
 ext.isCiServer = System.getenv().containsKey("CI")
 
 buildCache {
     local {
         enabled = !isCiServer
     }
     remote(ch.myniva.gradle.caching.s3.AwsS3BuildCache) {
         region = 'eu-west-1'
         bucket = 'your-bucket'
         push = isCiServer
     }
 }

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

AWS credentials

The plugin uses the DefaultAWSCredentialsProviderChain to look up the AWS credentials. If you want to override the credentials feel free to set awsAccessKeyId and awsSecretKey and (optionally depends on configuration) sessionToken. If they are set the plugin will ignore DefaultAWSCredentialsProviderChain.

S3 Bucket Permissions

The AWS credential must have at least the following permissions to the bucket:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
          "s3:PutObject",
          "s3:GetObject",
          "s3:ListBucket"
      ],
      "Resource": [
          "arn:aws:s3:::your-bucket/*",
          "arn:aws:s3:::your-bucket"
      ]
    }
  ]
}

Expiring cache entries

This plugin does not deal with expiring cache entries directly but relies on S3 object lifecycle management to do so. Cache entry expiration rules can be set on S3 buckets using AWS API or via AWS Management Console.

Contributing

Contributions are always welcome! If you'd like to contribute (and we hope you do) please open a pull request.

License

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap