Share
Embed
Kotlin-friendly Annotation Processing (AppsConf 2018)
When promoting Kotlin over Java to your friend the first argument you’ll probably use will be its powerful syntax: in-house nullability support, default arguments, delegated properties, data & sealed classes, etc. These features are really the stuff we’re benefiting from everyday, but if we’ll take Java annotation processors then sadly the only information they can get about our code will be Java-related and no info about Kotlin-specific features.
In this talk we’ll find out how to use Kotlin metadata added by the compiler to get info about Kotlin language features in the code and utilise it during annotation processing.
Video: https://youtu.be/rJ9BRDuvJ1I
Sergey Ryabov
October 08, 2018
Transcript
160 slides
-
• Annotation processing works inside javac • Separate Annotation Processors
are pluggable JSR-269 -
• Annotation processing works inside javac • Separate Annotation Processors
are pluggable • Gradle’s annotationProcessor dependencies configuration JSR-269 -
• Annotation processing works inside javac • Separate Annotation Processors
are pluggable • Gradle’s annotationProcessor dependencies configuration • /META-INF/services/javax.annotation.processing.Processor declares your AP’s main entry point JSR-269 -
• Annotation processing works inside javac • Separate Annotation Processors
are pluggable • Gradle’s annotationProcessor dependencies configuration • /META-INF/services/javax.annotation.processing.Processor declares your AP’s main entry point • Multiple rounds of processing JSR-269 -
• APT can’t process Kotlin sources — build KAPT •
Kotlin’s own JSR-269 implementation? Kotlin-way -
• APT can’t process Kotlin sources — build KAPT •
Kotlin’s own JSR-269 implementation? • Generate Java code/stubs from Kotlin? Kotlin-way -
• APT can’t process Kotlin sources — build KAPT •
Kotlin’s own JSR-269 implementation? • Generate Java code/stubs from Kotlin? • Precompile Kotlin classes and feed them to javac? Kotlin-way -
• APT can’t process Kotlin sources — build KAPT •
Kotlin’s own JSR-269 implementation? • Generate Java code/stubs from Kotlin? • Precompile Kotlin classes and feed them to javac? Kotlin-way -
• APT can’t process Kotlin sources — build KAPT •
Kotlin’s own JSR-269 implementation? • Generate Java code/stubs from Kotlin? • Precompile Kotlin classes and feed them to javac? Kotlin-way -
• APT can’t process Kotlin sources — build KAPT •
Kotlin’s own JSR-269 implementation? • Generate Java code/stubs from Kotlin? • Precompile Kotlin classes and feed them to javac? Kotlin-way -
• APT can’t process Kotlin sources — build KAPT •
Kotlin’s own JSR-269 implementation? • Generate Java code/stubs from Kotlin? • Precompile Kotlin classes and feed them to javac? • No multiple APT rounds over generated Kotlin files Kotlin-way -
class KotlinProcessor : AbstractProcessor() { override fun getSupportedOptions(): Set<String> override
fun getSupportedAnnotationTypes(): Set<String> } JSR-269 -
class KotlinProcessor : AbstractProcessor() { override fun getSupportedOptions(): Set<String> override
fun getSupportedAnnotationTypes(): Set<String> override fun getSupportedSourceVersion(): SourceVersion } JSR-269 -
class KotlinProcessor : AbstractProcessor() { override fun getSupportedOptions(): Set<String> override
fun getSupportedAnnotationTypes(): Set<String> override fun getSupportedSourceVersion(): SourceVersion override fun init(processingEnv: ProcessingEnvironment) } JSR-269 -
class KotlinProcessor : AbstractProcessor() { override fun getSupportedOptions(): Set<String> override
fun getSupportedAnnotationTypes(): Set<String> override fun getSupportedSourceVersion(): SourceVersion override fun init(processingEnv: ProcessingEnvironment) override fun process( annotations: Set<TypeElement>, roundEnv: RoundEnvironment ): Boolean } JSR-269 -
class KotlinProcessor : AbstractProcessor() { override fun getSupportedOptions(): Set<String> override
fun getSupportedAnnotationTypes(): Set<String> override fun getSupportedSourceVersion(): SourceVersion override fun init(processingEnv: ProcessingEnvironment) override fun process( annotations: Set<TypeElement>, roundEnv: RoundEnvironment ): Boolean } JSR-269 -
Problems • No info about Kotlin-specifics is available for Annotation
Processors • No Nullability -
Problems • No info about Kotlin-specifics is available for Annotation
Processors • No Nullability • No default arguments -
Problems • No info about Kotlin-specifics is available for Annotation
Processors • No Nullability • No default arguments • No sealed & data classes -
Problems • No info about Kotlin-specifics is available for Annotation
Processors • No Nullability • No default arguments • No sealed & data classes • … -
Problems • No info about Kotlin-specifics is available for Annotation
Processors • No Nullability • No default arguments • No sealed & data classes • … • No nothing! -
Dad! APT can’t get any Kotlin info. And StackOverflow can’t
help! If even StackOverflow keeps silence… -
Dad! APT can’t get any Kotlin info. And StackOverflow can’t
help! If even StackOverflow keeps silence… B-b-b-but compiler..? -
Dad! APT can’t get any Kotlin info. And StackOverflow can’t
help! If even StackOverflow keeps silence… B-b-b-but compiler..? Well, this city has a Hero! -
@Metadata( mv = {1, 1, 11}, bv = {1, 0,
2}, k = 1, d1 = {"\u0000\u0080\u0001\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u00… d2 = {""Lxyz/ryabov/gsonkot/User;", "", "id", "", "username", "", "isAdmin ) public final class User { ... } -
@Metadata • Provides Kotlin-specific info • Class-level annotation • Accessible
both at compile time and runtime -
@Metadata • Provides Kotlin-specific info • Class-level annotation • Accessible
both at compile time and runtime • Used by compiler as well -
@Metadata • mv • bv • k • d1 •
d2 • xs • xi • pn -
@Metadata • metadataVersion • bytecodeVersion • kind • data1 •
data2 • extraString • extraInt • packageName -
What can we do with that? Parse data1 Protocol Buffers
using kind to define its format -
What can we do with that? Parse data1 Protocol Buffers
using kind to define its format https://github.com/JetBrains/kotlin/blob/master/core/metadata/src/metadata.proto -
What tools do we have? • Hands • Use kotlin-metadata
by Eugenio Marletti https://github.com/Takhion/kotlin-metadata -
What tools do we have? • Hands • Use kotlin-metadata
by Eugenio Marletti https://github.com/Takhion/kotlin-metadata • Or… -
What tools do we have? • Hands • Use kotlin-metadata
by Eugenio Marletti https://github.com/Takhion/kotlin-metadata • Or… kotlinx-metadata by JetBrains https://github.com/JetBrains/kotlin/tree/master/libraries/kotlinx-metadata/jvm -
Visitors API public interface ElementVisitor<R, P> { R visit(Element e,
P p); R visitPackage(PackageElement e, P p); } -
Visitors API public interface ElementVisitor<R, P> { R visit(Element e,
P p); R visitPackage(PackageElement e, P p); R visitType(TypeElement e, P p); } -
Visitors API public interface ElementVisitor<R, P> { R visit(Element e,
P p); R visitPackage(PackageElement e, P p); R visitType(TypeElement e, P p); R visitVariable(VariableElement e, P p); } -
Visitors API public interface ElementVisitor<R, P> { R visit(Element e,
P p); R visitPackage(PackageElement e, P p); R visitType(TypeElement e, P p); R visitVariable(VariableElement e, P p); R visitExecutable(ExecutableElement e, P p); } -
Visitors API public interface ElementVisitor<R, P> { R visit(Element e,
P p); R visitPackage(PackageElement e, P p); R visitType(TypeElement e, P p); R visitVariable(VariableElement e, P p); R visitExecutable(ExecutableElement e, P p); R visitTypeParameter(TypeParameterElement e, P p); } -
Visitors API public interface ElementVisitor<R, P> { R visit(Element e,
P p); R visitPackage(PackageElement e, P p); R visitType(TypeElement e, P p); R visitVariable(VariableElement e, P p); R visitExecutable(ExecutableElement e, P p); R visitTypeParameter(TypeParameterElement e, P p); R visitUnknown(Element e, P p); } -
Visitors API class KotlinProcessor : AbstractProcessor() { override fun process(
annotations: Set<TypeElement>, roundEnv: RoundEnvironment ): Boolean { return false } } -
Visitors API class KotlinProcessor : AbstractProcessor() { override fun process(
annotations: Set<TypeElement>, roundEnv: RoundEnvironment ): Boolean { for (element in roundEnv.getElementsAnnotatedWith(Builder::class.java)) { }. return false } } -
Visitors API class KotlinProcessor : AbstractProcessor() { override fun process(
annotations: Set<TypeElement>, roundEnv: RoundEnvironment ): Boolean { for (element in roundEnv.getElementsAnnotatedWith(Builder::class.java)) { element.accept(visitor, null) }.. return false } } -
Visitors API class KotlinProcessor : AbstractProcessor() { override fun process(
annotations: Set<TypeElement>, roundEnv: RoundEnvironment ): Boolean { for (element in roundEnv.getElementsAnnotatedWith(Builder::class.java)) { val visitor = object : ElementScanner7<Unit, Unit>() { override fun visitVariable(e: VariableElement, p: Unit?) { handleVariable(e) } } element.accept(visitor, null) }. return false } } -
Visitors API class KotlinProcessor : AbstractProcessor() { override fun process(
annotations: Set<TypeElement>, roundEnv: RoundEnvironment ): Boolean { for (element in roundEnv.getElementsAnnotatedWith(Builder::class.java)) { val visitor = object : ElementScanner7<Unit, Unit>() { override fun visitVariable(e: VariableElement, p: Unit?) { handleVariable(e) } } element.accept(visitor, null) }. return false } } -
DOM-like API public interface Element { Element getEnclosingElement(); List<? extends
Element> getEnclosedElements(); } -
DOM-like API public interface Element { Element getEnclosingElement(); List<? extends
Element> getEnclosedElements(); ElementKind getKind(); } -
DOM-like API class KotlinProcessor : AbstractProcessor() { override fun process(
annotations: Set<TypeElement>, roundEnv: RoundEnvironment ): Boolean { for (element in roundEnv.getElementsAnnotatedWith(BindView::class.java)) { } return false } } -
DOM-like API class KotlinProcessor : AbstractProcessor() { override fun process(
annotations: Set<TypeElement>, roundEnv: RoundEnvironment ): Boolean { for (element in roundEnv.getElementsAnnotatedWith(BindView::class.java)) { } return false } } -
DOM-like API class KotlinProcessor : AbstractProcessor() { override fun process(
annotations: Set<TypeElement>, roundEnv: RoundEnvironment ): Boolean { for (element in roundEnv.getElementsAnnotatedWith(BindView::class.java)) { if (element.kind == ElementKind.FIELD) { handleVariable(element as VariableElement) }. } return false } } -
DOM-like API class KotlinProcessor : AbstractProcessor() { override fun process(
annotations: Set<TypeElement>, roundEnv: RoundEnvironment ): Boolean { for (element in roundEnv.getElementsAnnotatedWith(BindView::class.java)) { if (element.kind == ElementKind.FIELD) { handleVariable(element as VariableElement) }. } return false } } -
Visitors API abstract class KmFunctionVisitor abstract class KmPropertyVisitor abstract class
KmPackageVisitor abstract class KmClassVisitor abstract class KmConstructorVisitor abstract class KmValueParameterVisitor abstract class KmLambdaVisitor abstract class KmTypeVisitor abstract class KmTypeAliasVisitor abstract class KmTypeParameterVisitor -
Visitors API abstract class KmClassVisitor { open fun visitTypeParameter( flags:
Flags, name: String, id: Int, variance: KmVariance ): KmTypeParameterVisitor? }. -
Visitors API class Type<out E : UpperBoundType> abstract class KmClassVisitor
{ open fun visitTypeParameter( flags: Flags, name: String, id: Int, variance: KmVariance ): KmTypeParameterVisitor? }. -
Visitors API class Type<out E : UpperBoundType> abstract class KmClassVisitor
{ open fun visitTypeParameter( flags: Flags, name: String, id: Int, variance: KmVariance ): KmTypeParameterVisitor? }. -
Visitors API class Type<out E : UpperBoundType> abstract class KmClassVisitor
{ open fun visitTypeParameter( flags: Flags, name: String, id: Int, variance: KmVariance ): KmTypeParameterVisitor? }. -
Visitors API class Type<out E : UpperBoundType> abstract class KmClassVisitor
{ open fun visitTypeParameter( flags: Flags, name: String, id: Int, variance: KmVariance ): KmTypeParameterVisitor? }. -
Visitors API class Type<out E : UpperBoundType> abstract class KmClassVisitor
{ open fun visitTypeParameter( flags: Flags, name: String, id: Int, variance: KmVariance ): KmTypeParameterVisitor? }. -
Visitors API class Type<out E : UpperBoundType> abstract class KmClassVisitor
{ open fun visitTypeParameter( flags: Flags, name: String, id: Int, variance: KmVariance ): KmTypeParameterVisitor? }. -
Visitors API class Type<out E : UpperBoundType> abstract class KmClassVisitor
{ open fun visitTypeParameter( flags: Flags, name: String, id: Int, variance: KmVariance ): KmTypeParameterVisitor? }. -
Visitors API abstract class KmClassVisitor { open fun visitTypeParameter( flags:
Flags, name: String, id: Int, variance: KmVariance ): KmTypeParameterVisitor? }. -
Visitors API abstract class KmClassVisitor { open fun visitTypeParameter( flags:
Flags, name: String, id: Int, variance: KmVariance ): KmTypeParameterVisitor? }. interface ElementVisitor<R, P> { R visitTypeParameter( TypeParameterElement e, P p ); } -
Visitors API abstract class KmClassVisitor { open fun visitTypeParameter( flags:
Flags, name: String, id: Int, variance: KmVariance ): KmTypeParameterVisitor? }. interface ElementVisitor<R, P> { R visitTypeParameter( TypeParameterElement e, P p ); } -
Visitors API abstract class KmClassVisitor { open fun visitTypeParameter( flags:
Flags, name: String, id: Int, variance: KmVariance ): KmTypeParameterVisitor? }. interface ElementVisitor<R, P> { R visitTypeParameter( TypeParameterElement e, P p ); } -
GsonTypeAdapter @GsonAdapter data class User( val id: Long, val username:
String, val isAdmin: Boolean ) -
val annotation = GsonAdapter::class.java for (element in roundEnv.getElementsAnnotatedWith(annotation)) { val
input = getInputFrom(element) ?: continue if (!input.generateAndWrite()) return true } -
val annotation = GsonAdapter::class.java for (element in roundEnv.getElementsAnnotatedWith(annotation)) { val
input = getInputFrom(element) ?: continue if (!input.generateAndWrite()) return true } -
fun getMetadata(element: Element): KotlinClassMetadata? { val annotation = element.getAnnotation(Metadata::class.java) val
header = annotation.run { KotlinClassHeader(k, mv, bv, d1, d2, xs, pn, xi) }. return KotlinClassMetadata.read(header) }. -
fun getMetadata(element: Element): KotlinClassMetadata? { val annotation = element.getAnnotation(Metadata::class.java) val
header = annotation.run { KotlinClassHeader(k, mv, bv, d1, d2, xs, pn, xi) }. return KotlinClassMetadata.read(header) }. -
fun getMetadata(element: Element): KotlinClassMetadata? { val annotation = element.getAnnotation(Metadata::class.java) val
header = annotation.run { KotlinClassHeader(k, mv, bv, d1, d2, xs, pn, xi) }. return KotlinClassMetadata.read(header) }. -
fun getMetadata(element: Element): KotlinClassMetadata? { val annotation = element.getAnnotation(Metadata::class.java) val
header = annotation.run { KotlinClassHeader(k, mv, bv, d1, d2, xs, pn, xi) }. return KotlinClassMetadata.read(header) }. -
sealed class KotlinClassMetadata { class Class : KotlinClassMetadata class FileFacade
: KotlinClassMetadata class SyntheticClass : KotlinClassMetadata class MultiFileClassFacade : KotlinClassMetadata class MultiFileClassPart : KotlinClassMetadata class Unknown : KotlinClassMetadata } -
sealed class KotlinClassMetadata { class Class : KotlinClassMetadata class FileFacade
: KotlinClassMetadata class SyntheticClass : KotlinClassMetadata class MultiFileClassFacade : KotlinClassMetadata class MultiFileClassPart : KotlinClassMetadata class Unknown : KotlinClassMetadata } -
val metadata = getMetadata(element) if (metadata !is KotlinClassMetadata.Class) { errorMustBeKotlinClass(element)
return null }. metadata.accept(object : KmClassVisitor() { }) -
val metadata = getMetadata(element) if (metadata !is KotlinClassMetadata.Class) { errorMustBeKotlinClass(element)
return null }. metadata.accept(object : KmClassVisitor() { override fun visit(flags: Flags, name: ClassName) { } }) -
val metadata = getMetadata(element) if (metadata !is KotlinClassMetadata.Class) { errorMustBeKotlinClass(element)
return null }. metadata.accept(object : KmClassVisitor() { override fun visit(flags: Flags, name: ClassName) { pkg = name.substringBeforeLast('/').fqName() className = name.substringAfterLast('/') fqClassName = name.fqName() } }) -
return null }. metadata.accept(object : KmClassVisitor() { override fun visit(flags:
Flags, name: ClassName) { pkg = name.substringBeforeLast('/').fqName() className = name.substringAfterLast('/') fqClassName = name.fqName() } override fun visitConstructor(flags: Flags): KmConstructorVisitor? { } }) -
return null }. metadata.accept(object : KmClassVisitor() { override fun visit(flags:
Flags, name: ClassName) { pkg = name.substringBeforeLast('/').fqName() className = name.substringAfterLast('/') fqClassName = name.fqName() } override fun visitConstructor(flags: Flags): KmConstructorVisitor? { if (!flags.isPrimaryConstructor) return null } }) -
val Flags.isNullableType: Boolean get() = Flag.Type.IS_NULLABLE(this) val Flags.isDataClass: Boolean get()
= Flag.Class.IS_DATA(this) val Flags.isPrimaryConstructor: Boolean get() = Flag.Constructor.IS_PRIMARY(this) val Flags.hasDefaultValue: Boolean get() = Flag.ValueParameter.DECLARES_DEFAULT_VALUE(this) -
return null }. metadata.accept(object : KmClassVisitor() { override fun visit(flags:
Flags, name: ClassName) { pkg = name.substringBeforeLast('/').fqName() className = name.substringAfterLast('/') fqClassName = name.fqName() } override fun visitConstructor(flags: Flags): KmConstructorVisitor? { if (!flags.isPrimaryConstructor) return null } }) -
pkg = name.substringBeforeLast('/').fqName() className = name.substringAfterLast('/') fqClassName = name.fqName() }
override fun visitConstructor(flags: Flags): KmConstructorVisitor? { if (!flags.isPrimaryConstructor) return null return object : KmConstructorVisitor() { override fun visitValueParameter( flags: Flags, name: String ): KmValueParameterVisitor? { }. }. } }) -
} override fun visitConstructor(flags: Flags): KmConstructorVisitor? { if (!flags.isPrimaryConstructor) return
null return object : KmConstructorVisitor() { override fun visitValueParameter( flags: Flags, name: String ): KmValueParameterVisitor? { return object : KmValueParameterVisitor() { override fun visitType(flags: Flags): KmTypeVisitor? { return ... } } }. }. } }) -
return object :.KmTypeVisitor().{. override fun visitAbbreviatedType(flags: Flags): KmTypeVisitor? { }
override fun visitArgument( flags: Flags, variance: KmVariance ): KmTypeVisitor? { } }. -
class KmTypeInfoVisitor( private val flags: Flags, private val onVisitEnd: (KmTypeInfoVisitor)
-> Unit ) : KmTypeVisitor() {. }. -
class KmTypeInfoVisitor( private val flags: Flags, private val onVisitEnd: (KmTypeInfoVisitor)
-> Unit ) : KmTypeVisitor() {. lateinit var fqName: String var isNullable: Boolean = false private val typeArgs = arrayListOf<String>() }. -
class KmTypeInfoVisitor( private val flags: Flags, private val onVisitEnd: (KmTypeInfoVisitor)
-> Unit ) : KmTypeVisitor() { lateinit var fqName: String var isNullable: Boolean = false private val typeArgs = arrayListOf<String>() override fun visitEnd() { } }. -
private val onVisitEnd: (KmTypeInfoVisitor) -> Unit ) : KmTypeVisitor() {
lateinit var fqName: String var isNullable: Boolean = false private val typeArgs = arrayListOf<String>() override fun visitEnd() { if (typeArgs.isNotEmpty()) { fqName += typeArgs.joinToString(prefix = "<", postfix = ">") typeArgs.clear() }, isNullable = flags.isNullableType onVisitEnd(this) } }. -
fqName += typeArgs.joinToString(prefix = "<", postfix = ">") typeArgs.clear() },
isNullable = flags.isNullableType onVisitEnd(this) } override fun visitClass(name: ClassName) { fqName = name.fqName() }. }. -
onVisitEnd(this) } override fun visitClass(name: ClassName) { fqName = name.fqName()
}. override fun visitAbbreviatedType(flags: Flags): KmTypeVisitor? { return KmTypeInfoVisitor(flags, typeResolver) { fqName = it.fqName typeArgs.clear() }. }, }. -
onVisitEnd(this) } override fun visitClass(name: ClassName) { fqName = name.fqName()
}. override fun visitAbbreviatedType(flags: Flags): KmTypeVisitor? { return KmTypeInfoVisitor(flags, typeResolver) { fqName = it.fqName typeArgs.clear() }. }, }. -
fqName = name.fqName() }. override fun visitAbbreviatedType(flags: Flags): KmTypeVisitor? {
return KmTypeInfoVisitor(flags, typeResolver) { fqName = it.fqName typeArgs.clear() }. },’ override fun visitTypeAlias(name: ClassName) { fqName = name.fqName() }. }. -
return KmTypeInfoVisitor(flags, typeResolver) { fqName = it.fqName typeArgs.clear() }. },
override fun visitTypeAlias(name: ClassName) { fqName = name.fqName() }. override fun visitTypeParameter(id: Int) { fqName = typeResolver(id) ?: throw error("Missing param: id=$id") }, }. -
override fun visitTypeAlias(name: ClassName) { fqName = name.fqName() }. override
fun visitTypeParameter(id: Int) { fqName = typeResolver(id) ?: throw error("Missing param: id=$id") }, override fun visitArgument( flags: Flags, variance: KmVariance ): KmTypeVisitor? { return KmTypeInfoVisitor(flags, typeResolver) { typeArgs += it.fqName }, }, }. -
override fun visitTypeAlias(name: ClassName) { fqName = name.fqName() }. override
fun visitTypeParameter(id: Int) { fqName = typeResolver(id) ?: throw error("Missing param: id=$id") }, override fun visitArgument( flags: Flags, variance: KmVariance ): KmTypeVisitor? { return KmTypeInfoVisitor(flags, typeResolver) { typeArgs += it.fqName },. }, }. -
} override fun visitConstructor(flags: Flags): KmConstructorVisitor? { if (!flags.isPrimaryConstructor) return
null return object : KmConstructorVisitor() { override fun visitValueParameter( flags: Flags, name: String ): KmValueParameterVisitor? { return object : KmValueParameterVisitor() { override fun visitType(flags: Flags): KmTypeVisitor? { return ... }. }. }. }. } }) -
} override fun visitConstructor(flags: Flags): KmConstructorVisitor? { if (!flags.isPrimaryConstructor) return
null return object : KmConstructorVisitor() { override fun visitValueParameter( flags: Flags, name: String ): KmValueParameterVisitor? { return object : KmValueParameterVisitor() { override fun visitType(flags: Flags): KmTypeVisitor? { return KmTypeInfoVisitor(flags, typeArgsRegistry::get) { parameters += Parameter(name, it.fqName, it.isNullable) } }. }. }. }. } }) -
Worth noting • Metadata has only partial info • Separate
code model from generation -
Worth noting • Metadata has only partial info • Separate
code model from generation • Both Kotlin & Java can be supported in one place -
Worth noting • Metadata has only partial info • Separate
code model from generation • Both Kotlin & Java can be supported in one place • Multiplatform support will follow -
Other applications? • Annotation processing with codegen • Bytecode weaving
• Code validation • Generating headers for interop with other languages: TypeScript, C/C++ -
Links • Metadata ProtoBuffer spec: github.com/JetBrains/kotlin/blob/master/core/metadata/src/metadata.proto • kotlin-metadata by Eugenio
Marletti: github.com/Takhion/kotlin-metadata • kotlinx-metadata by JetBrains: github.com/JetBrains/kotlin/tree/master/libraries/kotlinx-metadata/jvm • Value-based API for kotlinx-metadata: youtrack.jetbrains.com/issue/KT-26602 • Gson TypeAdapters codegen: github.com/colriot/GsonKotgen • KotlinPoet: github.com/square/kotlinpoet • Annotation Processing in a Kotlin World by Zac Sweers: youtu.be/_yaaCtWF8aE?t=18968 • Annotation Processing Boilerplate Destruction by Jake Wharton: youtu.be/dOcs-NKK-RA • Multiple KAPT rounds demo: github.com/Takhion/generate-kotlin-multiple-rounds