Kotlin-Compile-Testing: A library for testing Kotlin and Java annotation processors, compiler plugins and code generation

I recently released this compile testing library for Kotlin in the spirit of Google’s compile-testing:


It can be used to test annotation processors, compiler plugins and code generation.

Features:

  • Mixed-source sets: Compile Kotlin and Java source files together

  • Supports compiler plugins

  • Annotation processing:

    • Run annotation processors on Kotlin and Java sources

    • Generate Kotlin and Java sources

    • Provide your own instances of annotation processors directly to the compiler instead of letting the compiler create them with a service locator

    • Debug annotation processors: Since the compilation runs in the same process as your application, you can easily debug it instead of having to attach your IDE’s debugger manually to the compilation process

  • Inherit classpath: Compiled sources have access to classes in your application

    • Project Jigsaw compatible: Works with JDK 8 as well as JDK 9 and later

    • JDK cross compilation: Provide your own JDK to compile the code against, instead of using the host application’s JDK. This allows you to easily test your code on all JDK versions

  • Find dependencies automatically on the host classpath

Hopefully it will be as helpful to you as it was to me. Remember to leave a star if you like it!

1 Like