summaryrefslogtreecommitdiff
path: root/plugins/kotlin/jvm/src/org/jetbrains/kotlin/idea/compiler/configuration/KotlinBuildProcessParametersProvider.kt
blob: c0a6ed051ba40085561c4f5a8a1bc45f84510f08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.

package org.jetbrains.kotlin.idea.compiler.configuration

import com.intellij.compiler.server.BuildProcessParametersProvider
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.registry.Registry
import org.jetbrains.kotlin.config.IncrementalCompilation
import org.jetbrains.kotlin.idea.PluginStartupApplicationService
import org.jetbrains.kotlin.idea.artifacts.KotlinArtifacts

class KotlinBuildProcessParametersProvider(private val project: Project) : BuildProcessParametersProvider() {
    override fun getVMArguments(): MutableList<String> {
        val compilerWorkspaceSettings = KotlinCompilerWorkspaceSettings.getInstance(project)

        val res = arrayListOf<String>()
        if (compilerWorkspaceSettings.preciseIncrementalEnabled) {
            res.add("-D" + IncrementalCompilation.INCREMENTAL_COMPILATION_JVM_PROPERTY + "=true")
        }
        if (compilerWorkspaceSettings.incrementalCompilationForJsEnabled) {
            res.add("-D" + IncrementalCompilation.INCREMENTAL_COMPILATION_JS_PROPERTY + "=true")
        }
        if (compilerWorkspaceSettings.enableDaemon) {
            res.add("-Dkotlin.daemon.enabled")
        }
        if (Registry.`is`("kotlin.jps.instrument.bytecode", false)) {
            res.add("-Dkotlin.jps.instrument.bytecode=true")
        }
        PluginStartupApplicationService.getInstance().aliveFlagPath.let {
            if (!it.isBlank()) {
                // TODO: consider taking the property name from compiler/daemon/common (check whether dependency will be not too heavy)
                res.add("-Dkotlin.daemon.client.alive.path=\"$it\"")
            }
        }
        return res
    }

    override fun getAdditionalPluginPaths(): Iterable<String> {
        return listOf(KotlinArtifacts.instance.kotlincDirectory.path)
    }
}