El Cattivo
El Cattivo

Reputation: 73

Split Apache Avro Schemas in several files while having several goals in the avro-maven-plugin

I want to split up my avro schema files. For generating the source code, I use the avro-maven-plugin. I followed this post:

Can I split an Apache Avro schema across multiple files?

It works fine, but in my case I want to have different goals and then I get an error message about [ERROR] Failed to execute goal org.apache.avro:avro-maven-plugin:1.8.2:protocol (schemas) on project AvroTestProject: Execution schemas of goal org.apache.avro:avro-maven-plugin:1.8.2:protocol failed: No protocol name specified: ... since my imported file is only a schema and not a protocol.

Here is the snippet of my pom.xml:

        <plugin>
            <groupId>org.apache.avro</groupId>
            <artifactId>avro-maven-plugin</artifactId>
            <version>${avro.version}</version>
            <executions>
                <execution>
                    <id>schemas</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>schema</goal>
                        <goal>protocol</goal>
                        <goal>idl-protocol</goal>
                    </goals>
                    <configuration>
                        <sourceDirectory>${project.basedir}/src/avro/</sourceDirectory>
                        <outputDirectory>${project.basedir}/src/</outputDirectory>
                        <imports>
                            <import>${project.basedir}/src/avro/TestSchema.avsc</import>
                        </imports>
                    </configuration>
                </execution>
            </executions>
        </plugin>

Is there a way to declare the import only for a certain goal? Or are there other possibilities to solve this problem?

Upvotes: 3

Views: 2379

Answers (1)

Vlad Krava
Vlad Krava

Reputation: 21

The problem is your goals definition in avro-maven-plugin. Thus, consider setting only schema goal to avoid execution of protocol and idl-protocol as it is conflicting with declaration of a schema in imports block.

Upvotes: 2

Related Questions