I’m making a plugin. One goal is to emit a compilation database like JSON file that describes the build of a Java project. To that end, I am using TaskExecutionListener’s beforeExecute
. If the task is an instance of JavaCompile
then I get the class path:
((JavaCompile)task).getClasspath().getFiles()
However, builds for some projects that use Kotlin and Java (calling the kotlin code from Java) do not seem to produce a complete classpath. For example, assembling okhttp
includes tasks :okhttp:compileKotlin
followed by :okhttp:compileJava
. The compileJava
task does not include any classpath for the classes produced by the Kotlin task - taking the JavaCompile
object’s cp, arguments, files, and output directory and using javac
manually results in missing symbols.
What is going on? Shouldn’t the full classpath be available via getClasspath() or is there a reason Gradle can compile without it? Is there another dataflow I need to look for that includes classpath information?