Simple classpath scanner for Javassist
Lightweight javaassist classpath scanner.
Usage
The artifact avaliable at Maven Central:
<dependency>
<groupId>com.github.baev</groupId>
<artifactId>javassist-classpath-scanner</artifactId>
<version>RELEASE</version>
</dependency>
List<URI> classpath = ...
ClasspathScanner scanner = new ClasspathScanner();
classpath.forEach(scanner::scan);
Set<ClassFile> = scanner.getClasses();
Then you can do whatever you need with the found classes. For example, you can find all the JUnit tests using code like this:
public boolean isTestMethod(MethodInfo methodInfo) {
return JavassistUtils.isAnnotated(methodInfo, "org.junit.Test");
}
public List<MethodInfo> getTestMethods(ClassFile clazz) {
return JavassistUtils.getMethods(clazz, this::isTestMethod);
}
List<MethodInfo> testMethods = scanner.getClasses().stream()
.map(this::getTestMethods)
.collect(Collectors.toList());