Skip to content

Commit 2e0c92d

Browse files
vRallevtschuchortdev
authored andcommitted
Expose the API to pass flags to KAPT.
1 parent c25709d commit 2e0c92d

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

core/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ dependencies {
3636
// The Kotlin compiler should be near the end of the list because its .jar file includes
3737
// an obsolete version of Guava
3838
api "org.jetbrains.kotlin:kotlin-compiler-embeddable:$embedded_kotlin_version"
39-
implementation "org.jetbrains.kotlin:kotlin-annotation-processing-embeddable:$embedded_kotlin_version"
39+
api "org.jetbrains.kotlin:kotlin-annotation-processing-embeddable:$embedded_kotlin_version"
4040
}
4141

4242
compileKotlin {

core/src/main/kotlin/com/tschuchort/compiletesting/KotlinCompilation.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ class KotlinCompilation : AbstractKotlinCompilation<K2JVMCompilerArguments>() {
5252
/** Arbitrary arguments to be passed to kapt */
5353
var kaptArgs: MutableMap<OptionName, OptionValue> = mutableMapOf()
5454

55+
/** Arbitrary flags to be passed to kapt */
56+
var kaptFlags: MutableSet<KaptFlag> = mutableSetOf()
57+
5558
/** Annotation processors to be passed to kapt */
5659
var annotationProcessors: List<Processor> = emptyList()
5760

@@ -370,8 +373,13 @@ class KotlinCompilation : AbstractKotlinCompilation<K2JVMCompilerArguments>() {
370373

371374
it.mode = AptMode.STUBS_AND_APT
372375

373-
if (verbose)
374-
it.flags.addAll(KaptFlag.MAP_DIAGNOSTIC_LOCATIONS, KaptFlag.VERBOSE)
376+
it.flags.apply {
377+
addAll(kaptFlags)
378+
379+
if (verbose) {
380+
addAll(KaptFlag.MAP_DIAGNOSTIC_LOCATIONS, KaptFlag.VERBOSE)
381+
}
382+
}
375383
}
376384

377385
val compilerMessageCollector = PrintingMessageCollector(

0 commit comments

Comments
 (0)