https://github.com/fluidsonic/fluid-compiler
Compile Kotlin code and run Kapt annotation processing directly from Kotlin
https://github.com/fluidsonic/fluid-compiler
Last synced: 9 months ago
JSON representation
Compile Kotlin code and run Kapt annotation processing directly from Kotlin
- Host: GitHub
- URL: https://github.com/fluidsonic/fluid-compiler
- Owner: fluidsonic
- License: apache-2.0
- Created: 2019-03-02T21:03:55.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-06-24T02:19:31.000Z (over 2 years ago)
- Last Synced: 2025-03-27T19:41:42.753Z (10 months ago)
- Language: Kotlin
- Size: 258 KB
- Stars: 12
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
fluid-compiler
==============
[](https://search.maven.org/artifact/io.fluidsonic.compiler/fluid-compiler)
[](https://github.com/JetBrains/kotlin/releases/v1.8.22)
[](https://kotlinlang.slack.com/messages/C7UDFSVT2/)
Compile Kotlin code and run Kapt annotation processing directly from Kotlin, for example to unit test your annotation processors!
Installation
------------
`build.gradle.kts`:
```kotlin
dependencies {
implementation("io.fluidsonic.compiler:fluid-compiler:0.13.0")
}
```
Example
-------
```kotlin
import io.fluidsonic.compiler.*
val result = KotlinCompiler()
.includesCurrentClasspath()
.jvmTarget(KotlinJvmTarget.v1_8)
.processors(MyAnnotationProcessor())
.sources("sources", "more-sources/Example.kt")
.compile()
// result.exitCode contains the exit code of the compiler
// result.messages contains all messages printed during compilation and annotation processing
// result.generatedFiles contains all files generated by annotation processors
```
### Additional configuration
```kotlin
.destination("output")
.kotlinHome("/path/to/kotlin/home")
.moduleName("my-module")
```
### Manually setting compiler arguments
```kotlin
.arguments {
apiVersion = "1.4"
languageVersion = "1.6"
newInference = true
}
```
For a complete list of all compiler arguments check out
[K2JVMCompilerArguments](https://github.com/JetBrains/kotlin/blob/master/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt)
.
### Manually setting Kapt options
```kotlin
.kaptOptions {
flags += KaptFlag.CORRECT_ERROR_TYPES
mode = AptMode.STUBS_AND_APT
}
```
For a complete list of all Kapt options check out
[KaptOptions](https://github.com/JetBrains/kotlin/blob/master/plugins/kapt3/kapt3-base/src/org/jetbrains/kotlin/kapt3/base/KaptOptions.kt).
License
-------
Apache 2.0