Skip to content

Does not work when used in a library #82

@lewimuchiri

Description

@lewimuchiri

Assuming you have a library my-library with the following dependencies:

dependencies {
    compileOnly("org.atteo.classindex:classindex:3.4") // also tried implementation(..). Didn't work
    annotationProcessor("org.atteo.classindex:classindex:3.4")
}

And a custom annotation:

@Retention( RetentionPolicy.RUNTIME )
@IndexAnnotated
public @interface MyCustomAnnotation {
}

And a method in the library to get all classes with that annotation:

    public void getClassesWithAnnotation() {
        Iterable<Class<?>> klasses = ClassIndex.getAnnotated(MyCustomAnnotation.class);
        ...
    }

And then the library is imported into another Java project as follows:

    implementation("app.libs.io:my-library:2.0.0.8-SNAPSHOT") 

Then the Java Project has a class with that annotation:

@MyCustomAnnotation
public class TestClass {
}

When the Java project calls the getClassesWithAnnotation() from the library, it gets an empty list, showing that the classes in the Java project were not scanned.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions