In Avro IDL, how can I import an externally provided schema?

use*_*201 6 idl avro

A simple example illustrates my problem.

In essence, I am working on a large project that has code split across multiple repositories. In repo 1 there is an Avro schema "S1" defined in an .avdl file which gets compiled into its Avro generated class.

In repo 2, which pulls the compiled artifacts of repo 1 in as dependencies, I need to create a new schema that has multiple records and also needs to embed the "S1" schema of repo 1.

在 repo 2 中,我有一个 IDL 文件,其中包含所有 repo 2 架构,但我找不到方法在此 IDL 中包含 repo 1 的架构。我无法导入它,因为在存储库 2 中我无法访问存储库 1 中的架构文件。我确实可以访问存储库 1 中的 Avro 生成的类,但 IDL 似乎不支持引用该类的方法。

我怎样才能做到这一点?如果这在 IDL 中是不可能的,我该如何在 JSON 中做到这一点? - 谢谢!

Dou*_*ing 2

Avro IDL 的 import 语句将首先查找相对于输入文件的指定文件。但如果失败,它会查找 Java 类路径。因此,如果存储库 1 中的 jar 文件包含 IDL 文件,则存储库 2 中的 IDL 文件应该能够通过 jar 文件中的路径导入它。

https://github.com/apache/avro/blob/master/lang/java/compiler/src/main/javacc/org/apache/avro/compiler/idl/idl.jj#L153

这似乎没有记录。请让我知道这对你有没有用。