The one-stop lib for code generation for kotlin (jvm) and code generation testing. Based on kotlin-poet.
Usage:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.toolisticon.kotlin.generation</groupId>
<artifactId>kotlin-code-generation-bom</artifactId>
<version>LATEST_VERSION</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
This code generation lib wraps the fantastic kotlin-poet framework. The documentation is based on the kotlin-poet documentation.
Core concept are Strategies and Processors.
- Implement and list your strategies and processors in the
META-INF/services/io.toolisticon.kotlin.generation.spi.KotlinCodeGenerationSpi
. Both interfaces are loaded via the same ServiceLoader mechanism, and later filtered for the specific type of strategy or processor. - Load the services via
val spi = KotlinCodeGeneration.spi.load()
- Define your context by extending the
KotlinCodeGenerationContext
class. This context is passed to the strategies and processors, so they can use more data than just the input item in the loop.- You probably want to filter the loaded list you provide to your specific context.
- KotlinAnnotationSpec
- KotlinAnnotationSpecBuilder
- KotlinFileSpec
- KotlinFileSpecBuilder
- KotlinFunSpec
- KotlinFunSpecBuilder
- KotlinParameterSpec
- KotlinParameterSpecBuilder
- KotlinPropertySpec
- KotlinPropertySpecBuilder
- com/squareup/kotlinpoet/TypeAliasSpec
- com/squareup/kotlinpoet/TypeSpec
- com/squareup/kotlinpoet/AnnotationSpec$Builder
- Taggable.Builder
- com/squareup/kotlinpoet/CodeBlock$Builder
- None
- com/squareup/kotlinpoet/FileSpec$Builder
- Annotatable.Builder
- Taggable.Builder
- TypeSpecHolder.Builder
- com/squareup/kotlinpoet/FunSpec$Builder
- Annotatable.Builder
- ContextReceivable.Builder
- Documentable.Builder
- Taggable.Builder
- OriginatingElementsHolder.Builder
- com/squareup/kotlinpoet/ParameterSpec$Builder
- Annotatable.Builder
- Documentable.Builder
- Taggable.Builder
- com/squareup/kotlinpoet/PropertySpec$Builder
- Annotatable.Builder
- ContextReceivable.Builder
- Documentable.Builder
- OriginatingElementsHolder.Builder
- Taggable.Builder
- com/squareup/kotlinpoet/TypeAliasSpec$Builder
- Annotatable.Builder
- Documentable.Builder
- Taggable.Builder