I am using the avro-maven-plugin inside a quarkus project:
<plugin>
<groupId>org.apache.avro</groupId>
<artifactId>avro-maven-plugin</artifactId>
<version>1.11.3</version>
<configuration>
...
</configuration>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>schema</goal>
</goals>
<configuration>
<includes>
<include>**/*.avsc</include>
</includes>
<imports>
<import>A.avsc</import>
<import>B.avsc</import>
</imports>
</configuration>
</execution>
</executions>
</plugin>
The question is about the imports section in the plugin. The documentation says that the imported files should not reference eachother, however in my case both file A and B need to be imported and B references A.
As far as I understand, this is not possible and fails with:
[ERROR] Failed to execute goal io.quarkus.platform:quarkus-maven-plugin:3.6.6:dev (default-cli) on project : Unable to execute mojo: Execution null of goal org.apache.avro:avro-maven-plugin:1.11.3:schema failed: Can't redefine: -> [Help 1]
Is there any workaround?
Check if you are using the quarkus-maven-plugin
with the generate-code
goal. In such a case, building with maven compile will work (as you have described), since only the plugin and the configuration you defined will be used. Using quarkus:dev
with the above-mentioned generate-code
goal will also start compiling Avro files, but without your import configurations, since another plugin is used.
Since you are using Quarkus, I suggest utilizing their way of Avro schema generation. In this case, you will need to list imports in your Quarkus config file under avro.codegen.avsc.imports
. More info in
Quarkus documentation about tweaking avro code gen ;)