-2

I wannna use annotation processor in my IDEA plugin, which will resolve classes and methods with 'TaskID' annotation. But I found that my processor can't run at all. I do wanna know what's wrong and what should I do. Here is my code below

import com.google.auto.service.AutoService;

import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.Processor;
import javax.annotation.processing.RoundEnvironment;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.*;
import javax.lang.model.util.Elements;
import java.util.*;

@AutoService(Processor.class)
public class AnnotationProcessor extends AbstractProcessor {
@Retention(RetentionPolicy.SOURCE)
@Target({TYPE, METHOD})
public @interface TaskID {
    /**
     * Task ID
     */
    String[] taskID();
}
dependencies {
    annotationProcessor 'com.google.auto.service:auto-service:1.0-rc2'
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
    implementation 'com.google.auto.service:auto-service:1.0-rc2'
    implementation ("com.github.javaparser:javaparser-core:3.25.4")
}

Enviroment: JDK 11, Gradle-7.6 IntelliJ IDEA 2021.3.1 (Community Edition)

  • Try enabling in the IDE as well – hermit Aug 30 '23 at 02:48
  • Hi hermit, I'm glad to receive your comment. A good news is that I have found a solution for this problem. It was totally because the annotation processor module should be placed in a diff module from other module. – hill cxs Aug 31 '23 at 08:35

1 Answers1

0

Put the annotation processor codes in a seperated module and other module just depend on it.