'Apache Avro maven plugin seems to be ignoring config

I am using apache avro maven plugin with the aim of generating java from avsc. I am running this on an m1 mac(though i didn't see anything online about that being an issue).

The issue appears to be that my config is not picked up. The code generation seems to work with the defaults. for example

Its looking for the avsc in.

Failed to execute goal org.apache.avro:avro-maven-plugin:1.10.2:schema (default-cli) on project falc-proxy: neither sourceDirectory: /Users/pdhulipala/falc-proxy/src/main/avro or testSourceDirectory: /Users/pdhulipala/falc-proxy/src/test/avro are directories

With the plugin details defined as below.

<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/resources/avro/</sourceDirectory>
                            <outputDirectory>${project.basedir}/src/main/resources/java/</outputDirectory>
                            <imports>
                                <import>${project.basedir}/src/main/resources/avro/MsgHeader.avsc</import>
                                <import>${project.basedir}/src/main/resources/avro/Request.avsc</import>
                            </imports>
                            <includes>
                                <include>*.avsc</include>
                            </includes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

Wondering if there is anyway to debug this/add logging etc.



Solution 1:[1]

Problem solved. Just move the configuration block directly under the plugin one. It seams that when you want to generate the code with mvn package the configuration block must be under the execution tag while when you want to generate the code running directly the goal avro:schema the configuration block must be directly under the plugin block. If you want to perform both operations you have to duplicate your configuration block. Check the following example...

https://github.com/xmeng1/avro-maven-demo/blob/master/pom.xml

Solution 2:[2]

I fixed this issue by moving the configuration section to the same level as the executions tag. Now I'm able to generate the schemas with the plugin. This is my configuration:

<plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>${project.parent.version}</version>
        </plugin>
        <plugin>
            <groupId>org.apache.avro</groupId>
            <artifactId>avro-maven-plugin</artifactId>
            <version>1.11.0</version>
            <executions>
                <execution>
                    <phase>none</phase>
                    <!-- <phase>generate-sources</phase>-->
                    <goals>
                        <goal>schema</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <createSetters>false</createSetters>
                <sourceDirectory>${project.basedir}/src/main/resources/avro/</sourceDirectory>
                <outputDirectory>${project.basedir}/src/main/java/</outputDirectory>
                <fieldVisibility>PRIVATE</fieldVisibility>
                <stringType>String</stringType>
            </configuration>
        </plugin>
    </plugins>

Solution 3:[3]

I have the same problem. The pom.xml is similar...

<plugin>
                <groupId>org.apache.avro</groupId>
                <artifactId>avro-maven-plugin</artifactId>
                <version>1.10.2</version>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>schema</goal>
                        </goals>
                        <configuration>
                            <sourceDirectory>/home/andrea.gioia/Sviluppi/playground/kafka/kafka-spring/src/main/resources/avro/it/quantyca/kafka/spring/demo</sourceDirectory>
                            <outputDirectory>/home/andrea.gioia/Sviluppi/playground/kafka/kafka-spring/target/generated-src</outputDirectory>
                            <imports>
                                <import>${project.basedir}/src/main/resources/avro/it/quantyca/kafka/spring/demo/hobbit.avsc</import>
                            </imports>
                            <includes>
                                <include>*.avsc</include>
                            </includes>
                            <stringType>String</stringType>
                        </configuration>
                    </execution>
                </executions>

To debug you can execute the following command from terminal...

mvn -X avro:schema

In my case the output is the following ...

andrea.gioia@AGIOIA:~/Sviluppi/playground/kafka/kafka-spring$ mvn -X avro:schema
Apache Maven 3.6.3
Maven home: /usr/share/maven
Java version: 11.0.11, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.11.0-25-generic", arch: "amd64", family: "unix"
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/usr/share/maven/lib/guice.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[DEBUG] Created new class realm maven.api
[DEBUG] Importing foreign packages into class realm maven.api
[DEBUG]   Imported: javax.annotation.* < plexus.core
[DEBUG]   Imported: javax.annotation.security.* < plexus.core
[DEBUG]   Imported: javax.enterprise.inject.* < plexus.core
[DEBUG]   Imported: javax.enterprise.util.* < plexus.core
[DEBUG]   Imported: javax.inject.* < plexus.core
[DEBUG]   Imported: org.apache.maven.* < plexus.core
[DEBUG]   Imported: org.apache.maven.artifact < plexus.core
[DEBUG]   Imported: org.apache.maven.classrealm < plexus.core
[DEBUG]   Imported: org.apache.maven.cli < plexus.core
[DEBUG]   Imported: org.apache.maven.configuration < plexus.core
[DEBUG]   Imported: org.apache.maven.exception < plexus.core
[DEBUG]   Imported: org.apache.maven.execution < plexus.core
[DEBUG]   Imported: org.apache.maven.execution.scope < plexus.core
[DEBUG]   Imported: org.apache.maven.lifecycle < plexus.core
[DEBUG]   Imported: org.apache.maven.model < plexus.core
[DEBUG]   Imported: org.apache.maven.monitor < plexus.core
[DEBUG]   Imported: org.apache.maven.plugin < plexus.core
[DEBUG]   Imported: org.apache.maven.profiles < plexus.core
[DEBUG]   Imported: org.apache.maven.project < plexus.core
[DEBUG]   Imported: org.apache.maven.reporting < plexus.core
[DEBUG]   Imported: org.apache.maven.repository < plexus.core
[DEBUG]   Imported: org.apache.maven.rtinfo < plexus.core
[DEBUG]   Imported: org.apache.maven.settings < plexus.core
[DEBUG]   Imported: org.apache.maven.toolchain < plexus.core
[DEBUG]   Imported: org.apache.maven.usability < plexus.core
[DEBUG]   Imported: org.apache.maven.wagon.* < plexus.core
[DEBUG]   Imported: org.apache.maven.wagon.authentication < plexus.core
[DEBUG]   Imported: org.apache.maven.wagon.authorization < plexus.core
[DEBUG]   Imported: org.apache.maven.wagon.events < plexus.core
[DEBUG]   Imported: org.apache.maven.wagon.observers < plexus.core
[DEBUG]   Imported: org.apache.maven.wagon.proxy < plexus.core
[DEBUG]   Imported: org.apache.maven.wagon.repository < plexus.core
[DEBUG]   Imported: org.apache.maven.wagon.resource < plexus.core
[DEBUG]   Imported: org.codehaus.classworlds < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.* < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.classworlds < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.component < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.configuration < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.container < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.context < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.lifecycle < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.logging < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.personality < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.util.xml.Xpp3Dom < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.util.xml.pull.XmlPullParser < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.util.xml.pull.XmlPullParserException < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.util.xml.pull.XmlSerializer < plexus.core
[DEBUG]   Imported: org.eclipse.aether.* < plexus.core
[DEBUG]   Imported: org.eclipse.aether.artifact < plexus.core
[DEBUG]   Imported: org.eclipse.aether.collection < plexus.core
[DEBUG]   Imported: org.eclipse.aether.deployment < plexus.core
[DEBUG]   Imported: org.eclipse.aether.graph < plexus.core
[DEBUG]   Imported: org.eclipse.aether.impl < plexus.core
[DEBUG]   Imported: org.eclipse.aether.installation < plexus.core
[DEBUG]   Imported: org.eclipse.aether.internal.impl < plexus.core
[DEBUG]   Imported: org.eclipse.aether.metadata < plexus.core
[DEBUG]   Imported: org.eclipse.aether.repository < plexus.core
[DEBUG]   Imported: org.eclipse.aether.resolution < plexus.core
[DEBUG]   Imported: org.eclipse.aether.spi < plexus.core
[DEBUG]   Imported: org.eclipse.aether.transfer < plexus.core
[DEBUG]   Imported: org.eclipse.aether.version < plexus.core
[DEBUG]   Imported: org.fusesource.jansi.* < plexus.core
[DEBUG]   Imported: org.slf4j.* < plexus.core
[DEBUG]   Imported: org.slf4j.event.* < plexus.core
[DEBUG]   Imported: org.slf4j.helpers.* < plexus.core
[DEBUG]   Imported: org.slf4j.spi.* < plexus.core
[DEBUG] Populating class realm maven.api
[INFO] Error stacktraces are turned on.
[DEBUG] Message scheme: color
[DEBUG] Message styles: debug info warning error success failure strong mojo project
[DEBUG] Reading global settings from /usr/share/maven/conf/settings.xml
[DEBUG] Reading user settings from /home/andrea.gioia/.m2/settings.xml
[DEBUG] Reading global toolchains from /usr/share/maven/conf/toolchains.xml
[DEBUG] Reading user toolchains from /home/andrea.gioia/.m2/toolchains.xml
[DEBUG] Using local repository at /home/andrea.gioia/.m2/repository
[DEBUG] Using manager EnhancedLocalRepositoryManager with priority 10.0 for /home/andrea.gioia/.m2/repository
[INFO] Scanning for projects...
[DEBUG] Extension realms for project it.quantyca.kafka.spring:demo:jar:0.0.1-SNAPSHOT: (none)
[DEBUG] Looking up lifecycle mappings for packaging jar from ClassRealm[plexus.core, parent: null]
[DEBUG] Extension realms for project org.springframework.boot:spring-boot-starter-parent:pom:2.5.3: (none)
[DEBUG] Looking up lifecycle mappings for packaging pom from ClassRealm[plexus.core, parent: null]
[DEBUG] Extension realms for project org.springframework.boot:spring-boot-dependencies:pom:2.5.3: (none)
[DEBUG] Looking up lifecycle mappings for packaging pom from ClassRealm[plexus.core, parent: null]
[DEBUG] Resolving plugin prefix avro from [org.apache.maven.plugins, org.codehaus.mojo]
[DEBUG] Resolved plugin prefix avro to org.apache.avro:avro-maven-plugin from POM it.quantyca.kafka.spring:demo:jar:0.0.1-SNAPSHOT
[DEBUG] === REACTOR BUILD PLAN ================================================
[DEBUG] Project: it.quantyca.kafka.spring:demo:jar:0.0.1-SNAPSHOT
[DEBUG] Tasks:   [avro:schema]
[DEBUG] Style:   Regular
[DEBUG] =======================================================================
[INFO] 
[INFO] -------------------< it.quantyca.kafka.spring:demo >--------------------
[INFO] Building Demo 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[DEBUG] Resolving plugin prefix avro from [org.apache.maven.plugins, org.codehaus.mojo]
[DEBUG] Resolved plugin prefix avro to org.apache.avro:avro-maven-plugin from POM it.quantyca.kafka.spring:demo:jar:0.0.1-SNAPSHOT
[DEBUG] Lifecycle default -> [validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy]
[DEBUG] Lifecycle clean -> [pre-clean, clean, post-clean]
[DEBUG] Lifecycle site -> [pre-site, site, post-site, site-deploy]
[DEBUG] === PROJECT BUILD PLAN ================================================
[DEBUG] Project:       it.quantyca.kafka.spring:demo:0.0.1-SNAPSHOT
[DEBUG] Dependencies (collect): []
[DEBUG] Dependencies (resolve): [runtime+test]
[DEBUG] Repositories (dependencies): [confluent (https://packages.confluent.io/maven/, default, releases+snapshots), central (https://repo.maven.apache.org/maven2, default, releases)]
[DEBUG] Repositories (plugins)     : [confluent (https://packages.confluent.io/maven/, default, releases+snapshots), central (https://repo.maven.apache.org/maven2, default, releases)]
[DEBUG] -----------------------------------------------------------------------
[DEBUG] Goal:          org.apache.avro:avro-maven-plugin:1.10.2:schema (default-cli)
[DEBUG] Style:         Regular
[DEBUG] Configuration: <?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <createOptionalGetters>${createOptionalGetters}</createOptionalGetters>
  <createSetters default-value="true"/>
  <customConversions>${customConversions}</customConversions>
  <customLogicalTypeFactories>${customLogicalTypeFactories}</customLogicalTypeFactories>
  <enableDecimalLogicalType default-value="false"/>
  <fieldVisibility default-value="PRIVATE"/>
  <gettersReturnOptional>${gettersReturnOptional}</gettersReturnOptional>
  <optionalGettersForNullableFieldsOnly>${optionalGettersForNullableFieldsOnly}</optionalGettersForNullableFieldsOnly>
  <outputDirectory default-value="${project.build.directory}/generated-sources/avro">${outputDirectory}</outputDirectory>
  <project default-value="${project}"/>
  <sourceDirectory default-value="${basedir}/src/main/avro">${sourceDirectory}</sourceDirectory>
  <stringType>${stringType}</stringType>
  <templateDirectory>${templateDirectory}</templateDirectory>
  <testOutputDirectory default-value="${project.build.directory}/generated-test-sources/avro">${outputDirectory}</testOutputDirectory>
  <testSourceDirectory default-value="${basedir}/src/test/avro">${sourceDirectory}</testSourceDirectory>
  <velocityToolsClassesNames>${velocityToolsClassesNames}</velocityToolsClassesNames>
</configuration>
[DEBUG] =======================================================================
[INFO] 
[INFO] --- avro-maven-plugin:1.10.2:schema (default-cli) @ demo ---
[DEBUG] Dependency collection stats: {ConflictMarker.analyzeTime=963865, ConflictMarker.markTime=385111, ConflictMarker.nodeCount=167, ConflictIdSorter.graphTime=638256, ConflictIdSorter.topsortTime=545360, ConflictIdSorter.conflictIdCount=51, ConflictIdSorter.conflictIdCycleCount=0, ConflictResolver.totalTime=6042668, ConflictResolver.conflictItemCount=117, DefaultDependencyCollector.collectTime=253243314, DefaultDependencyCollector.transformTime=9970039}
[DEBUG] org.apache.avro:avro-maven-plugin:jar:1.10.2
[DEBUG]    org.apache.maven:maven-core:jar:3.3.9:compile
[DEBUG]       org.apache.maven:maven-model:jar:3.3.9:compile
[DEBUG]       org.apache.maven:maven-settings:jar:3.3.9:compile
[DEBUG]       org.apache.maven:maven-settings-builder:jar:3.3.9:compile
[DEBUG]          org.apache.maven:maven-builder-support:jar:3.3.9:compile
[DEBUG]       org.apache.maven:maven-repository-metadata:jar:3.3.9:compile
[DEBUG]       org.apache.maven:maven-artifact:jar:3.3.9:compile
[DEBUG]       org.apache.maven:maven-plugin-api:jar:3.3.9:compile
[DEBUG]       org.apache.maven:maven-model-builder:jar:3.3.9:compile
[DEBUG]          com.google.guava:guava:jar:18.0:compile
[DEBUG]       org.apache.maven:maven-aether-provider:jar:3.3.9:compile
[DEBUG]          org.eclipse.aether:aether-spi:jar:1.0.2.v20150114:compile
[DEBUG]       org.eclipse.aether:aether-impl:jar:1.0.2.v20150114:compile
[DEBUG]       org.eclipse.aether:aether-api:jar:1.0.2.v20150114:compile
[DEBUG]       org.eclipse.aether:aether-util:jar:1.0.2.v20150114:compile
[DEBUG]       org.eclipse.sisu:org.eclipse.sisu.plexus:jar:0.3.2:compile
[DEBUG]          javax.enterprise:cdi-api:jar:1.0:compile
[DEBUG]             javax.annotation:jsr250-api:jar:1.0:compile
[DEBUG]          org.eclipse.sisu:org.eclipse.sisu.inject:jar:0.3.2:compile
[DEBUG]       com.google.inject:guice:jar:no_aop:4.0:compile
[DEBUG]          javax.inject:javax.inject:jar:1:compile
[DEBUG]          aopalliance:aopalliance:jar:1.0:compile
[DEBUG]       org.codehaus.plexus:plexus-interpolation:jar:1.21:compile
[DEBUG]       org.codehaus.plexus:plexus-utils:jar:3.0.22:compile
[DEBUG]       org.codehaus.plexus:plexus-classworlds:jar:2.5.2:compile
[DEBUG]       org.codehaus.plexus:plexus-component-annotations:jar:1.6:compile
[DEBUG]       org.sonatype.plexus:plexus-sec-dispatcher:jar:1.3:compile
[DEBUG]          org.sonatype.plexus:plexus-cipher:jar:1.4:compile
[DEBUG]       org.apache.commons:commons-lang3:jar:3.4:compile
[DEBUG]    org.apache.maven.shared:file-management:jar:3.0.0:compile
[DEBUG]       org.apache.maven.shared:maven-shared-io:jar:3.0.0:compile
[DEBUG]          org.apache.maven:maven-compat:jar:3.0:compile
[DEBUG]             org.sonatype.sisu:sisu-inject-plexus:jar:1.4.2:compile
[DEBUG]                org.sonatype.sisu:sisu-inject-bean:jar:1.4.2:compile
[DEBUG]                   org.sonatype.sisu:sisu-guice:jar:noaop:2.1.7:compile
[DEBUG]          org.apache.maven.wagon:wagon-provider-api:jar:2.10:compile
[DEBUG]       org.apache.maven.shared:maven-shared-utils:jar:3.0.0:compile
[DEBUG]          commons-io:commons-io:jar:2.4:compile
[DEBUG]    org.apache.avro:avro-compiler:jar:1.10.2:compile
[DEBUG]       org.apache.avro:avro:jar:1.10.2:compile
[DEBUG]          com.fasterxml.jackson.core:jackson-core:jar:2.12.2:compile (version managed from default)
[DEBUG]          org.apache.commons:commons-compress:jar:1.20:compile (version managed from default)
[DEBUG]       org.apache.velocity:velocity-engine-core:jar:2.3:compile (version managed from default)
[DEBUG]       com.fasterxml.jackson.core:jackson-databind:jar:2.12.2:compile (version managed from default)
[DEBUG]          com.fasterxml.jackson.core:jackson-annotations:jar:2.12.2:compile
[DEBUG]    org.slf4j:slf4j-api:jar:1.7.30:compile
[DEBUG] Created new class realm plugin>org.apache.avro:avro-maven-plugin:1.10.2
[DEBUG] Importing foreign packages into class realm plugin>org.apache.avro:avro-maven-plugin:1.10.2
[DEBUG]   Imported:  < maven.api
[DEBUG] Populating class realm plugin>org.apache.avro:avro-maven-plugin:1.10.2
[DEBUG]   Included: org.apache.avro:avro-maven-plugin:jar:1.10.2
[DEBUG]   Included: org.apache.maven:maven-builder-support:jar:3.3.9
[DEBUG]   Included: com.google.guava:guava:jar:18.0
[DEBUG]   Included: org.eclipse.aether:aether-util:jar:1.0.2.v20150114
[DEBUG]   Included: javax.enterprise:cdi-api:jar:1.0
[DEBUG]   Included: org.eclipse.sisu:org.eclipse.sisu.inject:jar:0.3.2
[DEBUG]   Included: com.google.inject:guice:jar:no_aop:4.0
[DEBUG]   Included: aopalliance:aopalliance:jar:1.0
[DEBUG]   Included: org.codehaus.plexus:plexus-interpolation:jar:1.21
[DEBUG]   Included: org.codehaus.plexus:plexus-utils:jar:3.0.22
[DEBUG]   Included: org.codehaus.plexus:plexus-component-annotations:jar:1.6
[DEBUG]   Included: org.sonatype.plexus:plexus-sec-dispatcher:jar:1.3
[DEBUG]   Included: org.sonatype.plexus:plexus-cipher:jar:1.4
[DEBUG]   Included: org.apache.commons:commons-lang3:jar:3.4
[DEBUG]   Included: org.apache.maven.shared:file-management:jar:3.0.0
[DEBUG]   Included: org.apache.maven.shared:maven-shared-io:jar:3.0.0
[DEBUG]   Included: org.sonatype.sisu:sisu-inject-bean:jar:1.4.2
[DEBUG]   Included: org.sonatype.sisu:sisu-guice:jar:noaop:2.1.7
[DEBUG]   Included: org.apache.maven.shared:maven-shared-utils:jar:3.0.0
[DEBUG]   Included: commons-io:commons-io:jar:2.4
[DEBUG]   Included: org.apache.avro:avro-compiler:jar:1.10.2
[DEBUG]   Included: org.apache.avro:avro:jar:1.10.2
[DEBUG]   Included: com.fasterxml.jackson.core:jackson-core:jar:2.12.2
[DEBUG]   Included: org.apache.commons:commons-compress:jar:1.20
[DEBUG]   Included: org.apache.velocity:velocity-engine-core:jar:2.3
[DEBUG]   Included: com.fasterxml.jackson.core:jackson-databind:jar:2.12.2
[DEBUG]   Included: com.fasterxml.jackson.core:jackson-annotations:jar:2.12.2
[DEBUG] Configuring mojo org.apache.avro:avro-maven-plugin:1.10.2:schema from plugin realm ClassRealm[plugin>org.apache.avro:avro-maven-plugin:1.10.2, parent: jdk.internal.loader.ClassLoaders$AppClassLoader@55054057]
[DEBUG] Configuring mojo 'org.apache.avro:avro-maven-plugin:1.10.2:schema' with basic configurator -->
[DEBUG]   (f) createSetters = true
[DEBUG]   (f) customConversions = []
[DEBUG]   (f) customLogicalTypeFactories = []
[DEBUG]   (f) enableDecimalLogicalType = false
[DEBUG]   (f) fieldVisibility = PRIVATE
[DEBUG]   (f) outputDirectory = /home/andrea.gioia/Sviluppi/playground/kafka/kafka-spring/target/generated-sources/avro
[DEBUG]   (f) project = MavenProject: it.quantyca.kafka.spring:demo:0.0.1-SNAPSHOT @ /home/andrea.gioia/Sviluppi/playground/kafka/kafka-spring/pom.xml
[DEBUG]   (f) sourceDirectory = /home/andrea.gioia/Sviluppi/playground/kafka/kafka-spring/src/main/avro
[DEBUG]   (f) testOutputDirectory = /home/andrea.gioia/Sviluppi/playground/kafka/kafka-spring/target/generated-test-sources/avro
[DEBUG]   (f) testSourceDirectory = /home/andrea.gioia/Sviluppi/playground/kafka/kafka-spring/src/test/avro
[DEBUG]   (f) velocityToolsClassesNames = []
[DEBUG] -- end configuration --
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.741 s
[INFO] Finished at: 2021-08-19T19:34:18+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.avro:avro-maven-plugin:1.10.2:schema (default-cli) on project demo: neither sourceDirectory: /home/andrea.gioia/Sviluppi/playground/kafka/kafka-spring/src/main/avro or testSourceDirectory: /home/andrea.gioia/Sviluppi/playground/kafka/kafka-spring/src/test/avro are directories -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.avro:avro-maven-plugin:1.10.2:schema (default-cli) on project demo: neither sourceDirectory: /home/andrea.gioia/Sviluppi/playground/kafka/kafka-spring/src/main/avro or testSourceDirectory: /home/andrea.gioia/Sviluppi/playground/kafka/kafka-spring/src/test/avro are directories
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoExecutionException: neither sourceDirectory: /home/andrea.gioia/Sviluppi/playground/kafka/kafka-spring/src/main/avro or testSourceDirectory: /home/andrea.gioia/Sviluppi/playground/kafka/kafka-spring/src/test/avro are directories
    at org.apache.avro.mojo.AbstractAvroMojo.execute (AbstractAvroMojo.java:210)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[ERROR] 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

It seems that the plugin ignore my configuration and use the default ones. I'm working on the problem. Let me know if you find the solution. I will do the same.

Solution 4:[4]

It seems strange, but it's works in my case:

I replaced avro schemas from src/main/resources/avro to src/main/avro (default path) and run mvn clean:package.

Strange in this case was that it still worked when I replaced schemas from default path to my custom path (src/main/resources/avro) and run mvn clean:package.

P.S. Not on virtual machine this magic doesn't work)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Andrea Gioia
Solution 2 Ana Lucatti
Solution 3 Andrea Gioia
Solution 4