本文整理汇总了Java中org.gradle.caching.BuildCacheEntryWriter类的典型用法代码示例。如果您正苦于以下问题:Java BuildCacheEntryWriter类的具体用法?Java BuildCacheEntryWriter怎么用?Java BuildCacheEntryWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BuildCacheEntryWriter类属于org.gradle.caching包,在下文中一共展示了BuildCacheEntryWriter类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: store
import org.gradle.caching.BuildCacheEntryWriter; //导入依赖的package包/类
@Override
public void store(final BuildCacheKey key, final BuildCacheEntryWriter result) throws BuildCacheException {
persistentCache.useCache("store build cache entry", new Runnable() {
@Override
public void run() {
File file = getFile(key.getHashCode());
try {
Closer closer = Closer.create();
OutputStream output = closer.register(new FileOutputStream(file));
try {
result.writeTo(output);
} finally {
closer.close();
}
} catch (IOException ex) {
throw new UncheckedIOException(ex);
}
}
});
}
示例2: 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);
}
}
示例3: 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);
}
}
示例4: store
import org.gradle.caching.BuildCacheEntryWriter; //导入依赖的package包/类
@Override
public void store(BuildCacheKey key, BuildCacheEntryWriter writer) throws BuildCacheException {
if (stageCacheEntries) {
delegate.store(key, new StagingBuildCacheEntryWriter(writer, temporaryFileProvider));
} else {
delegate.store(key, writer);
}
}
示例5: store
import org.gradle.caching.BuildCacheEntryWriter; //导入依赖的package包/类
@Override
public void store(BuildCacheKey key, BuildCacheEntryWriter writer) throws BuildCacheException {
try {
LOGGER.debug("storing cache key {}", key);
delegate.store(key, writer);
} catch (BuildCacheException e) {
LOGGER.warn("Could not store cache entry for cache key {}", key, e);
throw e;
}
}
示例6: store
import org.gradle.caching.BuildCacheEntryWriter; //导入依赖的package包/类
@Override
public void store(BuildCacheKey key, BuildCacheEntryWriter writer) throws BuildCacheException {
try {
delegate.store(key, writer);
} catch (BuildCacheException e) {
// Assume its OK to not push anything.
}
}
示例7: store
import org.gradle.caching.BuildCacheEntryWriter; //导入依赖的package包/类
@Override
public void store(BuildCacheKey key, BuildCacheEntryWriter writer) throws BuildCacheException {
if (enabled.get()) {
try {
delegate.store(key, writer);
} catch (BuildCacheException e) {
recordFailure();
throw e;
}
}
}
示例8: store
import org.gradle.caching.BuildCacheEntryWriter; //导入依赖的package包/类
@Override
public void store(BuildCacheKey key, final BuildCacheEntryWriter output) throws BuildCacheException {
final URI uri = root.resolve(key.getHashCode());
HttpPut httpPut = new HttpPut(uri);
httpPut.setEntity(new AbstractHttpEntity() {
@Override
public boolean isRepeatable() {
return true;
}
@Override
public long getContentLength() {
return -1;
}
@Override
public InputStream getContent() throws IOException, UnsupportedOperationException {
throw new UnsupportedOperationException();
}
@Override
public void writeTo(OutputStream outstream) throws IOException {
output.writeTo(outstream);
}
@Override
public boolean isStreaming() {
return false;
}
});
CloseableHttpResponse response = null;
try {
response = httpClient.execute(httpPut);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Response for PUT {}: {}", safeUri(uri), response.getStatusLine());
}
// TODO: We should examine the status to make sure the PUT was successful
} catch (IOException e) {
// TODO: We should consider different types of exceptions as fatal/recoverable.
// Right now, everything is considered recoverable.
throw new BuildCacheException(String.format("storing key '%s' in %s", key, getDescription()), e);
} finally {
HttpClientUtils.closeQuietly(response);
}
}
示例9: StagingBuildCacheEntryWriter
import org.gradle.caching.BuildCacheEntryWriter; //导入依赖的package包/类
private StagingBuildCacheEntryWriter(BuildCacheEntryWriter writer, TemporaryFileProvider temporaryFileProvider) {
this.writer = writer;
this.temporaryFileProvider = temporaryFileProvider;
}