<commit_before>package org.jetbrains.kotlin.gradle.frontend.ktor

import org.gradle.api.plugins.*
import org.gradle.api.tasks.*
import org.jetbrains.kotlin.gradle.frontend.servers.*
import java.io.*
import java.net.*

/**
 * @author <NAME>
 */
open class KtorStartStopTask : AbstractStartStopTask<Int>() {
    @Input
    var start: Boolean = true

    @get:Input
    val port: Int
        get() = project.extensions.getByType(KtorExtension::class.java).port ?: throw IllegalArgumentException("ktor port not configured")

    @Input
    var shutdownPath = "/ktor/application/shutdown"

    @Input
    var mainClass = "org.jetbrains.ktor.jetty.DevelopmentHost"

    override val identifier = "ktor"
    override fun checkIsRunning(stopInfo: Int?): Boolean {
        return stopInfo != null &&
                try {
                    Socket("localhost", stopInfo).close()
                    true
                } catch (e: IOException) {
                    false
                }
    }

    override fun beforeStart() = port

    override fun builder(): ProcessBuilder {
        return ProcessBuilder(
                listOf("/usr/java/latest/bin/java", "-cp")
                        + (project.configurations.flatMap { it.files.filter { it.canRead() && it.extension == "jar" } }
                        + project.convention.findPlugin(JavaPluginConvention::class.java).sourceSets.getByName("main").output.toList()
                        )
                        .distinct().joinToString(File.pathSeparator) { it.absolutePath }
                        + listOf(
                        "-Dktor.deployment.port=$port",
                        "-Dktor.deployment.autoreload=true",
                        "-Dktor.deployment.shutdown.url=$shutdownPath",
                        mainClass)
        ).inheritIO().directory(project.buildDir)
    }

    override fun stop(state: Int?) {
        if (state != null) {
            try {
                URL("http://localhost:$port$shutdownPath").readText()
            } catch (ignore: IOException) {
            }
        }
    }

    override fun readState(file: File) = file.readText().trim().toInt()
    override fun writeState(file: File, state: Int) {
        file.writeText("$state\n")
    }

    @TaskAction
    fun start() {
        if (start) {
            doStart()
        } else {
            doStop()
        }
    }
}<commit_msg>ktor jvm options<commit_after>package org.jetbrains.kotlin.gradle.frontend.ktor

import org.gradle.api.plugins.*
import org.gradle.api.tasks.*
import org.jetbrains.kotlin.gradle.frontend.servers.*
import java.io.*
import java.net.*

/**
 * @author <NAME>
 */
open class KtorStartStopTask : AbstractStartStopTask<Int>() {
    @Input
    var start: Boolean = true

    @get:Input
    val port: Int
        get() = project.extensions.getByType(KtorExtension::class.java).port ?: throw IllegalArgumentException("ktor port not configured")

    @get:Input
    val jvmOptions: Array<String>
        get() = project.extensions.getByType(KtorExtension::class.java).jvmOptions

    @Input
    var shutdownPath = "/ktor/application/shutdown"

    @Input
    var mainClass = "org.jetbrains.ktor.jetty.DevelopmentHost"

    override val identifier = "ktor"
    override fun checkIsRunning(stopInfo: Int?): Boolean {
        return stopInfo != null &&
                try {
                    Socket("localhost", stopInfo).close()
                    true
                } catch (e: IOException) {
                    false
                }
    }

    override fun beforeStart() = port

    override fun serverLog() = project.buildDir.resolve("$identifier-$port.log")

    override fun builder(): ProcessBuilder {
        return ProcessBuilder(
                listOf("/usr/java/latest/bin/java", "-cp")
                        + (project.configurations.flatMap { it.files.filter { it.canRead() && it.extension == "jar" } }
                        + project.convention.findPlugin(JavaPluginConvention::class.java).sourceSets.getByName("main").output.toList()
                        )
                        .distinct().joinToString(File.pathSeparator) { it.absolutePath }
                        + listOf(
                        "-Dktor.deployment.port=$port",
                        "-Dktor.deployment.autoreload=true",
                        "-Dktor.deployment.shutdown.url=$shutdownPath")
                        + jvmOptions
                        + mainClass
        ).directory(project.buildDir)
    }

    override fun stop(state: Int?) {
        if (state != null) {
            try {
                URL("http://localhost:$port$shutdownPath").readText()
            } catch (ignore: IOException) {
            }
        }
    }

    override fun readState(file: File) = file.readText().trim().toInt()
    override fun writeState(file: File, state: Int) {
        file.writeText("$state\n")
    }

    @TaskAction
    fun start() {
        if (start) {
            doStart()
        } else {
            doStop()
        }
    }
}
{'fraction_non_alphanumeric': 0.1224124203821656, 'fraction_numerical': 0.0, 'mean_word_length': 1.8373800112930547, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6725436', 'n_tokens_mistral': 1413, 'n_tokens_neox': 1349, 'n_words': 253}