Skip to content

Commit

Permalink
KTIJ-585 [Gradle Runner]: main() cannot be launched from AS 4.1
Browse files Browse the repository at this point in the history
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 4817d5e)
  • Loading branch information
klunnii committed Nov 30, 2020
1 parent 5e23440 commit 166ce6a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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?
Expand Down
5 changes: 5 additions & 0 deletions idea/resources/META-INF/extensions/ide.xml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@
defaultValue="false"
restartRequired="false"/>

<registryKey key="kotlin.gradle-run.enabled"
description="Enable delegation of app running to gradle"
defaultValue="false"
restartRequired="false"/>

<fileEditorProvider implementation="org.jetbrains.kotlin.idea.scratch.ui.KtScratchFileEditorProvider"/>

<jbProtocolCommand implementation="org.jetbrains.kotlin.tools.projectWizard.wizard.OpenNewProjectWizardProtocolCommand"/>
Expand Down

0 comments on commit 166ce6a

Please sign in to comment.