Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2015 the original author or authors.
*
* 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.
*/
package org.gradle.launcher.daemon.protocol;
import org.gradle.api.logging.LogLevel;
import org.gradle.internal.logging.events.OperationIdentifier;
import org.gradle.internal.logging.text.StyledTextOutput;
import org.gradle.internal.logging.events.*;
import org.gradle.internal.serialize.*;
import java.util.List;
public class DaemonMessageSerializer {
public static Serializer create() {
BaseSerializerFactory factory = new BaseSerializerFactory();
Serializer logLevelSerializer = factory.getSerializerFor(LogLevel.class);
Serializer throwableSerializer = factory.getSerializerFor(Throwable.class);
DefaultSerializerRegistry registry = new DefaultSerializerRegistry();
registry.register(BuildEvent.class, new BuildEventSerializer());
registry.register(Failure.class, new FailureSerializer(throwableSerializer));
// Input events
registry.register(ForwardInput.class, new ForwardInputSerializer());
registry.register(CloseInput.class, new CloseInputSerializer());
// Output events
registry.register(LogEvent.class, new LogEventSerializer(logLevelSerializer, throwableSerializer));
registry.register(StyledTextOutputEvent.class, new StyledTextOutputEventSerializer(logLevelSerializer, new ListSerializer(new SpanSerializer(factory.getSerializerFor(StyledTextOutput.Style.class)))));
registry.register(ProgressStartEvent.class, new ProgressStartEventSerializer());
registry.register(ProgressCompleteEvent.class, new ProgressCompleteEventSerializer());
registry.register(ProgressEvent.class, new ProgressEventSerializer());
registry.register(LogLevelChangeEvent.class, new LogLevelChangeEventSerializer(logLevelSerializer));
registry.register(OutputMessage.class, new OutputMessageSerializer(registry.build(OutputEvent.class)));
// Default for everything else
registry.useJavaSerialization(Message.class);
return registry.build(Message.class);
}
private static class FailureSerializer implements Serializer {
private final Serializer throwableSerializer;
public FailureSerializer(Serializer throwableSerializer) {
this.throwableSerializer = throwableSerializer;
}
@Override
public void write(Encoder encoder, Failure failure) throws Exception {
throwableSerializer.write(encoder, failure.getValue());
}
@Override
public Failure read(Decoder decoder) throws Exception {
return new Failure(throwableSerializer.read(decoder));
}
}
private static class BuildEventSerializer implements Serializer {
private final Serializer