How can I scan a classpath to find all classes of a particular type?
The process is simpler than you might think. You will use the Javac API to analyze files. So first, you’ll want to get the classpath – for example ClassPath path = project.getLookup().lookup( ClassPathProvider.class).findClassPath(someFile, ClassPath.SOURCE); (or if you can directly access the project, get the classpath some other way). Then you’ll recursively iterate all of the children of the FileObjects that are the classpath roots. For each one with the extension .java, you will call JavaSource src = JavaSource.forFileObject(fo); to get the JavaSource for that FileObject. The JavaSource is something you can pass a task to, and it will run the compiler against it and you can write a visitor or scanner that visits every element of the compilation tree. So you will implement CancellableTask