本文整理汇总了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);
}
}
示例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);
}
}