@@ -401,7 +401,7 @@ class KotlinCompilation {
401401 }
402402
403403 /* * Performs the 1st and 2nd compilation step to generate stubs and run annotation processors */
404- private fun stubsAndApt (): ExitCode {
404+ private fun stubsAndApt (sourceFiles : List < File > ): ExitCode {
405405 if (annotationProcessors.isEmpty()) {
406406 log(" No services were given. Not running kapt steps." )
407407 return ExitCode .OK
@@ -434,8 +434,8 @@ class KotlinCompilation {
434434 )
435435 )
436436
437- val kotlinSources = sourcesDir.listFilesRecursively(). filter< File > (File ::isKotlinFile)
438- val javaSources = sourcesDir.listFilesRecursively() .filter(File ::isJavaFile)
437+ val kotlinSources = sourceFiles. filter(File ::isKotlinFile)
438+ val javaSources = sourceFiles .filter(File ::isJavaFile)
439439
440440 val sourcePaths = mutableListOf<File >().apply {
441441 addAll(javaSources)
@@ -503,8 +503,8 @@ class KotlinCompilation {
503503 }
504504
505505 /* * Performs the 3rd compilation step to compile Kotlin source files */
506- private fun compileKotlin (): ExitCode {
507- val sources = sourcesDir.listFilesRecursively() +
506+ private fun compileKotlin (sourceFiles : List < File > ): ExitCode {
507+ val sources = sourceFiles +
508508 kaptKotlinGeneratedDir.listFilesRecursively() +
509509 kaptSourceDir.listFilesRecursively()
510510
@@ -557,8 +557,8 @@ class KotlinCompilation {
557557 }
558558
559559 /* * Performs the 4th compilation step to compile Java source files */
560- private fun compileJava (): ExitCode {
561- val javaSources = (sourcesDir.listFilesRecursively() + kaptSourceDir.listFilesRecursively())
560+ private fun compileJava (sourceFiles : List < File > ): ExitCode {
561+ val javaSources = (sourceFiles + kaptSourceDir.listFilesRecursively())
562562 .filterNot<File >(File ::isKotlinFile)
563563
564564 if (javaSources.isEmpty())
@@ -660,7 +660,7 @@ class KotlinCompilation {
660660 kaptKotlinGeneratedDir.mkdirs()
661661
662662 // write given sources to working directory
663- sources.forEach { it.writeIfNeeded(sourcesDir) }
663+ val sourceFiles = sources.map { it.writeIfNeeded(sourcesDir) }
664664
665665 /*
666666 There are 4 steps to the compilation process:
@@ -679,7 +679,7 @@ class KotlinCompilation {
679679 withSystemProperty(" idea.use.native.fs.for.win" , " false" ) {
680680 // step 1 and 2: generate stubs and run annotation processors
681681 try {
682- val exitCode = stubsAndApt()
682+ val exitCode = stubsAndApt(sourceFiles )
683683 if (exitCode != ExitCode .OK ) {
684684 val messages = internalMessageBuffer.readUtf8()
685685 searchSystemOutForKnownErrors(messages)
@@ -690,7 +690,7 @@ class KotlinCompilation {
690690 }
691691
692692 // step 3: compile Kotlin files
693- compileKotlin().let { exitCode ->
693+ compileKotlin(sourceFiles ).let { exitCode ->
694694 if (exitCode != ExitCode .OK ) {
695695 val messages = internalMessageBuffer.readUtf8()
696696 searchSystemOutForKnownErrors(messages)
@@ -700,7 +700,7 @@ class KotlinCompilation {
700700 }
701701
702702 // step 4: compile Java files
703- compileJava().let { exitCode ->
703+ compileJava(sourceFiles ).let { exitCode ->
704704 val messages = internalMessageBuffer.readUtf8()
705705
706706 if (exitCode != ExitCode .OK )
0 commit comments