When creating a new CLI app with help of Micronaut CLI tool (mn) and with maven as build tool, the created pom.xml is not working correctly. With Micronaut 1.1.0 it seems to work
mn create-cli-app foo --build mavencd foo./mvnw packageBuild runs successfully and jar file is built
Build crashes with an exception
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project foo: Fatal error compiling: java.lang.NoClassDefFoundError: io/micronaut/inject/annotation/AnnotatedElementValidator: io.micronaut.inject.annotation.AnnotatedElementValidator -> [Help 1]
Hi all,
this issue can be solved putting the artifact io.micronaut.configuration:micronaut-picocli at last position of the annotation processor path, as the following code:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
<annotationProcessorPaths>
<path>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-inject-java</artifactId>
<version>${micronaut.version}</version>
</path>
<path>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-validation</artifactId>
<version>${micronaut.version}</version>
</path>
<path>
<groupId>io.micronaut.configuration</groupId>
<artifactId>micronaut-picocli</artifactId>
<version>${micronaut.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
<executions>
<execution>
<id>test-compile</id>
<goals>
<goal>testCompile</goal>
</goals>
<configuration>
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
<annotationProcessorPaths>
<path>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-inject-java</artifactId>
<version>${micronaut.version}</version>
</path>
<path>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-validation</artifactId>
<version>${micronaut.version}</version>
</path>
<path>
<groupId>io.micronaut.configuration</groupId>
<artifactId>micronaut-picocli</artifactId>
<version>${micronaut.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</execution>
</executions>
</plugin>
I have tested the above mentioned solution and that does seem to resolve the issue. Someone else has also ran across this same issue as https://github.com/micronaut-projects/micronaut-core/issues/2302 and the above solution seems to resolve it as well
Most helpful comment
Hi all,
this issue can be solved putting the artifact
io.micronaut.configuration:micronaut-picocliat last position of the annotation processor path, as the following code: