Skip to content

Instantly share code, notes, and snippets.

@hasghari
Created June 30, 2012 19:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hasghari/3025179 to your computer and use it in GitHub Desktop.
Save hasghari/3025179 to your computer and use it in GitHub Desktop.
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