I am using avro maven plugin to generate java code for avro .avsc schema file, I have one common schema which is getting used at multiple places as separate record, when i give different namespace at each place, it is able to generate java code, but generated code is in different folders although code for both classes are same
Is there any way to generate only single class for common reference like above schenario... Here is my avsc
{
"namespace": "exmaple.avro",
"type": "record",
"name": "TopRecord",
"fields": [{
"name": "id",
"type": "string"
},
{
"name": "amount",
"type": "double"
},
{
"name": "AC",
"type": {
"type": "record",
"name": "AC_SCHEMA",
"fields": [{
"name": "id",
"type": "string"
},
{
"name": "amount",
"type": "double"
},
{
"name": "InnerCommon",
"type": {
"type": "record",
"name": "InnerSchema",
"fields": [{
"name": "id",
"type": "string"
}]
}
}
]
}
}, {
"name": "BC",
"type": {
"type": "record",
"name": "BC_SCHEMA",
"fields": [{
"name": "id",
"type": "string"
},
{
"name": "amount",
"type": "double"
},
{
"name": "InnerCommon",
"type": {
"type": "record",
"name": "InnerSchema",
"fields": [{
"name": "id",
"type": "string"
}]
}
}
]
}
}
]
}
If i give different namespaces for InnerCommon schema at both placed, it is able to generate code but with classes in 2 folders which have same code :(
Here is working avsc with namespace
{
"namespace": "exmaple.avro",
"type": "record",
"name": "TopRecord",
"fields": [{
"name": "id",
"type": "string"
},
{
"name": "amount",
"type": "double"
},
{
"name": "AC",
"type": {
"type": "record",
"name": "AC_SCHEMA",
"fields": [{
"name": "id",
"type": "string"
},
{
"name": "amount",
"type": "double"
},
{
"name": "InnerCommon",
"type": {
"type": "record",
"name": "InnerSchema",
"namespace": "inner1",
"fields": [{
"name": "id",
"type": "string"
}]
}
}
]
}
}, {
"name": "BC",
"type": {
"type": "record",
"name": "BC_SCHEMA",
"fields": [{
"name": "id",
"type": "string"
},
{
"name": "amount",
"type": "double"
},
{
"name": "InnerCommon",
"type": {
"type": "record",
"name": "InnerSchema",
"namespace": "inner2",
"fields": [{
"name": "id",
"type": "string"
}]
}
}
]
}
}
]
}
Here is the generated folder structure
Is there any way i can put all common generated stuff in single folder and have same namespace to remove duplication?
EDIT 1: I need to register it to schema registry and check for evolution, i was wondering if there is any way to tell plugin not to override generated code and put only one class