Maven annotation processing processor not found

Aurasphere :

I'm new to annotation processing and I'm trying to automating it with Maven. I've put this in my pom.xml:

<plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.0</version>
            <configuration>
                <annotationProcessors>
                    <annotationProcessor>
                        co.aurasphere.revolver.annotation.processor.InjectAnnotationProcessor</annotationProcessor>
                    <annotationProcessor>
                        co.aurasphere.revolver.annotation.processor.RevolverContextAnnotationProcessor</annotationProcessor>
                </annotationProcessors>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
    </plugins>

The problem is that when I try to build the project I get a CompilationFailureException because Maven can't find the processors.

I've found other questions like this, solved by putting the dependency outside the plugin. I tried that, but nothing changed for me.

Am I missing something?

Thank you.

EDIT

Here is my dependency on another project which contains both the processor and the annotations:

    <dependencies>
    <dependency>
        <groupId>co.aurasphere</groupId>
        <artifactId>revolver-annotation-processor</artifactId>
        <version>0.0.3-SNAPSHOT</version>
    </dependency>
</dependencies>

EDIT 2:

After further investigation, I decided to decompile the processor JAR (built with Maven) and it happens that... my classes are not there. For some reasons, Maven is not compiling my classes into the JAR and that's why the classes are not found. I've tried figuring out what's wrong on that build (this never happened to me before and I've used Maven for a while...).

First of all, the packaging on that project is jar. The classes are all under src/main/java. I've checked in my pom.xml that the classpath and source path is the same.

Here's the processor pom:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>co.aurasphere</groupId>
<artifactId>revolver-annotation-processor</artifactId>
<version>0.0.3-SNAPSHOT</version>
<build>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
    </plugins> 
</build>
<dependencies>
    <!-- https://mvnrepository.com/artifact/javax.inject/javax.inject -->
    <dependency>
        <groupId>javax.inject</groupId>
        <artifactId>javax.inject</artifactId>
        <version>1</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.apache.velocity/velocity -->
    <dependency>
        <groupId>org.apache.velocity</groupId>
        <artifactId>velocity</artifactId>
        <version>1.7</version>
    </dependency>


</dependencies>

EDIT 3

Here's the output of a maven clean install on the processor project. Unfortunately the output is too long and I had to post an external link even if I know it's not good.

EDIT 4

Here are some screenshots of my dependency hierarchy: Eclipse and File System.

Since the project was originally created as an Eclipse simple Java project and then converted to a Maven one, I tried to create a new Maven project and move everything to the new one in the hope that the problem was the Eclipse plugin that messed something up, but the error was still there.

Aurasphere :

I've found the answer myself. I've figured out that the problem was the file javax.annotation.processing.Processor in META-INF/services/ with the configuration of the annotation processor's class. In order to fix the problem I had to add the following to the pom.xml configuration of my processor project:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.5.1</version>
            <configuration>
                <compilerArgument>
                    -proc:none
                </compilerArgument>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
    </plugins>
</build>

This let Maven build the classes into the actual jar and fixed the problem. I don't know if this is a bug or not but it surely looks strange to me. Thank you everybody for the help!

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Java Annotation Processor getEnclosingElement() method

How to get annotation parameter in annotation processor

@ConfigurationProperties Spring Boot Configuration Annotation Processor not found in classpath

@ConfigurationProperties Spring Boot Configuration Annotation Processor not found in classpath

IntelliJ Idea: Maven compilation warning about supported annotation processor source version 'RELEASE_6' on Java 11

Annotation Processor - How to get the Class it is processing

Annotation processor output in maven

Code replacement with an annotation processor

Maven 3 - How to add annotation processor dependency?

Setup Java 6 annotation processing configuration for eclipse compiler with maven

How to configure the Annotation Processing API without external Jar using Maven?

Writing an annotation processor for maven-processor-plugin

Annotation processor 'org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor' not found

Java annotation processing edit file created by annotation processer with other annotation processor

Get all values of a generated Annotation in an Annotation Processor

Annotation processing unknown Annotation

Annotation Processor in IntelliJ and Gradle

Javapoet not found in processor

Set up picocli Annotation Processor in Intellij maven project with modules

Matching between annotation and processor

Change annotation processor dynamically

Null annotation processor in Eclipse

Multiplexer not processing second Input Processor

Java annotation processor, annotation types with annotations

Annotation processor 'io.vertx.serviceproxy.ServiceProxyProcessor' not found

Use annotation processor in kotlin

Annotation processor 'com.sun.tools.ws.processor.modeler.annotation.WebServiceAp' not found

Get enclosing class name of a VariableElement in javax.annotation.processing.Processor

Proper Lifecycle Order For Annotation Processing In Maven