Make it easier to use the output of a compilation as an input for another compilation
vRallev opened this issue · comments
Feeding a new compilation with the output from a previous compilation isn't very hard, although I believe there could be a nicer API:
kotlinCompilation.classpaths += previousCompilationResult.outputDirectory
The tricky part is the result of the 2nd compilation where the class loader doesn't respect the output from the previous compilation. The workaround is to create a new class loader that uses all compilation results as input:
URLClassLoader(
allCompilationResults.map { it.outputDirectory.toURI().toURL() }.toTypedArray(),
this::class.java.classLoader
)
This is quite annoying, because one needs to be aware that result.classLoader
gives misleading results.
I wish the library would provide a better solution for this. If you're open for that, then I'm more than happy to create a PR.
Sounds like a good idea. If you want to make a PR it would be very appreciated.
The tricky part is the result of the 2nd compilation where the class loader doesn't respect the output from the previous compilation
Can you elaborate on that? Perhaps it would be better if the result.classLoader
included kotlinCompilation.classpaths
by default.
Perhaps it would be better if the
result.classLoader
includedkotlinCompilation.classpaths
by default.
Ah, that's even better than what I suggested above. I've created a PR.