From 166ce6a2ea2824c4b990cbbf8a422b89e62b1019 Mon Sep 17 00:00:00 2001 From: Andrei Klunnyi Date: Mon, 30 Nov 2020 15:44:37 +0000 Subject: [PATCH] KTIJ-585 [Gradle Runner]: main() cannot be launched from AS 4.1 Android gradle-project model differs from what we have for pure Java and MPP. It's the reason why application classpath cannot be collected correctly. Until universal solution is provided delegation to gradle is put under the registry flag. If disable platform runner is used as before. (cherry picked from commit 4817d5e01d5484175b3b3c683b80771326bd7e2b) --- .../idea/gradle/execution/KotlinGradleAppEnvProvider.kt | 6 +++++- idea/resources/META-INF/extensions/ide.xml | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/gradle/execution/KotlinGradleAppEnvProvider.kt b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/gradle/execution/KotlinGradleAppEnvProvider.kt index a4b6cbb3d220c..8ab96c3aaa68d 100644 --- a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/gradle/execution/KotlinGradleAppEnvProvider.kt +++ b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/gradle/execution/KotlinGradleAppEnvProvider.kt @@ -33,6 +33,7 @@ import com.intellij.openapi.projectRoots.ex.JavaSdkUtil import com.intellij.openapi.roots.ModuleRootManager import com.intellij.openapi.roots.ProjectFileIndex import com.intellij.openapi.util.io.FileUtil +import com.intellij.openapi.util.registry.Registry import com.intellij.openapi.util.text.StringUtil import com.intellij.psi.PsiClass import com.intellij.psi.PsiJavaModule @@ -50,7 +51,10 @@ import org.jetbrains.plugins.gradle.util.GradleConstants */ class KotlinGradleAppEnvProvider : GradleExecutionEnvironmentProvider { - override fun isApplicable(task: ExecuteRunConfigurationTask): Boolean = task.runProfile is KotlinRunConfiguration + override fun isApplicable(task: ExecuteRunConfigurationTask): Boolean { + val enabled = Registry.`is`("kotlin.gradle-run.enabled", false) + return enabled && task.runProfile is KotlinRunConfiguration + } override fun createExecutionEnvironment( project: Project, executeRunConfigurationTask: ExecuteRunConfigurationTask, executor: Executor? diff --git a/idea/resources/META-INF/extensions/ide.xml b/idea/resources/META-INF/extensions/ide.xml index 6242950216ec6..64675b749d5f5 100644 --- a/idea/resources/META-INF/extensions/ide.xml +++ b/idea/resources/META-INF/extensions/ide.xml @@ -133,6 +133,11 @@ defaultValue="false" restartRequired="false"/> + +