Skip to content

Scanning for locally compiled classes (exlude child classes) #486

@wheelerlaw

Description

@wheelerlaw

I 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):

image

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions