diff --git a/buildSrc/src/main/kotlin/NoDebugJavaExec.kt b/buildSrc/src/main/kotlin/NoDebugJavaExec.kt new file mode 100644 index 00000000000..79186174aba --- /dev/null +++ b/buildSrc/src/main/kotlin/NoDebugJavaExec.kt @@ -0,0 +1,19 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + +import org.gradle.api.tasks.JavaExec + +/** + * Workaround for IDEA-200192: + * IDEA makes all JavaExec tasks not up-to-date and attaches debugger making our breakpoints trigger during irrelevant task execution + */ +open class NoDebugJavaExec : JavaExec() { + private fun String.isDebuggerArgument(): Boolean = + startsWith("-agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=") + + override fun setJvmArgs(arguments: MutableList?) { + super.setJvmArgs(arguments?.filterNot { it.isDebuggerArgument() }) + } +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/UtilityJavaExec.kt b/buildSrc/src/main/kotlin/UtilityJavaExec.kt deleted file mode 100644 index 35a35d5aef5..00000000000 --- a/buildSrc/src/main/kotlin/UtilityJavaExec.kt +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the license/LICENSE.txt file. - */ - -import org.apache.tools.ant.types.Commandline -import org.gradle.api.internal.ConventionTask -import org.gradle.api.tasks.Input -import org.gradle.api.tasks.Internal -import org.gradle.api.tasks.Optional -import org.gradle.api.tasks.TaskAction -import org.gradle.api.tasks.options.Option -import org.gradle.process.JavaExecSpec -import org.gradle.process.internal.ExecActionFactory -import org.gradle.process.internal.JavaExecAction -import java.io.File -import java.io.InputStream -import java.io.OutputStream -import java.util.* -import javax.inject.Inject - -/** - * This task does the same as original JavaExec task - * We avoid using JavaExec tasks due to IDEA-200192: - * IDEA makes all JavaExec tasks not up-to-date and attaches debugger making our breakpoints trigger during irrelevant task execution - */ -open class UtilityJavaExec( - private val javaExecAction: JavaExecAction -) : ConventionTask(), JavaExecSpec by javaExecAction { - - @Inject - constructor(execActionFactory: ExecActionFactory) : this(execActionFactory.newJavaExecAction()) - - @TaskAction - fun exec() { - // like in original JavaExec task - main = main // make convention mapping work (at least for 'main'... - jvmArgs = jvmArgs // ...and for 'jvmArgs') - - javaExecAction.execute() - } - - - @Option( - option = "debug-jvm", - description = "Enable debugging for the process. The process is started suspended and listening on port 5005. [INCUBATING]" - ) - override fun setDebug(enabled: Boolean) { - javaExecAction.debug = enabled - } - - - @Option(option = "args", description = "Command line arguments passed to the main class. [INCUBATING]") - fun setArgsString(args: String): JavaExecSpec { - return setArgs(Arrays.asList(*Commandline.translateCommandline(args))) - } - - @Optional - @Input - override fun getExecutable(): String? = javaExecAction.executable - - @Internal - override fun getWorkingDir(): File = javaExecAction.workingDir - - @Internal - override fun getEnvironment(): Map = javaExecAction.environment - - @Internal - override fun getStandardInput(): InputStream = javaExecAction.standardInput - - @Internal - override fun getStandardOutput(): OutputStream = javaExecAction.standardOutput - - @Internal - override fun getErrorOutput(): OutputStream = javaExecAction.errorOutput - - @Input - override fun isIgnoreExitValue(): Boolean = javaExecAction.isIgnoreExitValue - - @Internal - override fun getCommandLine(): List = javaExecAction.commandLine -} \ No newline at end of file diff --git a/compiler/fir/tree/build.gradle.kts b/compiler/fir/tree/build.gradle.kts index 5b4d5d48666..bde040f9ca6 100644 --- a/compiler/fir/tree/build.gradle.kts +++ b/compiler/fir/tree/build.gradle.kts @@ -31,7 +31,7 @@ dependencies { generatorClasspath(project("visitors-generator")) } -val generateVisitors by tasks.creating(UtilityJavaExec::class) { +val generateVisitors by tasks.creating(NoDebugJavaExec::class) { val generationRoot = "$projectDir/src/org/jetbrains/kotlin/fir/" val output = "$projectDir/visitors" diff --git a/core/builtins/build.gradle.kts b/core/builtins/build.gradle.kts index 27b8724f3cc..22d92d62114 100644 --- a/core/builtins/build.gradle.kts +++ b/core/builtins/build.gradle.kts @@ -18,7 +18,7 @@ val clean by tasks.getting { } } -val serialize by tasks.creating(UtilityJavaExec::class) { +val serialize by tasks.creating(NoDebugJavaExec::class) { val outDir = builtinsSerialized val inDirs = arrayOf(builtinsSrc, builtinsNative) inDirs.forEach { inputs.dir(it) } diff --git a/libraries/stdlib/js/build.gradle b/libraries/stdlib/js/build.gradle index 5b0514250d7..c061b68faee 100644 --- a/libraries/stdlib/js/build.gradle +++ b/libraries/stdlib/js/build.gradle @@ -193,7 +193,7 @@ compileTestKotlin2Js { } } -task compileJs(type: UtilityJavaExec) { +task compileJs(type: NoDebugJavaExec) { dependsOn compileBuiltinsKotlin2Js, compileKotlin2Js, compileExperimentalKotlin2Js, compileCoroutinesExperimentalKotlin2Js inputs.files(compileBuiltinsKotlin2Js.outputs.files) inputs.files(compileKotlin2Js.outputs.files)