Gradle plugin with reflections

You’ll need to wire your task into Gradle’s DAG so that it runs after JavaCompile. Eg:

task myTask(type: MyReflectionsTask) {
   dependsOn compileJava
   ...
}

You’ll obviously need reflections on the buildscript.depencies.classpath (I’m not sure if this task is from buildSrc or a plugin). You won’t need the scanned classes on the buildscript classpath because we are using UrlClassloader to avoid a chicken-or-egg scenario.