Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import org.apache.avro.Protocol;
import org.apache.avro.compiler.idl.Idl;
import org.apache.avro.compiler.idl.ParseException;
import org.apache.avro.compiler.specific.ProtocolTask;
import org.apache.avro.compiler.specific.SpecificCompiler;
import org.apache.tools.ant.BuildException;
import java.io.File;
import java.io.IOException;
public class IdlTask extends ProtocolTask {
@Override
protected void doCompile(File src, File dir) throws IOException {
Idl parser = new Idl(src);
try {
Protocol protocol = parser.CompilationUnit();
SpecificCompiler compiler = new SpecificCompiler(protocol);
compiler.setStringType(getStringType());
compiler.compileToDestination(src, dir);
} catch (ParseException e) {
throw new BuildException(e);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment