Repository: JetBrains/kotlin
File: ant/src/org/jetbrains/kotlin/ant/Kotlin2JvmTask.kt (Kotlin)

Code before:
        if (noStdlib) args.add("-no-stdlib")
        if (noReflect) args.add("-no-reflect")
        if (includeRuntime) args.add("-include-runtime")
    }

    override fun execute() {
        if (!fork)
            super.execute()
        else {
            exec()
        }
    }

    private fun exec() {
        val javaHome = System.getProperty("java.home")
        val javaBin = javaHome + separator + "bin" + separator + "java"
        val classpath = System.getProperty("java.class.path")
        var redirector = Redirector(this)

        fillArguments()

        val command = ArrayList<String>()
        command.add(javaBin)
        command.addAll(cmdl.vmCommand.arguments) // jvm args
        command.add("-cp")
        command.add(classpath + pathSeparator + KotlinAntTaskUtil.compilerJar.canonicalPath)
        command.add(compilerFqName)
        command.addAll(args) // compiler args

        // streamHandler: used to handle the input and output streams of the subprocess.
        // watchdog: a watchdog for the subprocess or <code>null</code> to disable a timeout for the subprocess.
        // TODO: support timeout for the subprocess
        val exe = Execute(redirector.createHandler(), null)
        exe.setAntRun(getProject())
        exe.commandline = command.toTypedArray()
        log("Executing command: ${command.joinToString(" ")}", LogLevel.DEBUG.level)
        log("Compiling ${src!!.list().toList()} => [${output!!.canonicalPath}]")
        var exitCode = exe.execute()
        redirector.complete()
        if (failOnError && exitCode != 0) {
            throw BuildException("Compile failed; see the compiler error output for details.")
        }
    }

    fun createJvmarg(): Commandline.Argument {
        return cmdl.createVmArgument()
    }
}



Review comment (suggestion):
Is `classpath` really necessary? If I understand correctly, it's the classpath of the currently-running Ant task, which is not needed for the compiler to work

Code after:
        if (noStdlib) args.add("-no-stdlib")
        if (noReflect) args.add("-no-reflect")
        if (includeRuntime) args.add("-include-runtime")
    }

    override fun execute() {
        if (!fork)
            super.execute()
        else {
            exec()
        }
    }

    private fun exec() {
        val javaHome = System.getProperty("java.home")
        val javaBin = javaHome + separator + "bin" + separator + "java"
        val redirector = Redirector(this)

        fillArguments()

        val command = ArrayList<String>()
        command.add(javaBin)
        command.addAll(cmdl.vmCommand.arguments) // jvm args
        command.add("-Dorg.jetbrains.kotlin.cliMessageRenderer=FullPath") // same MessageRenderer as non-forking mode
        command.add("-cp")
        command.add(KotlinAntTaskUtil.compilerJar.canonicalPath)
        command.add(compilerFqName)
        command.addAll(args) // compiler args

        // streamHandler: used to handle the input and output streams of the subprocess.
        // watchdog: a watchdog for the subprocess or <code>null</code> to disable a timeout for the subprocess.
        // TODO: support timeout for the subprocess
        val exe = Execute(redirector.createHandler(), null)
        exe.setAntRun(getProject())
        exe.commandline = command.toTypedArray()
        log("Executing command: ${command.joinToString(" ")}", LogLevel.DEBUG.level)
        log("Compiling ${src!!.list().toList()} => [${output!!.canonicalPath}]")
        val exitCode = exe.execute()
        redirector.complete()
        if (failOnError && exitCode != 0) {
            throw BuildException("Compile failed; see the compiler error output for details.")
        }
    }

    fun createJvmarg(): Commandline.Argument {
        return cmdl.createVmArgument()
    }
}