Коммит e00c98d4 создал по автору Leonid Stashevsky's avatar Leonid Stashevsky Зафиксировано автором Leonid Stashevsky
Просмотр файлов

KTOR-4406 Make IDE using jvm only configuration by default

владелец 5121d102
......@@ -22,4 +22,4 @@
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
</project>
\ Нет новой строки в конце файла
......@@ -3,6 +3,8 @@
*/
import org.jetbrains.dokka.gradle.*
import org.jetbrains.kotlin.gradle.dsl.*
import org.jetbrains.kotlin.gradle.targets.js.*
import org.jetbrains.kotlin.konan.target.*
buildscript {
......@@ -121,46 +123,11 @@ allprojects {
}
kotlin {
targets.all {
if (!disabledExplicitApiModeProjects.contains(project.name)) explicitApi()
if (this is org.jetbrains.kotlin.gradle.targets.js.KotlinJsTarget) {
irTarget?.compilations?.all {
configureCompilation()
}
}
compilations.all {
configureCompilation()
}
}
if (!disabledExplicitApiModeProjects.contains(project.name)) {
explicitApi()
}
sourceSets
.matching { it.name !in listOf("main", "test") }
.all {
val srcDir = if (name.endsWith("Main")) "src" else "test"
val resourcesPrefix = if (name.endsWith("Test")) "test-" else ""
val platform = name.dropLast(4)
kotlin.srcDir("$platform/$srcDir")
resources.srcDir("$platform/${resourcesPrefix}resources")
languageSettings.apply {
progressiveMode = true
}
}
val jdk = when (name) {
in jdk11Modules -> 11
else -> 8
}
jvmToolchain {
check(this is JavaToolchainSpec)
languageVersion.set(JavaLanguageVersion.of(jdk))
}
setCompilationOptions()
configureSourceSets()
setupJvmToolchain()
}
val skipPublish: List<String> by rootProject.extra
......@@ -176,27 +143,84 @@ subprojects {
println("Using Kotlin compiler version: ${org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION}")
filterSnapshotTests()
allprojects {
plugins.apply("org.jetbrains.dokka")
fun configureDokka() {
if (COMMON_JVM_ONLY) return
allprojects {
plugins.apply("org.jetbrains.dokka")
val dokkaPlugin by configurations
dependencies {
dokkaPlugin("org.jetbrains.dokka:versioning-plugin:1.6.10")
val dokkaPlugin by configurations
dependencies {
dokkaPlugin("org.jetbrains.dokka:versioning-plugin:1.6.10")
}
}
val dokkaOutputDir = "../versions"
tasks.withType<DokkaMultiModuleTask> {
val mapOf = mapOf(
"org.jetbrains.dokka.versioning.VersioningPlugin" to
"""{ "version": "$configuredVersion", "olderVersionsDir":"$dokkaOutputDir" }"""
)
outputDirectory.set(file(projectDir.toPath().resolve(dokkaOutputDir).resolve(configuredVersion)))
pluginsMapConfiguration.set(mapOf)
}
rootProject.plugins.withType<org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin> {
rootProject.the<org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension>().ignoreScripts = false
}
}
val dokkaOutputDir = "../versions"
configureDokka()
tasks.withType<DokkaMultiModuleTask> {
val mapOf = mapOf(
"org.jetbrains.dokka.versioning.VersioningPlugin" to
"""{ "version": "$configuredVersion", "olderVersionsDir":"$dokkaOutputDir" }"""
)
fun Project.setupJvmToolchain() {
val jdk = when (project.name) {
in jdk11Modules -> 11
else -> 8
}
kotlin {
jvmToolchain {
check(this is JavaToolchainSpec)
languageVersion.set(JavaLanguageVersion.of(jdk))
}
}
}
outputDirectory.set(file(projectDir.toPath().resolve(dokkaOutputDir).resolve(configuredVersion)))
pluginsMapConfiguration.set(mapOf)
fun KotlinMultiplatformExtension.setCompilationOptions() {
targets.all {
if (this is KotlinJsTarget) {
irTarget?.compilations?.all {
configureCompilation()
}
}
compilations.all {
configureCompilation()
}
}
}
rootProject.plugins.withType<org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin> {
rootProject.the<org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension>().ignoreScripts = false
fun KotlinMultiplatformExtension.configureSourceSets() {
sourceSets
.matching { it.name !in listOf("main", "test") }
.all {
val srcDir = if (name.endsWith("Main")) "src" else "test"
val resourcesPrefix = if (name.endsWith("Test")) "test-" else ""
val platform = name.dropLast(4)
kotlin.srcDir("$platform/$srcDir")
resources.srcDir("$platform/${resourcesPrefix}resources")
languageSettings.apply {
progressiveMode = true
}
}
if (!COMMON_JVM_ONLY) return
sourceSets {
findByName("jvmMain")?.kotlin?.srcDirs("jvmAndNix/src")
findByName("jvmTest")?.kotlin?.srcDirs("jvmAndNix/test")
}
}
......@@ -2,11 +2,9 @@
* Copyright 2014-2021 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
import org.jetbrains.kotlin.utils.addToStdlib.*
import java.util.*
plugins {
`kotlin-dsl`
kotlin("plugin.serialization") version "1.6.21"
}
val buildSnapshotTrain = properties["build_snapshot_train"]?.toString()?.toBoolean() == true
......@@ -29,6 +27,22 @@ dependencies {
val ktlint_version = libs.versions.ktlint.version.get()
implementation("org.jmailen.gradle:kotlinter-gradle:$ktlint_version")
implementation("io.ktor:ktor-server-default-headers:2.0.2")
implementation("io.ktor:ktor-server-netty:2.0.2")
implementation("io.ktor:ktor-server-cio:2.0.2")
implementation("io.ktor:ktor-server-jetty:2.0.2")
implementation("io.ktor:ktor-server-websockets:2.0.2")
implementation("io.ktor:ktor-server-auth:2.0.2")
implementation("io.ktor:ktor-server-caching-headers:2.0.2")
implementation("io.ktor:ktor-server-conditional-headers:2.0.2")
implementation("io.ktor:ktor-server-compression:2.0.2")
implementation("io.ktor:ktor-server-content-negotiation:2.0.2")
implementation("io.ktor:ktor-serialization-kotlinx:2.0.2")
implementation("io.ktor:ktor-network-tls-certificates:2.0.2")
implementation(libs.kotlinx.serialization.json)
implementation(libs.logback.classic)
}
kotlin {
......
/*
* Copyright 2014-2022 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
import org.gradle.api.*
import org.gradle.kotlin.dsl.*
fun Project.configureCommon() {
val coroutines_version: String by extra
kotlin {
sourceSets {
val commonMain by getting {
dependencies {
api("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version")
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
}
}
}
/*
* Copyright 2014-2021 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
import org.gradle.api.*
import org.jetbrains.kotlin.gradle.dsl.*
import org.jetbrains.kotlin.gradle.plugin.mpp.*
import org.jetbrains.kotlin.konan.target.*
fun KotlinMultiplatformExtension.createIdeaTarget(name: String): KotlinNativeTarget = when (HostManager.host) {
is KonanTarget.LINUX_X64 -> linuxX64(name)
is KonanTarget.MACOS_X64 -> macosX64(name)
is KonanTarget.MACOS_ARM64 -> macosArm64(name)
is KonanTarget.MINGW_X64 -> mingwX64(name)
fun KotlinMultiplatformExtension.ideaTarget(): KotlinNativeTarget = when (HostManager.host) {
is KonanTarget.LINUX_X64 -> linuxX64()
is KonanTarget.MACOS_X64 -> macosX64()
is KonanTarget.MACOS_ARM64 -> macosArm64()
is KonanTarget.MINGW_X64 -> mingwX64()
else -> error("Unsupported target ${HostManager.host}")
}
fun Project.fastTarget() {
if (COMMON_JVM_ONLY) kotlin.jvm()
}
......@@ -23,6 +23,8 @@ fun Project.configureJvm() {
val configuredVersion: String by rootProject.extra
kotlin {
jvm()
sourceSets.apply {
val jvmMain by getting {
dependencies {
......
......@@ -5,6 +5,7 @@ import org.gradle.api.*
import org.gradle.kotlin.dsl.*
import org.jetbrains.kotlin.gradle.dsl.*
import org.jetbrains.kotlin.gradle.plugin.*
import org.jetbrains.kotlin.gradle.plugin.mpp.*
import org.jmailen.gradle.kotlinter.*
fun Project.kotlin(block: KotlinMultiplatformExtension.() -> Unit) {
......@@ -12,4 +13,62 @@ fun Project.kotlin(block: KotlinMultiplatformExtension.() -> Unit) {
}
val Project.kotlin: KotlinMultiplatformExtension get() = the()
val Project.kotlinter: KotlinterExtension get() = the()
fun KotlinMultiplatformExtension.createCInterop(
name: String,
cinteropTargets: List<String>,
block: DefaultCInteropSettings.() -> Unit
) {
cinteropTargets.mapNotNull { targets.findByName(it) }.filterIsInstance<KotlinNativeTarget>().forEach {
val main by it.compilations
main.cinterops.create(name, block)
}
}
fun NamedDomainObjectContainer<KotlinSourceSet>.jvmAndNixMain(block: KotlinSourceSet.() -> Unit) {
val sourceSet = findByName("jvmAndNixMain") ?: getByName("jvmMain")
block(sourceSet)
}
fun NamedDomainObjectContainer<KotlinSourceSet>.jvmAndNixTest(block: KotlinSourceSet.() -> Unit) {
val sourceSet = findByName("jvmAndNixTest") ?: getByName("jvmTest")
block(sourceSet)
}
fun NamedDomainObjectContainer<KotlinSourceSet>.posixMain(block: KotlinSourceSet.() -> Unit) {
val sourceSet = findByName("posixMain") ?: return
block(sourceSet)
}
fun NamedDomainObjectContainer<KotlinSourceSet>.darwinMain(block: KotlinSourceSet.() -> Unit) {
val sourceSet = findByName("darwinMain") ?: return
block(sourceSet)
}
fun NamedDomainObjectContainer<KotlinSourceSet>.darwinTest(block: KotlinSourceSet.() -> Unit) {
val sourceSet = findByName("darwinTest") ?: return
block(sourceSet)
}
fun NamedDomainObjectContainer<KotlinSourceSet>.jsMain(block: KotlinSourceSet.() -> Unit) {
val sourceSet = findByName("jsMain") ?: return
block(sourceSet)
}
fun NamedDomainObjectContainer<KotlinSourceSet>.jsTest(block: KotlinSourceSet.() -> Unit) {
val sourceSet = findByName("jsTest") ?: return
block(sourceSet)
}
fun NamedDomainObjectContainer<KotlinSourceSet>.desktopMain(block: KotlinSourceSet.() -> Unit) {
val sourceSet = findByName("desktopMain") ?: return
block(sourceSet)
}
fun NamedDomainObjectContainer<KotlinSourceSet>.desktopTest(block: KotlinSourceSet.() -> Unit) {
val sourceSet = findByName("desktopTest") ?: return
block(sourceSet)
}
......@@ -31,51 +31,6 @@ val HOST_NAME = when {
else -> error("Unknown os name `$OS_NAME`")
}
val MAC_TARGETS = setOf(
"macosX64",
"macosArm64",
"iosX64",
"iosArm64",
"iosArm32",
"iosSimulatorArm64",
"watchosX86",
"watchosX64",
"watchosArm32",
"watchosArm64",
"watchosSimulatorArm64",
"tvosX64",
"tvosArm64",
"tvosSimulatorArm64",
)
val WIN_TARGETS = setOf("mingwX64")
val LINUX_TARGETS = setOf("linuxX64")
val EXCLUDE_MAP = mapOf(
"linux" to MAC_TARGETS + WIN_TARGETS,
"windows" to MAC_TARGETS + LINUX_TARGETS,
"macos" to WIN_TARGETS + LINUX_TARGETS
)
val jettyAlpnBootVersion: String? = when (java_version) {
"1.8.0_191",
"1.8.0_192",
"1.8.0_201",
"1.8.0_202",
"1.8.0_211",
"1.8.0_212",
"1.8.0_221",
"1.8.0_222",
"1.8.0_231",
"1.8.0_232",
"1.8.0_241",
"1.8.0_242" -> "8.1.13.v20181017"
else -> null
}
fun posixTargets(project: Project): Set<KotlinNativeTarget> = project.kotlin.posixTargets()
val currentJdk = if (versionComponents[0] == 1) versionComponents[1] else versionComponents[0]
val jdk11Modules = listOf(
......@@ -93,5 +48,4 @@ fun Project.useJdkVersionForJvmTests(version: Int) {
}
)
}
}
......@@ -2,65 +2,74 @@
* Copyright 2014-2021 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
import org.jetbrains.kotlin.gradle.dsl.*
import org.jetbrains.kotlin.gradle.plugin.mpp.*
import org.gradle.api.*
fun KotlinMultiplatformExtension.posixTargets(): Set<KotlinNativeTarget> =
nixTargets() + mingwX64()
val Project.COMMON_JVM_ONLY get() = IDEA_ACTIVE && properties.get("ktor.ide.jvmAndCommonOnly") == "true"
fun KotlinMultiplatformExtension.nixTargets(): Set<KotlinNativeTarget> =
darwinTargets() + linuxX64()
fun Project.fastOr(block: () -> List<String>): List<String> {
if (COMMON_JVM_ONLY) return emptyList()
return block()
}
fun KotlinMultiplatformExtension.darwinTargets(): Set<KotlinNativeTarget> = setOf(
iosX64(),
iosArm64(),
iosArm32(),
iosSimulatorArm64(),
fun Project.posixTargets(): List<String> = fastOr { nixTargets() + kotlin.mingwX64().name }
watchosX86(),
watchosX64(),
watchosArm32(),
watchosArm64(),
watchosSimulatorArm64(),
fun Project.nixTargets(): List<String> = fastOr {
darwinTargets() + kotlin.linuxX64().name
}
tvosX64(),
tvosArm64(),
tvosSimulatorArm64(),
fun Project.darwinTargets(): List<String> = fastOr {
macosTargets() + iosTargets() + watchosTargets() + tvosTargets()
}
macosX64(),
macosArm64()
)
fun Project.macosTargets(): List<String> = fastOr {
with(kotlin) {
listOf(
macosX64(),
macosArm64()
).map { it.name }
}
}
fun Project.iosTargets(): List<String> = fastOr {
with(kotlin) {
listOf(
iosX64(),
iosArm64(),
iosArm32(),
iosSimulatorArm64(),
).map { it.name }
}
}
fun KotlinMultiplatformExtension.macosTargets(): Set<KotlinNativeTarget> = setOf(
macosX64(),
macosArm64()
)
fun Project.watchosTargets(): List<String> = fastOr {
with(kotlin) {
listOf(
watchosX86(),
watchosX64(),
watchosArm32(),
watchosArm64(),
watchosSimulatorArm64(),
).map { it.name }
}
}
fun KotlinMultiplatformExtension.iosTargets(): Set<KotlinNativeTarget> = setOf(
iosX64(),
iosArm64(),
iosArm32(),
iosSimulatorArm64(),
)
fun Project.tvosTargets(): List<String> = fastOr {
with(kotlin) {
listOf(
tvosX64(),
tvosArm64(),
tvosSimulatorArm64(),
).map { it.name }
}
}
fun KotlinMultiplatformExtension.watchosTargets(): Set<KotlinNativeTarget> = setOf(
watchosX86(),
watchosX64(),
watchosArm32(),
watchosArm64(),
watchosSimulatorArm64(),
)
fun KotlinMultiplatformExtension.tvosTargets(): Set<KotlinNativeTarget> = setOf(
tvosX64(),
tvosArm64(),
tvosSimulatorArm64(),
)
fun KotlinMultiplatformExtension.desktopTargets(): Set<KotlinNativeTarget> = setOf(
macosX64(),
macosArm64(),
linuxX64(),
mingwX64()
)
fun Project.desktopTargets(): List<String> = fastOr {
with(kotlin) {
listOf(
macosX64(),
macosArm64(),
linuxX64(),
mingwX64()
).map { it.name }
}
}
......@@ -54,6 +54,8 @@ fun isAvailableForPublication(publication: Publication): Boolean {
}
fun Project.configurePublication() {
if (COMMON_JVM_ONLY) return
apply(plugin = "maven-publish")
tasks.withType<AbstractPublishToMaven>().all {
......
......@@ -21,15 +21,12 @@ val Project.hasJvm: Boolean get() = hasCommon || hasJvmAndNix || files.any { it.
val Project.hasNative: Boolean get() = hasCommon || hasNix || hasPosix || hasDarwin || hasDesktop
fun Project.configureTargets() {
val coroutines_version: String by extra
val kotlin_version: String by extra
configureCommon()
if (hasJvm) configureJvm()
kotlin {
if (hasJvm) {
jvm()
configureJvm()
}
if (COMMON_JVM_ONLY) return
kotlin {
if (hasJs) {
js {
nodejs()
......@@ -42,18 +39,6 @@ fun Project.configureTargets() {
if (hasPosix || hasDarwin) extra.set("hasNative", true)
sourceSets {
val commonMain by getting {
dependencies {
api("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version")
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
if (hasPosix) {
val posixMain by creating
val posixTest by creating
......@@ -116,8 +101,8 @@ fun Project.configureTargets() {
}
posixTargets().forEach {
getByName("${it.name}Main").dependsOn(posixMain)
getByName("${it.name}Test").dependsOn(posixTest)
getByName("${it}Main").dependsOn(posixMain)
getByName("${it}Test").dependsOn(posixTest)
}
}
......@@ -133,8 +118,8 @@ fun Project.configureTargets() {
}
nixTargets().forEach {
getByName("${it.name}Main").dependsOn(nixMain)
getByName("${it.name}Test").dependsOn(nixTest)
getByName("${it}Main").dependsOn(nixMain)
getByName("${it}Test").dependsOn(nixTest)
}
}
......@@ -158,28 +143,28 @@ fun Project.configureTargets() {
watchosMain.dependsOn(darwinMain)
macosTargets().forEach {
getByName("${it.name}Main").dependsOn(macosMain)
getByName("${it.name}Test").dependsOn(macosTest)
getByName("${it}Main").dependsOn(macosMain)
getByName("${it}Test").dependsOn(macosTest)
}
iosTargets().forEach {
getByName("${it.name}Main").dependsOn(iosMain)
getByName("${it.name}Test").dependsOn(iosTest)
getByName("${it}Main").dependsOn(iosMain)
getByName("${it}Test").dependsOn(iosTest)
}
watchosTargets().forEach {
getByName("${it.name}Main").dependsOn(watchosMain)
getByName("${it.name}Test").dependsOn(watchosTest)
getByName("${it}Main").dependsOn(watchosMain)
getByName("${it}Test").dependsOn(watchosTest)
}
tvosTargets().forEach {
getByName("${it.name}Main").dependsOn(tvosMain)
getByName("${it.name}Test").dependsOn(tvosTest)
getByName("${it}Main").dependsOn(tvosMain)
getByName("${it}Test").dependsOn(tvosTest)
}
darwinTargets().forEach {
getByName("${it.name}Main").dependsOn(darwinMain)
getByName("${it.name}Test").dependsOn(darwinTest)
getByName("${it}Main").dependsOn(darwinMain)
getByName("${it}Test").dependsOn(darwinTest)
}
}
......@@ -191,8 +176,8 @@ fun Project.configureTargets() {
val desktopTest by getting
desktopTargets().forEach {
getByName("${it.name}Main").dependsOn(desktopMain)
getByName("${it.name}Test").dependsOn(desktopTest)
getByName("${it}Main").dependsOn(desktopMain)
getByName("${it}Test").dependsOn(desktopTest)
}
}
......
......@@ -46,6 +46,8 @@ fun Project.filterSnapshotTests() {
}
fun Project.setupTrainForSubproject() {
if (COMMON_JVM_ONLY) return
val build_snapshot_train: Boolean? by extra
if (build_snapshot_train != true) return
......
/*
* Copyright 2014-2021 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
* Copyright 2014-2022 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
package io.ktor.client.tests.utils
package test.server
import io.ktor.client.tests.utils.tests.*
import io.ktor.http.*
......
/*
* Copyright 2014-2022 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
package test.server
import io.ktor.http.*
import io.ktor.http.content.*
import io.ktor.util.*
import io.ktor.utils.io.charsets.*
import io.ktor.utils.io.core.*
fun makeArray(size: Int): ByteArray = ByteArray(size) { it.toByte() }
fun makeString(size: Int): String = CharArray(size) { it.toChar() }.concatToString().encodeBase64().take(size)
fun List<PartData>.makeString(): String = buildString {
val list = this@makeString
list.forEach {
append("${it.name!!}\n")
val content = when (it) {
is PartData.FileItem -> filenameContentTypeAndContentString(it.provider, it.headers)
is PartData.FormItem -> it.value
is PartData.BinaryItem -> filenameContentTypeAndContentString(it.provider, it.headers)
is PartData.BinaryChannelItem -> error("Not implemented")
}
append(content)
}
}
private fun filenameContentTypeAndContentString(provider: () -> Input, headers: Headers): String {
val dispositionHeader: String = headers.getAll(HttpHeaders.ContentDisposition)!!.joinToString(";")
val disposition: ContentDisposition = ContentDisposition.parse(dispositionHeader)
val filename: String = disposition.parameter("filename") ?: ""
val contentType = headers[HttpHeaders.ContentType]?.let { ContentType.parse(it) } ?: ""
val content: String = provider().readText(Charsets.ISO_8859_1)
return "$filename$contentType$content"
}
/*
* Copyright 2014-2021 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
* Copyright 2014-2022 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
package io.ktor.client.tests.utils
package test.server
import ch.qos.logback.classic.*
import io.ktor.client.tests.utils.tests.*
......@@ -14,14 +14,13 @@ import org.slf4j.*
import java.io.*
import java.util.concurrent.*
val TEST_SERVER: String = "http://127.0.0.1:8080"
private const val DEFAULT_PORT: Int = 8080
private const val DEFAULT_TLS_PORT: Int = 8089
private const val HTTP_PROXY_PORT: Int = 8082
internal fun startServer(): Closeable {
val logger = LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME) as ch.qos.logback.classic.Logger
logger.level = Level.ERROR
val scope = CloseableGroup()
try {
val tcpServer = TestTcpServer(HTTP_PROXY_PORT, ::tcpServerHandler)
......@@ -45,19 +44,6 @@ internal fun startServer(): Closeable {
return scope
}
/**
* Start server for tests.
*/
public fun main() {
val handler = startServer()
try {
while (!Thread.interrupted()) {
}
} finally {
handler.close()
}
}
private fun setupTLSServer(): ApplicationEngine {
val file = File.createTempFile("server", "certificate")
val testKeyStore = generateCertificate(file)
......
/*
* Copyright 2014-2022 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
package test.server
import org.gradle.api.*
import test.server.*
import test.server.startServer
import java.io.*
import java.util.concurrent.atomic.AtomicInteger
class TestServerPlugin : Plugin<Project> {
private var server: Closeable? = null
private val activeTasks = AtomicInteger(0)
fun start() {
val count = activeTasks.incrementAndGet()
if (count == 1) {
server = startServer()
}
}
fun stop() {
val count = activeTasks.decrementAndGet()
if (count == 0) {
server!!.close()
server = null
}
}
override fun apply(target: Project) {
target.testTasks {
it.doFirst {
start()
}
}
}
}
fun Project.testTasks(block: (Task) -> Unit) {
configure(tasks) {
if (!name.endsWith("Test")) return@configure
block(this)
}
}
/*
* Copyright 2014-2019 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
* Copyright 2014-2022 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
package io.ktor.client.tests.utils
package test.server
import io.ktor.network.selector.*
import io.ktor.network.sockets.*
......
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать