当前位置: 首页>>代码示例>>Java>>正文


Java BuildCacheEntryWriter.writeTo方法代码示例

本文整理汇总了Java中org.gradle.caching.BuildCacheEntryWriter.writeTo方法的典型用法代码示例。如果您正苦于以下问题:Java BuildCacheEntryWriter.writeTo方法的具体用法?Java BuildCacheEntryWriter.writeTo怎么用?Java BuildCacheEntryWriter.writeTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.gradle.caching.BuildCacheEntryWriter的用法示例。


在下文中一共展示了BuildCacheEntryWriter.writeTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: store

import org.gradle.caching.BuildCacheEntryWriter; //导入方法依赖的package包/类
@Override
public void store(BuildCacheKey key, BuildCacheEntryWriter writer) {
  logger.info("Start storing cache entry '{}' in S3 bucket", key.getHashCode());
  ObjectMetadata meta = new ObjectMetadata();
  meta.setContentType(BUILD_CACHE_CONTENT_TYPE);

  try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
    writer.writeTo(os);
    meta.setContentLength(os.size());
    try (InputStream is = new ByteArrayInputStream(os.toByteArray())) {
        PutObjectRequest request = getPutObjectRequest(key, meta, is);
        if(this.reducedRedundancy) {
          request.withStorageClass(StorageClass.ReducedRedundancy);
        }
        s3.putObject(request);
    }
  } catch (IOException e) {
    throw new BuildCacheException("Error while storing cache object in S3 bucket", e);
  }
}
 
开发者ID:myniva,项目名称:gradle-s3-build-cache,代码行数:21,代码来源:AwsS3BuildCacheService.java

示例2: store

import org.gradle.caching.BuildCacheEntryWriter; //导入方法依赖的package包/类
@Override
public void store(BuildCacheKey buildCacheKey, BuildCacheEntryWriter buildCacheEntryWriter)
    throws BuildCacheException {
  Blob blob = cloudStorage.get(cacheKeyToBlobId(buildCacheKey));
  if (blob == null || !blob.exists()) {
    blob =
        cloudStorage.create(
            BlobInfo.newBuilder(cacheKeyToBlobId(buildCacheKey))
                .setContentType(BUILD_CACHE_CONTENT_TYPE)
                .build());
  }
  try (OutputStream os = Channels.newOutputStream(blob.writer())) {
    buildCacheEntryWriter.writeTo(os);
  } catch (IOException e) {
    throw new UncheckedIOException("Error writing file from cloud storage.", e);
  }
}
 
开发者ID:curioswitch,项目名称:curiostack,代码行数:18,代码来源:CloudStorageBuildCacheService.java


注:本文中的org.gradle.caching.BuildCacheEntryWriter.writeTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。