Scanning for locally compiled classes (exlude child classes)
See original GitHub issueI am trying to figure out how to accomplish this, but so far from reading the documentation I have not been able to figure it out.
Basically, I want to scan for all classes that have been compiled locally by Maven or Gradle or something. I sort of figured out how to do it by doing this:
List<String> classnames = new ClassGraph()
.acceptPackages("")
.disableJarScanning()
.rejectClasses(Closure.class.getName())
.scan()
.getAllClasses()
.getNames();
Since I’m doing this on Groovy classes, I am getting a ton of extra classes that represent the Groovy closures in many of the classes. For example (the highlighted classes in this list of variables in IntelliJ are closure classes):
What I want to do is exclude classes that have groovy.lang.Closure
as their super class (or at any other arbitrary location below the class in the class hierarchy).
I tried using rejectClasses
, but closures are compiled into anonymous classes that extend groovy.lang.Closure
instead of being an instance of a Closure
, and it seems that rejectClasses
only works the provided class itself.
Is there a way to do this that I am overlooking?
Thanks
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (5 by maintainers)
Top GitHub Comments
I just made another change that returns
true
fromextendsSuperclass("java.lang.Object")
only for standard classes, not for interfaces or annotations, since these do not extendObject
. This will be in 4.8.95.Just as a heads-up – Sonatype has issues with publishing artifacts right now, so I can’t push to Maven Central until that is resolved. Feel free to use a locally-built snapshot until that is fixed. Also since I couldn’t push 4.8.94, I’ll just combine that change from the previous comment and release the final version as 4.8.94 with all changes.