Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to invoke avro-maven plugin

My question is similar to Unable to compile and create .avro file from .avsc using Maven

I have tried all possible things, checked the maven project 100 times, still i am not able to run the avro-maven plugin to generate the code for my avsc file.

i have read the following posts and followed the same, but to no success http://grepalex.com/2013/05/24/avro-maven/ https://github.com/phunt/avro-maven-plugin

i downloaded the above maven project, and here also the result is same.

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Avro Maven Example 0.0.1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ avro-maven ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ avro-maven ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory F:\01_Work\FLink\avro-maven-master\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ avro-maven ---
[INFO] No sources to compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.932 s
[INFO] Finished at: 2015-08-10T19:16:44+05:30
[INFO] Final Memory: 6M/16M
[INFO] ------------------------------------------------------------------------

But no generated code.

I strongly feel Maven is my mortal enemy and i will never be able to do any work with apache projects just because i cannot get maven to work. perhaps i should consider going back to saner world of C/C++ where it doesnt require an internet connection to compile my source.

like image 392
weima Avatar asked Oct 30 '22 21:10

weima


2 Answers

That eclipse error in pom file doesn't matters. Make sure that your .avsc file has namespace value, where actual file is getting generated.

{
"namespace": "com.hadoop.practice.avro",
"type": "record",
"name": "StringPair",
"doc": "A pair of strings",
"fields": [
    {"name": "left", "type": "string"},
    {"name": "right", "type": "string"}
]

}

StringPair.java get generated under this namespace defined package

like image 118
NGR Avatar answered Nov 10 '22 04:11

NGR


I publish a simple demo which is fully tested and 100% works https://github.com/xmeng1/avro-maven-demo. There are two important things for generating code by using the Avro

  1. The configuration: if we want to generate code when mvn compile or mvn package, we can put configuration under the execution. If we want to generate code when running goal mvn avro:scheme, we need put the configuration to the plugin directly. (the demo includes two type configuration)
  2. The namespace of the scheme file which will decide which package the generate code will belong to. {"namespace": "com.xx.xx.demo", "name": "Foo"}, the Foo.java will be created under the package com.xx.xx.demo
like image 30
Xin Meng Avatar answered Nov 10 '22 04:11

Xin Meng