Why getAnnotation(Class) return always null inside my custom gradle plugin?


(khouloud) #1

I developed a gradle project in wich I’m trying to process an annotation; this work great inside my gradle project. However when I’m trying to export my gradle project jar and use it inside my gradle plugin my code does not work correctly and I’m always getting ann null even if the annotation exists. Here is my code :

cls = Class.forName(className, false, classLoader);
CustomEntity ann = (CustomEntity) cls.getAnnotation(CustomEntity.class);

I cannot understand why my code works correctly inside my gradle project. However the same code does not work and always return a null annotation inside my gradle plugin…