1313 * See the License for the specific language governing permissions and
1414 * limitations under the License.
1515 */
16- package com.tschuchort.compiletest
1716
17+ import com.tschuchort.compiletest.NullStream
18+ import com.tschuchort.compiletest.TeeOutputStream
1819import io.github.classgraph.ClassGraph
1920import okio.Buffer
2021import okio.buffer
@@ -65,39 +66,39 @@ open class KotlinCompilation(
6566 * process' classpaths
6667 */
6768 val kotlinStdLibJar : File ? = findKtStdLib(
68- log = { if(verbose) systemOut.log(it) }
69+ log = { if (verbose) systemOut.log(it) }
6970 ),
7071 /* *
7172 * Path to the kotlin-stdlib-jdk*.jar
7273 * If none is given, it will be searched for in the host
7374 * process' classpaths
7475 */
7576 val kotlinStdLibJdkJar : File ? = findKtStdLibJdk(
76- log = { if(verbose) systemOut.log(it) }
77+ log = { if (verbose) systemOut.log(it) }
7778 ),
7879 /* *
7980 * Path to the kotlin-reflect.jar
8081 * If none is given, it will be searched for in the host
8182 * process' classpaths
8283 */
8384 val kotlinReflectJar : File ? = findKtReflect(
84- log = { if(verbose) systemOut.log(it) }
85+ log = { if (verbose) systemOut.log(it) }
8586 ),
8687 /* *
8788 * Path to the kotlin-script-runtime.jar
8889 * If none is given, it will be searched for in the host
8990 * process' classpaths
9091 */
9192 val kotlinScriptRuntimeJar : File ? = findKtScriptRt(
92- log = { if(verbose) systemOut.log(it) }
93+ log = { if (verbose) systemOut.log(it) }
9394 ),
9495 /* *
9596 * Path to the kotlin-stdlib-common.jar
9697 * If none is given, it will be searched for in the host
9798 * process' classpaths
9899 */
99100 val kotlinStdLibCommonJar : File ? = findKtStdLibCommon(
100- log = { if(verbose) systemOut.log(it) }
101+ log = { if (verbose) systemOut.log(it) }
101102 ),
102103 /* *
103104 * Path to the tools.jar file needed for kapt when using a JDK 8.
@@ -106,17 +107,17 @@ open class KotlinCompilation(
106107 * internal compiler error!
107108 */
108109 val toolsJar : File ? = findToolsInHostClasspath(
109- log = { if(verbose) systemOut.log(it) }
110- ),
110+ log = { if (verbose) systemOut.log(it) }
111+ ),
111112 /* *
112113 * Path to the kotlin-annotation-processing-embeddable*.jar that
113114 * contains kapt3.
114115 *
115116 * Only needed when [services] is not empty.
116117 */
117118 val kapt3Jar : File ? = findKapt3(
118- log = { if(verbose) systemOut.log(it) }
119- ),
119+ log = { if (verbose) systemOut.log(it) }
120+ ),
120121 /* * Inherit classpath from calling process */
121122 val inheritClassPath : Boolean = false ,
122123 val jvmTarget : String? = null ,
@@ -272,6 +273,7 @@ open class KotlinCompilation(
272273 // Don't forget aptMode! Without it, the compiler will crash with an obscure error about
273274 // write unsafe context
274275 " plugin:org.jetbrains.kotlin.kapt3:aptMode=stubsAndApt" ,
276+ " plugin:org.jetbrains.kotlin.kapt3:mapDiagnosticLocations=true" ,
275277 * if (verbose)
276278 arrayOf(" plugin:org.jetbrains.kotlin.kapt3:verbose=true" )
277279 else
@@ -370,7 +372,8 @@ open class KotlinCompilation(
370372 val compilerSystemOutBuffer = Buffer () // Buffer for capturing compiler's logging output
371373 val compilerMessageCollector = PrintingMessageCollector (
372374 PrintStream (
373- TeeOutputStream (systemOut, compilerSystemOutBuffer.outputStream())),
375+ TeeOutputStream (systemOut, compilerSystemOutBuffer.outputStream())
376+ ),
374377 MessageRenderer .WITHOUT_PATHS , true )
375378
376379 /*
@@ -462,34 +465,46 @@ open class KotlinCompilation(
462465
463466 /* * Tries to find the kotlin-stdlib.jar in the host process' classpath */
464467 fun findKtStdLib (log : ((String ) -> Unit )? = null)
465- = findInHostClasspath(" kotlin-stdlib.jar" ,
466- Regex (" (kotlin-stdlib|kotlin-runtime)(-[0-9]+\\ .[0-9]+\\ .[0-9]+)\\ .jar" ), log)
468+ = findInHostClasspath(
469+ " kotlin-stdlib.jar" ,
470+ Regex (" (kotlin-stdlib|kotlin-runtime)(-[0-9]+\\ .[0-9]+\\ .[0-9]+)\\ .jar" ), log
471+ )
467472 // kotlin-stdlib.jar used to be kotlin-runtime.jar in <1.1
468473
469474 /* * Tries to find the kotlin-stdlib-jdk*.jar in the host process' classpath */
470475 fun findKtStdLibJdk (log : ((String ) -> Unit )? = null)
471- = findInHostClasspath(" kotlin-stdlib-jdk*.jar" ,
472- Regex (" kotlin-stdlib-jdk[0-9]+(-[0-9]+\\ .[0-9]+\\ .[0-9]+)\\ .jar" ), log)
476+ = findInHostClasspath(
477+ " kotlin-stdlib-jdk*.jar" ,
478+ Regex (" kotlin-stdlib-jdk[0-9]+(-[0-9]+\\ .[0-9]+\\ .[0-9]+)\\ .jar" ), log
479+ )
473480
474481 /* * Tries to find the kotlin-stdlib-common.jar in the host process' classpath */
475482 fun findKtStdLibCommon (log : ((String ) -> Unit )? = null)
476- = findInHostClasspath(" kotlin-stdlib-common.jar" ,
477- Regex (" kotlin-stdlib-common(-[0-9]+\\ .[0-9]+\\ .[0-9]+)\\ .jar" ), log)
483+ = findInHostClasspath(
484+ " kotlin-stdlib-common.jar" ,
485+ Regex (" kotlin-stdlib-common(-[0-9]+\\ .[0-9]+\\ .[0-9]+)\\ .jar" ), log
486+ )
478487
479488 /* * Tries to find the kotlin-reflect.jar in the host process' classpath */
480489 fun findKtReflect (log : ((String ) -> Unit )? = null)
481- = findInHostClasspath(" kotlin-reflect.jar" ,
482- Regex (" kotlin-reflect(-[0-9]+\\ .[0-9]+\\ .[0-9]+)\\ .jar" ), log)
490+ = findInHostClasspath(
491+ " kotlin-reflect.jar" ,
492+ Regex (" kotlin-reflect(-[0-9]+\\ .[0-9]+\\ .[0-9]+)\\ .jar" ), log
493+ )
483494
484495 /* * Tries to find the kotlin-script-runtime.jar in the host process' classpath */
485496 fun findKtScriptRt (log : ((String ) -> Unit )? = null)
486- = findInHostClasspath(" kotlin-script-runtime.jar" ,
487- Regex (" kotlin-script-runtime(-[0-9]+\\ .[0-9]+\\ .[0-9]+)\\ .jar" ), log)
497+ = findInHostClasspath(
498+ " kotlin-script-runtime.jar" ,
499+ Regex (" kotlin-script-runtime(-[0-9]+\\ .[0-9]+\\ .[0-9]+)\\ .jar" ), log
500+ )
488501
489502 /* * Tries to find the kapt 3 jar in the host process' classpath */
490503 fun findKapt3 (log : ((String ) -> Unit )? = null)
491- = findInHostClasspath(" kotlin-annotation-processing(-embeddable).jar" ,
492- Regex (" kotlin-annotation-processing(-(embeddable|gradle|maven))?(-[0-9]+\\ .[0-9]+\\ .[0-9]+)?\\ .jar" ), log)
504+ = findInHostClasspath(
505+ " kotlin-annotation-processing(-embeddable).jar" ,
506+ Regex (" kotlin-annotation-processing(-(embeddable|gradle|maven))?(-[0-9]+\\ .[0-9]+\\ .[0-9]+)?\\ .jar" ), log
507+ )
493508
494509
495510 /* * Tries to find the tools.jar needed for kapt in the host process' classpath */
0 commit comments