I have two schemas,
a.avsc
{
"namespace": "my.ns",
"type": "record",
"name": "A",
"fields": [
{
"name": "b",
"type": "my.ns.B"
}
]
}
b.avsc
{
"namespace": "my.ns",
"type": "record",
"name": "B",
"fields": [
]
}
This throws an exception:
[ERROR] Failed to execute goal org.apache.avro:avro-maven-plugin:1.10.2:schema (default) on project schema:
Execution default of goal org.apache.avro:avro-maven-plugin:1.10.2:schema failed:
"my.ns.B" is not a defined name. The type of the "b" field must be a defined name or a {"type": ...} expression. -> [Help 1]
If I put them both in the same file, it works though. But B has to be declared first.
[
{
"namespace": "my.ns",
"type": "record",
"name": "B",
"fields": [
]
},
{
"namespace": "my.ns",
"type": "record",
"name": "A",
"fields": [
{
"name": "b",
"type": "my.ns.B"
}
]
}
]
My maven plugin is setup like:
<plugin>
<groupId>org.apache.avro</groupId>
<artifactId>avro-maven-plugin</artifactId>
<version>${avro.version}</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>schema</goal>
</goals>
<configuration>
<sourceDirectory>${project.basedir}/src/main/avro/
</sourceDirectory>
<outputDirectory>${project.basedir}/target/generated-sources/main/java/
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>