1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 08:27:12 -07:00

GH-403: Honor Kotlin compiler flags in process.

Fixes https://github.com/cbeust/kobalt/issues/403
This commit is contained in:
Cedric Beust 2017-04-11 10:43:27 -07:00
parent 2e6f14007a
commit 49d058e3e1

View file

@ -90,7 +90,7 @@ class KotlinCompiler @Inject constructor(
return invokeCompilerInSeparateProcess(classpath, info, actualVersion, project)
} else {
return invokeCompilerDirectly(projectName ?: "kobalt-" + Random().nextInt(), outputDir,
return invokeCompilerDirectly(project, projectName ?: "kobalt-" + Random().nextInt(), outputDir,
info, classpath, filesToCompile)
}
}
@ -129,11 +129,20 @@ class KotlinCompiler @Inject constructor(
return TaskResult(result == 0, errorMessage = "Error while compiling")
}
private fun invokeCompilerDirectly(projectName: String, outputDir: String?, info: CompilerActionInfo,
classpathString: String, filesToCompile: Int): TaskResult {
private fun invokeCompilerDirectly(project: Project?, projectName: String, outputDir: String?,
info: CompilerActionInfo, classpathString: String, filesToCompile: Int): TaskResult {
val sourceFiles = info.sourceFiles
val friends = info.friendPaths.toTypedArray()
val args = K2JVMCompilerArguments().apply {
// Collect the compiler args from kotlinCompiler{} and from settings.xml and parse them
val args2 = (kotlinConfig(project)?.args ?: arrayListOf<String>()) +
(settings.kobaltCompilerFlags?.split(" ") ?: listOf<String>())
val args = K2JVMCompilerArguments()
val compiler = K2JVMCompiler()
compiler.parseArguments(args2.toTypedArray(), args)
// Override important arguments with our values
args.apply {
moduleName = projectName
destination = outputDir
classpath = classpathString
@ -224,7 +233,7 @@ class KotlinCompiler @Inject constructor(
if (cliArgs.noIncrementalKotlin || Kobalt.context?.internalContext?.noIncrementalKotlin ?: false) {
log(2, " Kotlin incremental compilation is disabled")
val duration = benchmarkMillis {
K2JVMCompiler().exec(collector, Services.Builder().build(), args)
compiler.exec(collector, Services.Builder().build(), args)
}
log(1, " Regular compilation time: ${duration.first} ms")
TaskResult(duration.second == ExitCode.OK)