
Enables compile-time code generation using KTE templates with an annotation for generating source files. Offers fast, incremental processing with flexible, type-safe template support.
SimpleKsp is a Kotlin Symbol Processing (KSP) library that enables compile-time code generation using KTE (Part of JTE) templates. It provides a simple annotation, @GenerateCode, to generate Kotlin source files based on template strings.
@file:GenerateCode to trigger generation from any Kotlin file.Gradle Kotlin DSL:
plugins {
id("com.google.devtools.ksp") version "<ksp version>"
}
dependencies {
compileOnly("io.github.stream29:kteksp-annotation:<version>")
ksp("io.github.stream29:kteksp-ksp:<version>")
}As KSP does not officially support Maven, we don't plan to support Maven.
If you still want to use this library with maven, please look at community KSP support of maven.
Use the @file:GenerateCode annotation at the top of a Kotlin file to specify generation parameters:
@file:GenerateCode(
packageName = "io.github.stream29.kteksp",
fileName = "Generated$0",
template =
"""
@file:GenerateCode(
packageName = \"io.github.stream29.kteksp\",
fileName = \"Generated$1\",
template = \"\"
)
package io.github.stream29.kteksp
"""
)
package io.github.stream29.kteksppackageName: The package for the generated file. If empty, uses the current package.fileName: The name of the generated file (without .kt). Supports template variables.template: The KTE template string for the generated file content.Run the build. The KSP processor will generate the specified files in the build/generated/ksp/ directory.
@Target(AnnotationTarget.FILE)
public annotation class GenerateCode(
val packageName: String = "",
val fileName: String = "",
@Language("kte")
val template: String,
).kt).See Generate.kt for a real usage example.
SimpleKsp is a Kotlin Symbol Processing (KSP) library that enables compile-time code generation using KTE (Part of JTE) templates. It provides a simple annotation, @GenerateCode, to generate Kotlin source files based on template strings.
@file:GenerateCode to trigger generation from any Kotlin file.Gradle Kotlin DSL:
plugins {
id("com.google.devtools.ksp") version "<ksp version>"
}
dependencies {
compileOnly("io.github.stream29:kteksp-annotation:<version>")
ksp("io.github.stream29:kteksp-ksp:<version>")
}As KSP does not officially support Maven, we don't plan to support Maven.
If you still want to use this library with maven, please look at community KSP support of maven.
Use the @file:GenerateCode annotation at the top of a Kotlin file to specify generation parameters:
@file:GenerateCode(
packageName = "io.github.stream29.kteksp",
fileName = "Generated$0",
template =
"""
@file:GenerateCode(
packageName = \"io.github.stream29.kteksp\",
fileName = \"Generated$1\",
template = \"\"
)
package io.github.stream29.kteksp
"""
)
package io.github.stream29.kteksppackageName: The package for the generated file. If empty, uses the current package.fileName: The name of the generated file (without .kt). Supports template variables.template: The KTE template string for the generated file content.Run the build. The KSP processor will generate the specified files in the build/generated/ksp/ directory.
@Target(AnnotationTarget.FILE)
public annotation class GenerateCode(
val packageName: String = "",
val fileName: String = "",
@Language("kte")
val template: String,
).kt).See Generate.kt for a real usage example.