use of org.gradle.internal.serialize.kryo.KryoBackedEncoder in project gradle by gradle.
the class DefaultScriptCompilationHandler method serializeMetadata.
private <M> void serializeMetadata(ScriptSource scriptSource, CompileOperation<M> extractingTransformer, File metadataDir, boolean emptyScript, boolean hasMethods) {
File metadataFile = new File(metadataDir, METADATA_FILE_NAME);
try {
GFileUtils.mkdirs(metadataDir);
try (KryoBackedEncoder encoder = new KryoBackedEncoder(new FileOutputStream(metadataFile))) {
byte flags = (byte) ((emptyScript ? EMPTY_FLAG : 0) | (hasMethods ? HAS_METHODS_FLAG : 0));
encoder.writeByte(flags);
if (extractingTransformer != null && extractingTransformer.getDataSerializer() != null) {
Serializer<M> serializer = extractingTransformer.getDataSerializer();
serializer.write(encoder, extractingTransformer.getExtractedData());
}
}
} catch (Exception e) {
throw new GradleException(String.format("Failed to serialize script metadata extracted for %s", scriptSource.getDisplayName()), e);
}
}
Aggregations