title: Maven plugin for Java POJO to Avro schema via reflection
body: <p>As per the answer in <a href="https://stackoverflow.com/questions/22954315/generate-avro-schema-from-certain-java-object#">Generate Avro Schema from certain Java Object</a>, it's possible to use Reflection to convert from a Java POJO to an Avro schema. </p>
  
  <p>One could manually do something along the lines of:</p>
  
  <pre><code>Schema schema = ReflectData.get().getSchema(POJO.class);
  File schemaFile = new File("pojo-reflected.avsc");
  FileWriter fileWriter = new FileWriter(schemaFile);
  fileWriter.append(schema.toString(true));
  fileWriter.close();
  </code></pre>
  
  <p>But does anyone know of any plugins that have the capability to do this? The confluent schema registry plugin doesn't provide any relevant functionality, and while there is an avro maven plugin, it seems to be more so geared towards the inverse: generating Java code from schemas rather than vice versa. </p>
  
  <p>I could probably hack together a solution along the lines of the answer in <a href="https://stackoverflow.com/questions/2147115/generating-sources-by-running-a-projects-java-class-in-maven">Generating sources by running a project&#39;s java class in Maven</a> and use a Java class to generate the schemas, but I feel like a plugin would be cleaner. </p>