mirror of
https://github.com/jlengrand/ktor.git
synced 2026-03-10 08:31:20 +00:00
Migrate to kotlin-multiplatform plugin
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -23,3 +23,4 @@ bin/
|
||||
.settings
|
||||
.project
|
||||
.classpath
|
||||
.konan
|
||||
|
||||
@@ -2,40 +2,34 @@
|
||||
* Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
|
||||
*/
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
kotlin.srcDir 'jvm/src'
|
||||
}
|
||||
test {
|
||||
kotlin.srcDir 'jvm/test'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
kotlin.sourceSets.jvmMain.dependencies {
|
||||
api "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
|
||||
implementation project(":ktor-utils:ktor-utils-jvm")
|
||||
api project(":ktor-utils")
|
||||
api 'org.ow2.asm:asm-debug-all:5.0.4'
|
||||
api 'com.google.code.gson:gson:2.6.2'
|
||||
}
|
||||
|
||||
kotlin.sourceSets.jvmTest.dependencies {
|
||||
api "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
|
||||
api "junit:junit:4.12"
|
||||
}
|
||||
|
||||
apply from: rootProject.file('gradle/compatibility.gradle')
|
||||
|
||||
test {
|
||||
def binaryCompatibilityModules = project.ext.buildList() as List<ProjectDependency>
|
||||
def artifactNames = binaryCompatibilityModules.collect { it.dependencyProject.name }
|
||||
def modules = binaryCompatibilityModules.collect { it.dependencyProject.projectDir }
|
||||
|
||||
// dependsOn cleanCompileTestKotlin
|
||||
jvmTest {
|
||||
dependsOn configurations.binaryCompatibility
|
||||
|
||||
systemProperty 'validator.input.modules', modules.join(File.pathSeparator)
|
||||
systemProperty 'validator.input.artifactNames', artifactNames.join(File.pathSeparator)
|
||||
systemProperty 'overwrite.output', project.properties['overwrite.output']
|
||||
jvmArgs '-ea'
|
||||
|
||||
doFirst {
|
||||
def binaryCompatibilityModules = project.ext.buildList() as List<ProjectDependency>
|
||||
def modules = binaryCompatibilityModules.collect { it.dependencyProject.projectDir }
|
||||
|
||||
tasks.findByName("test").systemProperty('validator.input.modules', modules.join(File.pathSeparator))
|
||||
}
|
||||
}
|
||||
|
||||
binaryCompatibilityModules.each {
|
||||
jvmTest.dependsOn(it.dependencyProject.getTasksByName("jvmJar", true))
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ fun ClassVisibility.findSetterForProperty(property: MemberVisibility): MemberVis
|
||||
}
|
||||
|
||||
fun readKotlinVisibilities(declarationFile: File): Map<String, ClassVisibility> {
|
||||
check(declarationFile.exists())
|
||||
val result = mutableListOf<ClassVisibility>()
|
||||
declarationFile.bufferedReader().use { reader ->
|
||||
val jsonReader = JsonReader(reader)
|
||||
|
||||
@@ -17,14 +17,16 @@ class PublicApiTest(
|
||||
) {
|
||||
companion object {
|
||||
private val modulesList = System.getProperty("validator.input.modules")
|
||||
private val artifactNames = System.getProperty("validator.input.artifactNames")
|
||||
private val nonPublicPackages: List<String> = emptyList()
|
||||
|
||||
@Parameterized.Parameters(name = "{1}")
|
||||
@JvmStatic
|
||||
fun modules(): List<Array<Any>> {
|
||||
return modulesList.split(File.pathSeparator).map { path ->
|
||||
val names = artifactNames.split(File.pathSeparator)
|
||||
return modulesList.split(File.pathSeparator).mapIndexed { id, path ->
|
||||
val dir = File(path)
|
||||
arrayOf<Any>(dir, dir.name)
|
||||
arrayOf<Any>(dir, names[id])
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,11 +41,11 @@ class PublicApiTest(
|
||||
.map { readKotlinVisibilities(it) }
|
||||
.reduce { m1, m2 -> m1 + m2 }
|
||||
val api = getBinaryAPI(JarFile(jarFile), visibilities).filterOutNonPublic(nonPublicPackages)
|
||||
api.dumpAndCompareWith(File("reference-public-api").resolve("${moduleName.removeSuffix("-jvm")}.txt"))
|
||||
api.dumpAndCompareWith(File("reference-public-api").resolve("$moduleName.txt"))
|
||||
}
|
||||
|
||||
private fun getJarPath(libsDir: File): File {
|
||||
val regex = Regex("$moduleName.+\\.jar")
|
||||
val regex = Regex("$moduleName-jvm.+\\.jar")
|
||||
val files = (libsDir.listFiles() ?: throw Exception("Cannot list files in $libsDir"))
|
||||
.filter {
|
||||
it.name.let {
|
||||
|
||||
@@ -35,7 +35,7 @@ private fun assertEqualsToFile(to: File, actual: CharSequence) {
|
||||
assertEquals(
|
||||
expectedText,
|
||||
actualText,
|
||||
"Actual data differs from file content: ${to.name}\nTo overwrite the expected API rerun with -Doverwrite.output=true parameter\n"
|
||||
"Actual data differs from file content: ${to.name}\nTo overwrite the expected API rerun with -Poverwrite.output=true parameter\n"
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -122,7 +122,9 @@ public final class io/ktor/client/call/UtilsJvmKt {
|
||||
|
||||
public final class io/ktor/client/call/UtilsKt {
|
||||
public static final fun call (Lio/ktor/client/HttpClient;Lio/ktor/client/request/HttpRequestBuilder;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static final fun call (Lio/ktor/client/HttpClient;Lio/ktor/http/Url;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static final fun call (Lio/ktor/client/HttpClient;Ljava/lang/String;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun call$default (Lio/ktor/client/HttpClient;Lio/ktor/http/Url;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static synthetic fun call$default (Lio/ktor/client/HttpClient;Ljava/lang/String;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
}
|
||||
|
||||
@@ -392,6 +394,10 @@ public final class io/ktor/client/request/BuildersKt {
|
||||
public static final fun request (Lkotlin/jvm/functions/Function1;)Lio/ktor/client/request/HttpRequestBuilder;
|
||||
}
|
||||
|
||||
public final class io/ktor/client/request/BuildersWithUrlKt {
|
||||
public static final fun url (Lio/ktor/client/request/HttpRequestBuilder;Lio/ktor/http/Url;)V
|
||||
}
|
||||
|
||||
public abstract class io/ktor/client/request/ClientUpgradeContent : io/ktor/http/content/OutgoingContent$NoContent {
|
||||
public fun <init> ()V
|
||||
public final fun getOutput ()Lkotlinx/coroutines/io/ByteWriteChannel;
|
||||
|
||||
@@ -79,8 +79,7 @@ public abstract class io/ktor/http/cio/HttpMessage : java/io/Closeable {
|
||||
}
|
||||
|
||||
public final class io/ktor/http/cio/HttpParserKt {
|
||||
public static final fun parseHeaders (Lkotlinx/coroutines/io/ByteReadChannel;Lio/ktor/http/cio/internals/CharBufferBuilder;Lio/ktor/http/cio/internals/MutableRange;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun parseHeaders$default (Lkotlinx/coroutines/io/ByteReadChannel;Lio/ktor/http/cio/internals/CharBufferBuilder;Lio/ktor/http/cio/internals/MutableRange;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun parseHeaders (Lkotlinx/coroutines/io/ByteReadChannel;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static final fun parseRequest (Lkotlinx/coroutines/io/ByteReadChannel;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static final fun parseResponse (Lkotlinx/coroutines/io/ByteReadChannel;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
}
|
||||
@@ -167,30 +166,6 @@ public final class io/ktor/http/cio/Response : io/ktor/http/cio/HttpMessage {
|
||||
public final fun getVersion ()Ljava/lang/CharSequence;
|
||||
}
|
||||
|
||||
public final class io/ktor/http/cio/internals/CharBufferBuilder : java/lang/Appendable, java/lang/CharSequence {
|
||||
public fun <init> ()V
|
||||
public fun <init> (Lkotlinx/io/pool/ObjectPool;)V
|
||||
public synthetic fun <init> (Lkotlinx/io/pool/ObjectPool;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public fun append (C)Ljava/lang/Appendable;
|
||||
public fun append (Ljava/lang/CharSequence;)Ljava/lang/Appendable;
|
||||
public fun append (Ljava/lang/CharSequence;II)Ljava/lang/Appendable;
|
||||
public final fun charAt (I)C
|
||||
public fun equals (Ljava/lang/Object;)Z
|
||||
public fun get (I)C
|
||||
public fun getLength ()I
|
||||
public final fun getPool ()Lkotlinx/io/pool/ObjectPool;
|
||||
public fun hashCode ()I
|
||||
public final fun length ()I
|
||||
public final fun release ()V
|
||||
public fun subSequence (II)Ljava/lang/CharSequence;
|
||||
public fun toString ()Ljava/lang/String;
|
||||
}
|
||||
|
||||
public final class io/ktor/http/cio/internals/CharBufferPoolKt {
|
||||
public static final field CHAR_BUFFER_BYTES I
|
||||
public static final field CHAR_BUFFER_LENGTH I
|
||||
}
|
||||
|
||||
public final class io/ktor/http/cio/internals/HttpByteBufferPoolKt {
|
||||
public static final fun getDefaultByteBufferPool ()Lkotlinx/io/pool/ObjectPool;
|
||||
}
|
||||
|
||||
@@ -966,6 +966,84 @@ public final class io/ktor/http/Url {
|
||||
public final class io/ktor/http/Url$Companion {
|
||||
}
|
||||
|
||||
public final class io/ktor/http/auth/AuthScheme {
|
||||
public static final field Basic Ljava/lang/String;
|
||||
public static final field Digest Ljava/lang/String;
|
||||
public static final field INSTANCE Lio/ktor/http/auth/AuthScheme;
|
||||
public static final field Negotiate Ljava/lang/String;
|
||||
public static final field OAuth Ljava/lang/String;
|
||||
public final synthetic fun getBasic ()Ljava/lang/String;
|
||||
public final synthetic fun getDigest ()Ljava/lang/String;
|
||||
public final synthetic fun getNegotiate ()Ljava/lang/String;
|
||||
}
|
||||
|
||||
public final class io/ktor/http/auth/HeaderValueEncoding : java/lang/Enum {
|
||||
public static final field QUOTED_ALWAYS Lio/ktor/http/auth/HeaderValueEncoding;
|
||||
public static final field QUOTED_WHEN_REQUIRED Lio/ktor/http/auth/HeaderValueEncoding;
|
||||
public static final field URI_ENCODE Lio/ktor/http/auth/HeaderValueEncoding;
|
||||
public static fun valueOf (Ljava/lang/String;)Lio/ktor/http/auth/HeaderValueEncoding;
|
||||
public static fun values ()[Lio/ktor/http/auth/HeaderValueEncoding;
|
||||
}
|
||||
|
||||
public abstract class io/ktor/http/auth/HttpAuthHeader {
|
||||
public static final field Companion Lio/ktor/http/auth/HttpAuthHeader$Companion;
|
||||
public final fun getAuthScheme ()Ljava/lang/String;
|
||||
public abstract fun render ()Ljava/lang/String;
|
||||
public abstract fun render (Lio/ktor/http/auth/HeaderValueEncoding;)Ljava/lang/String;
|
||||
public fun toString ()Ljava/lang/String;
|
||||
}
|
||||
|
||||
public final class io/ktor/http/auth/HttpAuthHeader$Companion {
|
||||
public final fun basicAuthChallenge (Ljava/lang/String;Ljava/nio/charset/Charset;)Lio/ktor/http/auth/HttpAuthHeader$Parameterized;
|
||||
public final fun digestAuthChallenge (Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Ljava/lang/String;Ljava/lang/Boolean;Ljava/lang/String;)Lio/ktor/http/auth/HttpAuthHeader$Parameterized;
|
||||
public static synthetic fun digestAuthChallenge$default (Lio/ktor/http/auth/HttpAuthHeader$Companion;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Ljava/lang/String;Ljava/lang/Boolean;Ljava/lang/String;ILjava/lang/Object;)Lio/ktor/http/auth/HttpAuthHeader$Parameterized;
|
||||
}
|
||||
|
||||
public final class io/ktor/http/auth/HttpAuthHeader$Parameterized : io/ktor/http/auth/HttpAuthHeader {
|
||||
public fun <init> (Ljava/lang/String;Ljava/util/List;Lio/ktor/http/auth/HeaderValueEncoding;)V
|
||||
public synthetic fun <init> (Ljava/lang/String;Ljava/util/List;Lio/ktor/http/auth/HeaderValueEncoding;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public fun <init> (Ljava/lang/String;Ljava/util/Map;Lio/ktor/http/auth/HeaderValueEncoding;)V
|
||||
public synthetic fun <init> (Ljava/lang/String;Ljava/util/Map;Lio/ktor/http/auth/HeaderValueEncoding;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public fun equals (Ljava/lang/Object;)Z
|
||||
public final fun getEncoding ()Lio/ktor/http/auth/HeaderValueEncoding;
|
||||
public final fun getParameters ()Ljava/util/List;
|
||||
public fun hashCode ()I
|
||||
public final fun parameter (Ljava/lang/String;)Ljava/lang/String;
|
||||
public fun render ()Ljava/lang/String;
|
||||
public fun render (Lio/ktor/http/auth/HeaderValueEncoding;)Ljava/lang/String;
|
||||
public final fun withParameter (Ljava/lang/String;Ljava/lang/String;)Lio/ktor/http/auth/HttpAuthHeader$Parameterized;
|
||||
}
|
||||
|
||||
public final class io/ktor/http/auth/HttpAuthHeader$Parameters {
|
||||
public static final field Charset Ljava/lang/String;
|
||||
public static final field INSTANCE Lio/ktor/http/auth/HttpAuthHeader$Parameters;
|
||||
public static final field OAuthCallback Ljava/lang/String;
|
||||
public static final field OAuthCallbackConfirmed Ljava/lang/String;
|
||||
public static final field OAuthConsumerKey Ljava/lang/String;
|
||||
public static final field OAuthNonce Ljava/lang/String;
|
||||
public static final field OAuthSignature Ljava/lang/String;
|
||||
public static final field OAuthSignatureMethod Ljava/lang/String;
|
||||
public static final field OAuthTimestamp Ljava/lang/String;
|
||||
public static final field OAuthToken Ljava/lang/String;
|
||||
public static final field OAuthTokenSecret Ljava/lang/String;
|
||||
public static final field OAuthVerifier Ljava/lang/String;
|
||||
public static final field OAuthVersion Ljava/lang/String;
|
||||
public static final field Realm Ljava/lang/String;
|
||||
}
|
||||
|
||||
public final class io/ktor/http/auth/HttpAuthHeader$Single : io/ktor/http/auth/HttpAuthHeader {
|
||||
public fun <init> (Ljava/lang/String;Ljava/lang/String;)V
|
||||
public fun equals (Ljava/lang/Object;)Z
|
||||
public final fun getBlob ()Ljava/lang/String;
|
||||
public fun hashCode ()I
|
||||
public fun render ()Ljava/lang/String;
|
||||
public fun render (Lio/ktor/http/auth/HeaderValueEncoding;)Ljava/lang/String;
|
||||
}
|
||||
|
||||
public final class io/ktor/http/auth/HttpAuthHeaderKt {
|
||||
public static final fun parseAuthorizationHeader (Ljava/lang/String;)Lio/ktor/http/auth/HttpAuthHeader;
|
||||
}
|
||||
|
||||
public final class io/ktor/http/content/ByteArrayContent : io/ktor/http/content/OutgoingContent$ByteArrayContent {
|
||||
public fun <init> ([BLio/ktor/http/ContentType;Lio/ktor/http/HttpStatusCode;)V
|
||||
public synthetic fun <init> ([BLio/ktor/http/ContentType;Lio/ktor/http/HttpStatusCode;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
|
||||
@@ -87,6 +87,10 @@ public final class io/ktor/util/CollectionsKt {
|
||||
}
|
||||
|
||||
public final class io/ktor/util/CryptoKt {
|
||||
public static final fun Digest (Ljava/lang/String;)Lio/ktor/util/Digest;
|
||||
public static final fun build (Lio/ktor/util/Digest;Ljava/lang/String;Ljava/nio/charset/Charset;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static final fun build (Lio/ktor/util/Digest;[BLkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun build$default (Lio/ktor/util/Digest;Ljava/lang/String;Ljava/nio/charset/Charset;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun decodeBase64 (Ljava/lang/String;)[B
|
||||
public static final fun encodeBase64 ([B)Ljava/lang/String;
|
||||
public static final fun generateNonce ()Ljava/lang/String;
|
||||
@@ -112,6 +116,17 @@ public final class io/ktor/util/DeflaterKt {
|
||||
public static synthetic fun deflated$default (Lkotlinx/coroutines/io/ByteWriteChannel;ZLkotlinx/io/pool/ObjectPool;Lkotlin/coroutines/CoroutineContext;ILjava/lang/Object;)Lkotlinx/coroutines/io/ByteWriteChannel;
|
||||
}
|
||||
|
||||
public abstract interface class io/ktor/util/Digest {
|
||||
public abstract fun build (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public abstract fun plusAssign ([B)V
|
||||
public abstract fun reset ()V
|
||||
}
|
||||
|
||||
public final class io/ktor/util/Hash {
|
||||
public static final field INSTANCE Lio/ktor/util/Hash;
|
||||
public final fun combine ([Ljava/lang/Object;)I
|
||||
}
|
||||
|
||||
public final class io/ktor/util/InputJvmKt {
|
||||
public static final fun asStream (Lkotlinx/io/core/Input;)Ljava/io/InputStream;
|
||||
}
|
||||
@@ -314,6 +329,11 @@ public final class io/ktor/util/cio/FileChannelsKt {
|
||||
public static synthetic fun writeChannel$default (Ljava/io/File;Lkotlinx/io/pool/ObjectPool;ILjava/lang/Object;)Lkotlinx/coroutines/io/ByteWriteChannel;
|
||||
}
|
||||
|
||||
public final class io/ktor/util/cio/InputStreamAdaptersKt {
|
||||
public static final fun toByteReadChannel (Ljava/io/InputStream;Lkotlinx/io/pool/ObjectPool;Lkotlin/coroutines/CoroutineContext;Lkotlinx/coroutines/Job;)Lkotlinx/coroutines/io/ByteReadChannel;
|
||||
public static synthetic fun toByteReadChannel$default (Ljava/io/InputStream;Lkotlinx/io/pool/ObjectPool;Lkotlin/coroutines/CoroutineContext;Lkotlinx/coroutines/Job;ILjava/lang/Object;)Lkotlinx/coroutines/io/ByteReadChannel;
|
||||
}
|
||||
|
||||
public final class io/ktor/util/cio/NoopContinuation : kotlin/coroutines/Continuation {
|
||||
public static final field INSTANCE Lio/ktor/util/cio/NoopContinuation;
|
||||
public fun getContext ()Lkotlin/coroutines/CoroutineContext;
|
||||
|
||||
121
build.gradle
121
build.gradle
@@ -1,14 +1,11 @@
|
||||
buildscript {
|
||||
ext.kotlin_repository = {
|
||||
if (kotlin_version.endsWith('-SNAPSHOT')) return 'https://oss.sonatype.org/content/repositories/snapshots'
|
||||
return 'http://dl.bintray.com/kotlin/kotlin-eap'
|
||||
}()
|
||||
import org.jetbrains.kotlin.konan.target.HostManager
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
jcenter()
|
||||
maven { url 'https://plugins.gradle.org/m2/' }
|
||||
maven { url kotlin_repository }
|
||||
maven { url 'https://dl.bintray.com/jetbrains/kotlin-native-dependencies' }
|
||||
maven { url "https://plugins.gradle.org/m2/" }
|
||||
maven { url "https://dl.bintray.com/jetbrains/kotlin-native-dependencies" }
|
||||
maven { url "https://dl.bintray.com/kotlin/kotlin-dev" }
|
||||
}
|
||||
|
||||
@@ -16,81 +13,91 @@ buildscript {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlin_version"
|
||||
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$bintray_plugin_version"
|
||||
classpath 'net.researchgate:gradle-release:2.4.0'
|
||||
classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
|
||||
classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:$kotlin_native_version"
|
||||
classpath "org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomic_fu_version"
|
||||
classpath "com.moowork.gradle:gradle-node-plugin:$gradle_node_version"
|
||||
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
|
||||
classpath 'de.undercouch:gradle-download-task:3.4.3'
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'net.researchgate.release'
|
||||
|
||||
ext.configuredVersion = project.hasProperty('releaseVersion') ? project.releaseVersion : project.version
|
||||
ext.dokkaExcludes = [
|
||||
'ktor-server',
|
||||
'ktor-samples',
|
||||
'ktor-features',
|
||||
'ktor-client'
|
||||
]
|
||||
|
||||
ext.configuredVersion = project.hasProperty("releaseVersion") ? project.releaseVersion : project.version
|
||||
ext.globalM2 = "$buildDir/m2"
|
||||
ext.publishLocal = project.hasProperty('publishLocal')
|
||||
ext.publishLocal = project.hasProperty("publishLocal")
|
||||
|
||||
apply from: 'gradle/platform.gradle'
|
||||
apply from: 'gradle/experimental.gradle'
|
||||
apply from: "gradle/experimental.gradle"
|
||||
|
||||
/**
|
||||
* `darwin` is subset of `posix`.
|
||||
* Don't create `posix` and `darwin` sourceSets in single project.
|
||||
*/
|
||||
def platforms = ["common", "jvm", "js", "posix", "darwin"]
|
||||
rootProject.ext.misc = ["binary-compatibility-validator", "ktor-server-benchmarks"]
|
||||
|
||||
def projectNeedsPlatform(project, platform) {
|
||||
if (rootProject.ext.misc.contains(project.name)) return platform == "jvm"
|
||||
|
||||
def files = project.projectDir.listFiles()
|
||||
def hasPosix = files.any { it.name == "posix" }
|
||||
def hasDarwin = files.any { it.name == "darwin" }
|
||||
|
||||
if (hasPosix && hasDarwin) return false
|
||||
if (!hasDarwin && platform == "darwin") return false
|
||||
|
||||
return files.any { it.name == "common" || it.name == platform }
|
||||
}
|
||||
|
||||
allprojects {
|
||||
def platform = platformOf(project)
|
||||
|
||||
group = 'io.ktor'
|
||||
group = "io.ktor"
|
||||
version = configuredVersion
|
||||
project.ext.hostManager = new HostManager()
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven { url 'https://dl.bintray.com/kotlin/kotlinx/' }
|
||||
maven { url kotlin_repository }
|
||||
maven { url "https://dl.bintray.com/kotlin/kotlinx/" }
|
||||
maven { url "https://dl.bintray.com/kotlin/kotlin-eap" }
|
||||
maven { url "https://dl.bintray.com/kotlin/kotlin-dev" }
|
||||
|
||||
jcenter()
|
||||
}
|
||||
|
||||
apply plugin: "kotlin-platform-${platform}"
|
||||
apply from: rootProject.file("gradle/atomicfu-${platform}.gradle")
|
||||
apply from: rootProject.file("gradle/${platform}.gradle")
|
||||
|
||||
if (project.name != 'binary-compatibility-validator') {
|
||||
apply from: rootProject.file('gradle/publish.gradle')
|
||||
}
|
||||
apply plugin: "kotlin-multiplatform"
|
||||
apply plugin: "kotlinx-atomicfu"
|
||||
|
||||
if (project.parent != null && project.parent.name == 'ktor-server') {
|
||||
apply from: rootProject.file('gradle/engines.gradle')
|
||||
}
|
||||
|
||||
task sourceJar(type: Jar, dependsOn: classes) {
|
||||
classifier 'sources'
|
||||
if (platform != 'native') {
|
||||
from sourceSets.main.kotlin
|
||||
duplicatesStrategy DuplicatesStrategy.EXCLUDE
|
||||
def platformSrc = sourceSets.main.allSource
|
||||
def commonSrc = rootProject.sourceSets.main.allSource
|
||||
from(platformSrc + commonSrc)
|
||||
platforms.each { platform ->
|
||||
if (projectNeedsPlatform(project, platform)) {
|
||||
configure([it]) {
|
||||
apply from: rootProject.file("gradle/utility.gradle")
|
||||
apply from: rootProject.file("gradle/${platform}.gradle")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task emptyJar(type: Jar) {
|
||||
classifier 'javadoc'
|
||||
if (!rootProject.ext.misc.contains(project.name)) {
|
||||
apply from: rootProject.file('gradle/dokka.gradle')
|
||||
apply from: rootProject.file('gradle/publish.gradle')
|
||||
}
|
||||
|
||||
tasks.build.dependsOn(['sourceJar', 'emptyJar'])
|
||||
configurations { testOutput }
|
||||
|
||||
}
|
||||
kotlin {
|
||||
configure(sourceSets) {
|
||||
def srcDir = name.endsWith("Main") ? "src" : "test"
|
||||
def resourcesPrefix = name.endsWith("Test") ? "test-" : ""
|
||||
def platform = name[0..-5]
|
||||
|
||||
release {
|
||||
scmAdapters = [net.researchgate.release.GitAdapter]
|
||||
git {
|
||||
requireBranch = 'gradle-build'
|
||||
kotlin.srcDirs = ["$platform/$srcDir"]
|
||||
resources.srcDirs = ["$platform/${resourcesPrefix}resources"]
|
||||
|
||||
if (rootProject.ext.misc.contains(project.name)) return
|
||||
languageSettings {
|
||||
progressiveMode = true
|
||||
experimentalAnnotations.each { useExperimentalAnnotation(it) }
|
||||
|
||||
if (project.path.startsWith(":ktor-server:ktor-server") && project.name != "ktor-server-core") {
|
||||
useExperimentalAnnotation("io.ktor.server.engine.EngineAPI")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
afterReleaseBuild.dependsOn bintrayUpload
|
||||
|
||||
@@ -3,11 +3,15 @@ kotlin.code.style=official
|
||||
|
||||
# config
|
||||
version=1.0.2-SNAPSHOT
|
||||
kotlin.incremental.js=true
|
||||
kotlin.incremental.multiplatform=true
|
||||
|
||||
# gradle
|
||||
org.gradle.daemon=true
|
||||
org.gradle.jvmargs=-Xmx2g -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
|
||||
|
||||
# kotlin
|
||||
kotlin_version=1.3.11
|
||||
kotlin_native_version=1.3.11
|
||||
|
||||
# kotlin libraries
|
||||
kotlinx_io_version=0.1.2-dev-9
|
||||
@@ -19,16 +23,15 @@ atomic_fu_version=0.11.12
|
||||
netty_version=4.1.24.Final
|
||||
netty_tcnative_version=2.0.8.Final
|
||||
jetty_version=9.4.11.v20180605
|
||||
jetty_alpn_boot_version=8.1.12.v20180117
|
||||
jetty_alpn_api_version=1.1.3.v20160715
|
||||
|
||||
# utility
|
||||
logback_version=1.2.3
|
||||
junit_version=4.12
|
||||
dokka_version=0.9.16
|
||||
dokka_version=0.9.17
|
||||
jmh_version=1.20
|
||||
gradle_node_version=1.2.0
|
||||
nodejs_version=8.9.3
|
||||
nodejs_version=10.14.1
|
||||
npm_version=6.4.1
|
||||
|
||||
# publishing
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
|
||||
dependencies {
|
||||
compile "org.jetbrains.kotlinx:atomicfu-common:$atomic_fu_version"
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
dependencies {
|
||||
compile "org.jetbrains.kotlinx:atomicfu-js:$atomic_fu_version"
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
|
||||
apply plugin: 'kotlinx-atomicfu'
|
||||
|
||||
dependencies {
|
||||
compileOnly "org.jetbrains.kotlinx:atomicfu:$atomic_fu_version"
|
||||
testCompile "org.jetbrains.kotlinx:atomicfu:$atomic_fu_version"
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
|
||||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlinx:atomicfu-native:$atomic_fu_version"
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
apply plugin: 'com.jfrog.bintray'
|
||||
|
||||
bintray {
|
||||
user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
|
||||
key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
|
||||
publish = false
|
||||
override = true
|
||||
|
||||
pkg {
|
||||
userOrg = 'kotlin'
|
||||
repo = 'ktor'
|
||||
name = 'ktor'
|
||||
|
||||
publications = ['mavenProject']
|
||||
licenses = ['Apache-2.0']
|
||||
vcsUrl = 'https://github.com/ktorio/ktor'
|
||||
|
||||
version {
|
||||
name = project.version
|
||||
released = new Date()
|
||||
vcsTag = project.version
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bintrayUpload.doFirst {
|
||||
publications = project.publishing.publications
|
||||
}
|
||||
@@ -1,36 +1,17 @@
|
||||
kotlin.sourceSets {
|
||||
commonMain.dependencies {
|
||||
api 'org.jetbrains.kotlin:kotlin-stdlib-common'
|
||||
api group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib-common', version: kotlin_version
|
||||
api group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-core-common', version: coroutines_version
|
||||
api group: 'org.jetbrains.kotlinx', name: 'kotlinx-io', version: kotlinx_io_version
|
||||
api group: 'org.jetbrains.kotlinx', name: 'atomicfu', version: atomic_fu_version
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
kotlin.srcDir 'src'
|
||||
resources.srcDir 'resources'
|
||||
api group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-io', version: kotlinx_io_version
|
||||
}
|
||||
test {
|
||||
kotlin.srcDir 'test'
|
||||
resources.srcDir 'test-resources'
|
||||
commonTest.dependencies {
|
||||
api "org.jetbrains.kotlin:kotlin-test-common:$kotlin_version"
|
||||
api "org.jetbrains.kotlin:kotlin-test-annotations-common:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
compileKotlinCommon {
|
||||
kotlinOptions.freeCompilerArgs += [ experimentalAnnotations ]
|
||||
}
|
||||
|
||||
compileTestKotlinCommon {
|
||||
kotlinOptions.freeCompilerArgs += [ experimentalAnnotations ]
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib-common', version: kotlin_version
|
||||
compile group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-core-common', version: coroutines_version
|
||||
|
||||
compile(group: 'org.jetbrains.kotlinx', name: 'kotlinx-io', version: kotlinx_io_version) {
|
||||
exclude(module: 'kotlin-stdlib-common')
|
||||
}
|
||||
|
||||
compile(group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-io', version: kotlinx_io_version) {
|
||||
exclude(module: 'kotlin-stdlib-common')
|
||||
}
|
||||
|
||||
testCompile "org.jetbrains.kotlin:kotlin-test-annotations-common:$kotlin_version"
|
||||
testCompile "org.jetbrains.kotlin:kotlin-test-common:$kotlin_version"
|
||||
}
|
||||
project.ext.set("commonStructure", true)
|
||||
|
||||
@@ -1,13 +1,25 @@
|
||||
apply from: rootProject.file('gradle/platform.gradle')
|
||||
|
||||
configurations {
|
||||
binaryCompatibility
|
||||
}
|
||||
|
||||
dependencies {
|
||||
def excludeList = ['ktor-client-tests', 'ktor-client-features', 'ktor-client-js', 'ktor-client-json-tests'].toSet()
|
||||
def excludeList = [
|
||||
'ktor-client-tests',
|
||||
'ktor-client-js',
|
||||
'ktor-client-json-tests',
|
||||
'ktor-client-curl',
|
||||
'ktor-client-ios',
|
||||
'ktor-client',
|
||||
'ktor-client-features'
|
||||
].toSet()
|
||||
|
||||
def projects = [].toSet()
|
||||
def queue = [project(':ktor-client')]
|
||||
def queue = [
|
||||
project(":ktor-client"),
|
||||
project(":ktor-http"),
|
||||
project(":ktor-network"),
|
||||
project(":ktor-utils")
|
||||
]
|
||||
|
||||
while (!queue.isEmpty()) {
|
||||
def project = queue.remove(queue.size() - 1) as Project
|
||||
@@ -16,37 +28,19 @@ dependencies {
|
||||
}
|
||||
}
|
||||
|
||||
binaryCompatibility projects.findAll {
|
||||
!excludeList.contains(it.name) &&
|
||||
platformOf(it) == 'jvm'
|
||||
}
|
||||
binaryCompatibility projects.findAll { !excludeList.contains(it.name) }
|
||||
}
|
||||
|
||||
def buildList = {
|
||||
def workQueue = []
|
||||
def allModules = new HashSet<ProjectDependency>()
|
||||
def allModules = configurations.binaryCompatibility.allDependencies.findAll { it instanceof ProjectDependency }
|
||||
|
||||
workQueue += configurations.binaryCompatibility.allDependencies.findAll { it instanceof ProjectDependency }
|
||||
|
||||
while (!workQueue.isEmpty()) {
|
||||
def p = workQueue.remove(workQueue.size() - 1)
|
||||
if (p instanceof ProjectDependency && allModules.add(p)) {
|
||||
p.dependencyProject.configurations.forEach { configuration ->
|
||||
if (!configuration.name.toLowerCase().contains('test') && configuration.name.toLowerCase().contains("jvm")) {
|
||||
workQueue += configuration.allDependencies.findAll { it instanceof ProjectDependency }
|
||||
} else if (configuration.name == 'compile') {
|
||||
def task = p.dependencyProject.tasks.findByName('compileKotlin')
|
||||
if (task != null) {
|
||||
workQueue += configuration.allDependencies.findAll { it instanceof ProjectDependency }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return allModules
|
||||
.sort { it.name }
|
||||
.findAll {
|
||||
def isCommon = it.dependencyProject.file("common").exists()
|
||||
def isJvm = it.dependencyProject.file("jvm").exists()
|
||||
isCommon || isJvm ? it.dependencyProject : null
|
||||
}
|
||||
|
||||
return allModules.toList().sort { it.name }.findAll { platformOf(it.dependencyProject) == 'jvm' }
|
||||
}
|
||||
|
||||
project.ext.buildList = buildList
|
||||
|
||||
// println "List of modules: \n" + modulesForBinaryCompatibility.collect { it.name }.sort().join('\n')
|
||||
|
||||
38
gradle/darwin.gradle
Normal file
38
gradle/darwin.gradle
Normal file
@@ -0,0 +1,38 @@
|
||||
apply from: rootProject.file("gradle/ide.gradle")
|
||||
|
||||
kotlin {
|
||||
targets {
|
||||
if (project.ext.ideaActive) {
|
||||
fromPreset(project.ext.ideaPreset, 'darwin')
|
||||
} else {
|
||||
fromPreset(presets.iosArm64, 'iosArm64')
|
||||
fromPreset(presets.iosX64, 'iosX64')
|
||||
fromPreset(presets.macosX64, 'macosX64')
|
||||
}
|
||||
/* fromPreset(presets.iosArm32, 'iosArm32') */
|
||||
}
|
||||
sourceSets {
|
||||
darwinMain.dependencies {
|
||||
implementation group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-core-native', version: coroutines_version
|
||||
implementation group: 'org.jetbrains.kotlinx', name: 'kotlinx-io-native', version: kotlinx_io_version
|
||||
implementation group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-io-native', version: kotlinx_io_version
|
||||
|
||||
implementation "org.jetbrains.kotlinx:atomicfu:$atomic_fu_version"
|
||||
}
|
||||
|
||||
darwinMain { dependsOn commonMain }
|
||||
darwinTest { dependsOn darwinMain }
|
||||
|
||||
if (!project.ext.ideaActive) {
|
||||
configure([/*iosArm32Main, */ iosArm64Main, iosX64Main, macosX64Main]) {
|
||||
dependsOn darwinMain
|
||||
}
|
||||
|
||||
configure([/*iosArm32Test, */ iosArm64Test, iosX64Test, macosX64Test]) {
|
||||
dependsOn darwinTest
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
project.ext.set("hasNative", true)
|
||||
@@ -1,21 +1,37 @@
|
||||
|
||||
apply plugin: 'org.jetbrains.dokka'
|
||||
|
||||
dokka {
|
||||
outputFormat = 'html'
|
||||
outputDirectory = "$buildDir/kdoc"
|
||||
|
||||
kotlinTasks {
|
||||
defaultKotlinTasks().findAll { it.name.contains("Jvm") }
|
||||
}
|
||||
|
||||
reportUndocumented = false
|
||||
}
|
||||
|
||||
task dokkaJavadoc(type: dokka.getClass()) {
|
||||
outputFormat = 'javadoc'
|
||||
outputDirectory = "$buildDir/javadoc"
|
||||
|
||||
kotlinTasks {
|
||||
defaultKotlinTasks().findAll { it.name.contains("Jvm") }
|
||||
}
|
||||
|
||||
reportUndocumented = false
|
||||
}
|
||||
|
||||
task dokkaWebsite(type: dokka.getClass()) {
|
||||
outputFormat = 'kotlin-website'
|
||||
outputDirectory = "${rootProject.projectDir}/apidoc"
|
||||
}
|
||||
|
||||
kotlinTasks {
|
||||
defaultKotlinTasks().findAll { it.name.contains("Jvm") }
|
||||
}
|
||||
|
||||
reportUndocumented = false
|
||||
}
|
||||
|
||||
task javadocJar(type: Jar, dependsOn: 'dokkaJavadoc') {
|
||||
classifier = 'javadoc'
|
||||
@@ -26,6 +42,3 @@ task dokkaJar(type: Jar, dependsOn: 'dokka') {
|
||||
classifier = 'kdoc'
|
||||
from fileTree(new File(project.buildDir, 'kdoc'))
|
||||
}
|
||||
|
||||
artifacts.archives javadocJar
|
||||
artifacts.archives dokkaJar
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
|
||||
if (project.name != 'ktor-server-core') {
|
||||
compileKotlin {
|
||||
kotlinOptions.freeCompilerArgs += ['-Xuse-experimental=kotlin.Experimental,io.ktor.server.engine.EngineAPI']
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
ext.experimentalAnnotations = "-Xuse-experimental=" +
|
||||
"kotlin.Experimental," +
|
||||
"io.ktor.util.KtorExperimentalAPI," +
|
||||
"io.ktor.util.InternalAPI," +
|
||||
"kotlinx.coroutines.ExperimentalCoroutinesApi," +
|
||||
ext.experimentalAnnotations = [
|
||||
"kotlin.Experimental",
|
||||
"kotlin.ExperimentalUnsignedTypes",
|
||||
"io.ktor.util.KtorExperimentalAPI",
|
||||
"io.ktor.util.InternalAPI",
|
||||
"kotlinx.coroutines.ExperimentalCoroutinesApi",
|
||||
"kotlinx.io.core.ExperimentalIoApi"
|
||||
]
|
||||
|
||||
17
gradle/ide.gradle
Normal file
17
gradle/ide.gradle
Normal file
@@ -0,0 +1,17 @@
|
||||
task prepareIdeInterop(type: Copy) {
|
||||
if (project.ext.isLinuxHost) {
|
||||
from "build/classes/kotlin/linuxX64"
|
||||
}
|
||||
if (project.ext.isMacosHost) {
|
||||
from "build/classes/kotlin/macosX64"
|
||||
}
|
||||
if (project.ext.isWinHost) {
|
||||
from "build/classes/kotlin/mingwX64"
|
||||
}
|
||||
|
||||
into "build/classes/kotlin/posix"
|
||||
}
|
||||
|
||||
configure([assemble]) {
|
||||
doLast { prepareIdeInterop.execute() }
|
||||
}
|
||||
150
gradle/js.gradle
150
gradle/js.gradle
@@ -1,87 +1,67 @@
|
||||
apply plugin: 'com.moowork.node'
|
||||
apply from: rootProject.file('gradle/nodejs.gradle')
|
||||
|
||||
node {
|
||||
// version = "$nodejs_version"
|
||||
// npmVersion = "$npm_version"
|
||||
download = false
|
||||
nodeModulesDir = file(buildDir)
|
||||
}
|
||||
kotlin {
|
||||
targets {
|
||||
fromPreset(presets.js, 'js')
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
|
||||
compile "org.jetbrains.kotlin:kotlin-test-js:$kotlin_version"
|
||||
sourceSets {
|
||||
jsMain.dependencies {
|
||||
api "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
|
||||
|
||||
compile group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-core-js', version: coroutines_version
|
||||
compile group: 'org.jetbrains.kotlinx', name: 'kotlinx-io-js', version: kotlinx_io_version
|
||||
compile group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-io-js', version: kotlinx_io_version
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
task assembleWeb(type: Sync) {
|
||||
(configurations.compile).each { File file ->
|
||||
from(zipTree(file.absolutePath), {
|
||||
includeEmptyDirs = false
|
||||
include { fileTreeElement ->
|
||||
def path = fileTreeElement.path
|
||||
(path.endsWith(".js") || path.endsWith(".js.map")) && (path.startsWith("META-INF/resources/") ||
|
||||
!path.startsWith("META-INF/"))
|
||||
}
|
||||
})
|
||||
api group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-core-js', version: coroutines_version
|
||||
api group: 'org.jetbrains.kotlinx', name: 'kotlinx-io-js', version: kotlinx_io_version
|
||||
api group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-io-js', version: kotlinx_io_version
|
||||
api group: 'org.jetbrains.kotlinx', name: 'atomicfu-js', version: atomic_fu_version
|
||||
}
|
||||
jsTest.dependencies {
|
||||
api "org.jetbrains.kotlin:kotlin-test-js:$kotlin_version"
|
||||
}
|
||||
from compileKotlin2Js.destinationDir
|
||||
into "${projectDir}/build/web"
|
||||
|
||||
dependsOn classes
|
||||
}
|
||||
|
||||
assemble.dependsOn assembleWeb
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
kotlin.srcDir 'src'
|
||||
resources.srcDir 'resources'
|
||||
}
|
||||
test {
|
||||
kotlin.srcDir 'test'
|
||||
resources.srcDir 'test-resources'
|
||||
}
|
||||
}
|
||||
|
||||
compileKotlin2Js {
|
||||
compileKotlinJs {
|
||||
kotlinOptions.metaInfo = true
|
||||
kotlinOptions.sourceMap = true
|
||||
kotlinOptions.moduleKind = 'umd'
|
||||
kotlinOptions.main = "noCall"
|
||||
kotlinOptions.main = 'noCall'
|
||||
kotlinOptions.sourceMapEmbedSources = 'always'
|
||||
kotlinOptions.freeCompilerArgs += ['-Xuse-experimental=kotlin.Experimental,io.ktor.util.KtorExperimentalAPI,io.ktor.util.InternalAPI']
|
||||
}
|
||||
|
||||
compileTestKotlin2Js {
|
||||
compileTestKotlinJs {
|
||||
kotlinOptions.metaInfo = true
|
||||
kotlinOptions.sourceMap = true
|
||||
kotlinOptions.moduleKind = 'umd'
|
||||
kotlinOptions.main = "call"
|
||||
kotlinOptions.main = 'call'
|
||||
kotlinOptions.sourceMapEmbedSources = 'always'
|
||||
kotlinOptions.freeCompilerArgs += ['-Xuse-experimental=kotlin.Experimental,io.ktor.util.KtorExperimentalAPI,io.ktor.util.InternalAPI']
|
||||
}
|
||||
|
||||
task installDependenciesMochaChrome(type: NpmTask, dependsOn: [npmInstall]) {
|
||||
args = ['install',
|
||||
"mocha@$mocha_version",
|
||||
"mocha-headless-chrome@$mocha_headless_chrome_version",
|
||||
"mocha-teamcity-reporter@$mocha_teamcity_reporter_version",
|
||||
'--no-save'
|
||||
]
|
||||
task assembleWeb(type: Sync, group: 'build', dependsOn: compileTestKotlinJs) {
|
||||
from compileKotlinJs.destinationDir
|
||||
into "$node.nodeModulesDir/node_modules"
|
||||
|
||||
def configuration = configurations.jsTestRuntimeClasspath
|
||||
from(files {
|
||||
configuration.collect { File file ->
|
||||
file.name.endsWith(".jar") ?
|
||||
zipTree(file.absolutePath).matching {
|
||||
include '*.js'
|
||||
include '*.js.map'
|
||||
} :
|
||||
files()
|
||||
}
|
||||
}.builtBy(configuration))
|
||||
}
|
||||
|
||||
def mochaChromeTestPage = file("$buildDir/test-page.html")
|
||||
|
||||
task prepareMochaChrome(dependsOn: [compileTestKotlin2Js, installDependenciesMochaChrome]) {
|
||||
task prepareMocha(dependsOn: installDependenciesMocha) {
|
||||
outputs.file(mochaChromeTestPage)
|
||||
}
|
||||
|
||||
prepareMochaChrome.doLast {
|
||||
prepareMocha.doLast {
|
||||
def libraryPath = "$buildDir/node_modules"
|
||||
|
||||
def reporter = (project.hasProperty("teamcity")) ? "mocha.setup({reporter: 'teamcity'});" : ""
|
||||
mochaChromeTestPage.text = """<!DOCTYPE html>
|
||||
<html>
|
||||
@@ -96,36 +76,44 @@ prepareMochaChrome.doLast {
|
||||
<script src="$node.nodeModulesDir/node_modules/mocha-teamcity-reporter/lib/teamcityBrowser.js"></script>
|
||||
<script>mocha.timeout(10000000);</script>
|
||||
<script>mocha.setup('bdd');</script>
|
||||
<script>
|
||||
$reporter
|
||||
mocha.checkLeaks();
|
||||
</script>
|
||||
<script src="$projectDir/build/web/kotlin.js"></script>
|
||||
<script src="$projectDir/build/web/kotlin-test.js"></script>
|
||||
<script src="$projectDir/build/web/kotlinx-atomicfu.js"></script>
|
||||
<script src="$projectDir/build/web/kotlinx-coroutines-core.js"></script>
|
||||
<script src="$projectDir/build/web/kotlinx-io-js.js"></script>
|
||||
<script src="$projectDir/build/web/kotlinx-coroutines-io-js.js"></script>
|
||||
<script src="$projectDir/build/web/kotlinx-serialization-runtime-js.js"></script>
|
||||
<script src="$projectDir/build/web/ktor-utils-js.js"></script>
|
||||
<script src="$projectDir/build/web/ktor-http-js.js"></script>
|
||||
<script src="$projectDir/build/web/ktor-client-core-js.js"></script>
|
||||
<script src="$projectDir/build/web/ktor-client-js.js"></script>
|
||||
<script src="$projectDir/build/web/ktor-client-json-js.js"></script>
|
||||
<script src="$compileTestKotlin2Js.outputFile"></script>
|
||||
<script src="$libraryPath/kotlin.js"></script>
|
||||
<script src="$libraryPath/kotlin-test.js"></script>
|
||||
<script src="$libraryPath/kotlinx-atomicfu.js"></script>
|
||||
<script src="$libraryPath/kotlinx-coroutines-core.js"></script>
|
||||
<script src="$libraryPath/kotlinx-io.js"></script>
|
||||
<script src="$libraryPath/kotlinx-coroutines-io.js"></script>
|
||||
<script src="$libraryPath/kotlinx-serialization-runtime-js.js"></script>
|
||||
<script src="$libraryPath/ktor-utils.js"></script>
|
||||
<script src="$libraryPath/ktor-http.js"></script>
|
||||
<script src="$libraryPath/ktor-http-cio.js"></script>
|
||||
<script src="$libraryPath/ktor-client-core.js"></script>
|
||||
<script src="$libraryPath/ktor-client.js"></script>
|
||||
<script src="$libraryPath/ktor-client-json.js"></script>
|
||||
<script src="$libraryPath/ktor-client-auth-basic.js"></script>
|
||||
<script src="$compileTestKotlinJs.outputFile"></script>
|
||||
<script>mocha.run();</script>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
}
|
||||
|
||||
task testMochaChrome(type: NodeTask, dependsOn: prepareMochaChrome) {
|
||||
task testMochaChrome(type: NodeTask, dependsOn: prepareMocha) {
|
||||
script = file("$node.nodeModulesDir/node_modules/mocha-headless-chrome/bin/start")
|
||||
args = [compileTestKotlin2Js.outputFile, '--file', mochaChromeTestPage, '-a', 'no-sandbox', '-a', 'disable-setuid-sandbox']
|
||||
args += ['--reporter', 'mocha-teamcity-reporter']
|
||||
if (project.hasProperty("mochaTests")) args += ['--grep', "$mochaTests"]
|
||||
description = "Run js tests in mocha-headless-chrome"
|
||||
args = [compileTestKotlinJs.outputFile, '--file', mochaChromeTestPage]
|
||||
if (project.hasProperty("teamcity")) args += ['--reporter', 'mocha-teamcity-reporter', '--no-sandbox']
|
||||
}
|
||||
|
||||
if (project.hasProperty("enable-js-tests")) {
|
||||
test.dependsOn testMochaChrome
|
||||
task testMochaNode(type: NodeTask, dependsOn: prepareMocha) {
|
||||
script = file("$node.nodeModulesDir/node_modules/mocha/bin/mocha")
|
||||
description = "Run js tests in mocha-nodejs"
|
||||
args = [compileTestKotlinJs.outputFile, '--require', 'source-map-support/register']
|
||||
if (project.hasProperty("teamcity")) args += ['--reporter', 'mocha-teamcity-reporter', '--no-sandbox']
|
||||
}
|
||||
|
||||
npmInstall.dependsOn assembleWeb
|
||||
//jsTest.dependsOn testMochaNode
|
||||
|
||||
if (!project.hasProperty("teamcity") || project.hasProperty("enable-js-tests")) {
|
||||
jsTest.dependsOn testMochaChrome
|
||||
}
|
||||
|
||||
@@ -1,27 +1,65 @@
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
kotlin.srcDir 'src'
|
||||
resources.srcDir 'resources'
|
||||
kotlin {
|
||||
targets {
|
||||
fromPreset(presets.jvm, 'jvm')
|
||||
}
|
||||
test {
|
||||
kotlin.srcDir 'test'
|
||||
resources.srcDir 'test-resources'
|
||||
|
||||
task jarTest(type: Jar, dependsOn: jvmTestClasses) {
|
||||
from targets.jvm.compilations.test.output
|
||||
classifier 'test'
|
||||
}
|
||||
|
||||
configure(targets) {
|
||||
compilations.all { compilation ->
|
||||
if (compilation.name == "main") {
|
||||
def compileTask = tasks.getByName(compilation.compileKotlinTaskName)
|
||||
// dump declarations from main JVM module for binary-compatibility-validator
|
||||
compileTask.kotlinOptions.freeCompilerArgs += ["-Xdump-declarations-to=${buildDir}/visibilities.json"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
jvmMain.dependencies {
|
||||
api 'org.jetbrains.kotlin:kotlin-stdlib'
|
||||
api group: 'org.jetbrains.kotlin', name: 'kotlin-reflect', version: kotlin_version
|
||||
api group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: kotlin_version
|
||||
api group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib-jdk7', version: kotlin_version
|
||||
api group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib-jdk8', version: kotlin_version
|
||||
api group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-core', version: coroutines_version
|
||||
api group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-jdk8', version: coroutines_version
|
||||
|
||||
api(group: 'org.jetbrains.kotlinx', name: 'kotlinx-io-jvm', version: kotlinx_io_version)
|
||||
api(group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-io-jvm', version: kotlinx_io_version)
|
||||
api("org.jetbrains.kotlinx:atomicfu:$atomic_fu_version")
|
||||
|
||||
api group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
|
||||
api group: 'com.typesafe', name: 'config', version: '1.3.1'
|
||||
}
|
||||
|
||||
jvmTest.dependencies {
|
||||
api 'org.jetbrains.kotlin:kotlin-test'
|
||||
api 'org.jetbrains.kotlin:kotlin-test-junit'
|
||||
api "junit:junit:$junit_version"
|
||||
|
||||
api group: 'org.jetbrains.kotlin', name: 'kotlin-test-junit', version: kotlin_version
|
||||
api group: 'junit', name: 'junit', version: junit_version
|
||||
|
||||
api "org.jetbrains.kotlinx:atomicfu:$atomic_fu_version"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task jarTest(type: Jar, dependsOn: testClasses) {
|
||||
from sourceSets.test.output
|
||||
classifier = 'test'
|
||||
}
|
||||
|
||||
test {
|
||||
jvmTest {
|
||||
ignoreFailures = true
|
||||
maxHeapSize = "2g"
|
||||
exclude("**/*StressTest*")
|
||||
}
|
||||
|
||||
task stressTest(type: Test, dependsOn: testClasses) {
|
||||
task stressTest(type: Test) {
|
||||
classpath = files { jvmTest.classpath }
|
||||
testClassesDirs = files { jvmTest.testClassesDirs }
|
||||
|
||||
ignoreFailures = true
|
||||
maxHeapSize = "2g"
|
||||
forkEvery = 1
|
||||
@@ -29,60 +67,13 @@ task stressTest(type: Test, dependsOn: testClasses) {
|
||||
systemProperty "enable.stress.tests", "true"
|
||||
}
|
||||
|
||||
task packageSources(type: Jar) {
|
||||
classifier = 'sources'
|
||||
from sourceSets.main.allSource
|
||||
}
|
||||
|
||||
artifacts.archives packageSources
|
||||
|
||||
configurations {
|
||||
testOutput.extendsFrom(testCompile)
|
||||
boot
|
||||
}
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = 'UTF-8'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile group: 'org.jetbrains.kotlin', name: 'kotlin-reflect', version: kotlin_version
|
||||
compile group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: kotlin_version
|
||||
compile group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib-jdk7', version: kotlin_version
|
||||
compile group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib-jdk8', version: kotlin_version
|
||||
compile group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-core', version: coroutines_version
|
||||
compile group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-jdk8', version: coroutines_version
|
||||
|
||||
compile(group: 'org.jetbrains.kotlinx', name: 'kotlinx-io-jvm', version: kotlinx_io_version) {
|
||||
exclude(module: 'kotlin-stdlib-jvm')
|
||||
}
|
||||
|
||||
compile(group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-io-jvm', version: kotlinx_io_version) {
|
||||
exclude(module: 'kotlin-stdlib-jvm')
|
||||
}
|
||||
|
||||
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
|
||||
compile group: 'com.typesafe', name: 'config', version: '1.3.1'
|
||||
testCompile group: 'org.jetbrains.kotlin', name: 'kotlin-test-junit', version: kotlin_version
|
||||
testCompile group: 'junit', name: 'junit', version: junit_version
|
||||
}
|
||||
|
||||
jar {
|
||||
jvmJar {
|
||||
manifest {
|
||||
attributes("Implementation-Title": project.name, "Implementation-Version": configuredVersion)
|
||||
}
|
||||
}
|
||||
|
||||
compileKotlin {
|
||||
kotlinOptions.freeCompilerArgs += [ experimentalAnnotations ]
|
||||
|
||||
// dump declarations from main JVM module for binary-compatibility-validator
|
||||
kotlinOptions.freeCompilerArgs += ["-Xdump-declarations-to=${buildDir}/visibilities.json"]
|
||||
}
|
||||
|
||||
compileTestKotlin {
|
||||
kotlinOptions.freeCompilerArgs += [ experimentalAnnotations ]
|
||||
}
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
def pomConfig = {
|
||||
licenses {
|
||||
license {
|
||||
name 'The Apache Software License, Version 2.0'
|
||||
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
|
||||
distribution 'repo'
|
||||
}
|
||||
}
|
||||
developers {
|
||||
developer {
|
||||
id 'JetBrains'
|
||||
name 'JetBrains Team'
|
||||
organization 'JetBrains'
|
||||
organizationUrl 'http://www.jetbrains.com'
|
||||
}
|
||||
}
|
||||
|
||||
scm {
|
||||
url 'https://github.com/ktorio/ktor.git'
|
||||
}
|
||||
}
|
||||
|
||||
def withPom = { pom ->
|
||||
pom.withXml {
|
||||
def root = asNode()
|
||||
root.appendNode('name', project.name)
|
||||
root.appendNode('description',
|
||||
'Framework for quickly creating connected applications in Kotlin with minimal effort')
|
||||
root.appendNode('url', 'https://github.com/ktorio/ktor')
|
||||
root.children().last() + pomConfig
|
||||
}
|
||||
}
|
||||
|
||||
project.ext.configurePom = withPom
|
||||
@@ -1,36 +0,0 @@
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
kotlin.srcDir 'src'
|
||||
component {
|
||||
targets = ['ios_arm64', 'ios_x64', 'macos_x64']
|
||||
outputKinds = [KLIBRARY]
|
||||
extraOpts experimentalAnnotations
|
||||
|
||||
pom {
|
||||
project.ext.configurePom(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
test {
|
||||
kotlin.srcDir 'test'
|
||||
component {
|
||||
targets = ['ios_arm64', 'ios_x64', 'macos_x64']
|
||||
extraOpts experimentalAnnotations
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-core-native', version: coroutines_version
|
||||
implementation group: 'org.jetbrains.kotlinx', name: 'kotlinx-io-native', version: kotlinx_io_version
|
||||
implementation group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-io-native', version: kotlinx_io_version
|
||||
}
|
||||
|
||||
if (project.hasProperty("teamcity")) {
|
||||
afterEvaluate {
|
||||
tasks.withType(Class.forName("org.gradle.nativeplatform.test.tasks.RunTestExecutable")) {
|
||||
args '--ktest_logger=TEAMCITY'
|
||||
}
|
||||
}
|
||||
}
|
||||
43
gradle/nodejs.gradle
Normal file
43
gradle/nodejs.gradle
Normal file
@@ -0,0 +1,43 @@
|
||||
apply plugin: 'com.moowork.node'
|
||||
|
||||
node {
|
||||
version = "$nodejs_version"
|
||||
npmVersion = "$npm_version"
|
||||
|
||||
download = true
|
||||
nodeModulesDir = file(buildDir)
|
||||
}
|
||||
|
||||
repositories.whenObjectAdded {
|
||||
if (it instanceof IvyArtifactRepository) {
|
||||
metadataSources {
|
||||
artifact()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task prepareNodePackage(type: Copy) {
|
||||
from("npm") {
|
||||
include 'package.json'
|
||||
expand(project.properties + [kotlinDependency: ""])
|
||||
}
|
||||
from("npm") {
|
||||
exclude 'package.json'
|
||||
}
|
||||
into "$node.nodeModulesDir"
|
||||
}
|
||||
|
||||
npmInstall.dependsOn prepareNodePackage
|
||||
|
||||
task installDependenciesMocha(type: NpmTask, dependsOn: npmInstall) {
|
||||
args = [
|
||||
'install',
|
||||
"mocha@$mocha_version",
|
||||
"mocha-headless-chrome@$mocha_headless_chrome_version",
|
||||
"source-map-support@$source_map_support_version",
|
||||
'--no-save'
|
||||
]
|
||||
if (project.hasProperty("teamcity")) args += [
|
||||
"mocha-teamcity-reporter@$mocha_teamcity_reporter_version"
|
||||
]
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
def commonModules = [
|
||||
'ktor-client',
|
||||
'ktor-client-core',
|
||||
'ktor-client-json',
|
||||
'ktor-client-mock',
|
||||
'ktor-client-logging',
|
||||
'ktor-utils',
|
||||
'ktor-http'
|
||||
]
|
||||
|
||||
def nativeModules = [
|
||||
'ktor-client-ios',
|
||||
'ktor-http-ios',
|
||||
'ktor-utils-ios',
|
||||
'ktor-client-core-ios',
|
||||
'ktor-client-json-ios',
|
||||
'ktor-client-mock-ios',
|
||||
'ktor-client-logging-ios'
|
||||
]
|
||||
|
||||
def jsModules = [
|
||||
'ktor-client-js',
|
||||
'ktor-client-core-js',
|
||||
'ktor-http-js',
|
||||
'ktor-utils-js',
|
||||
'ktor-client-json-js',
|
||||
'ktor-client-mock-js',
|
||||
'ktor-client-logging-js'
|
||||
]
|
||||
|
||||
ext.platformOf = { Project project ->
|
||||
if (project.name in commonModules) return 'common'
|
||||
if (project.name in nativeModules) return 'native'
|
||||
if (project.name in jsModules) return 'js'
|
||||
return 'jvm'
|
||||
}
|
||||
37
gradle/pom.gradle
Normal file
37
gradle/pom.gradle
Normal file
@@ -0,0 +1,37 @@
|
||||
def pomConfig = {
|
||||
licenses {
|
||||
license {
|
||||
name "The Apache Software License, Version 2.0"
|
||||
url "http://www.apache.org/licenses/LICENSE-2.0.txt"
|
||||
distribution "repo"
|
||||
}
|
||||
}
|
||||
developers {
|
||||
developer {
|
||||
id "JetBrains"
|
||||
name "JetBrains Team"
|
||||
organization "JetBrains"
|
||||
organizationUrl "http://www.jetbrains.com"
|
||||
}
|
||||
}
|
||||
|
||||
scm {
|
||||
url "https://github.com/ktorio/ktor.git"
|
||||
}
|
||||
}
|
||||
|
||||
project.ext.configureMavenCentralMetadata = { pom ->
|
||||
def root = asNode()
|
||||
root.appendNode('name', project.name)
|
||||
root.appendNode('description', 'Ktor is a framework for quickly creating web applications in Kotlin with minimal effort.')
|
||||
root.appendNode('url', 'https://github.com/ktorio/ktor')
|
||||
root.children().last() + pomConfig
|
||||
|
||||
def dependenciesNode = asNode().getAt("dependencies")[0]
|
||||
if (dependenciesNode != null) {
|
||||
def dependencyNode = dependenciesNode.appendNode('dependency')
|
||||
dependencyNode.appendNode('groupId', "$group")
|
||||
dependencyNode.appendNode('artifactId', "$project.name")
|
||||
dependencyNode.appendNode('version', "$project.version")
|
||||
}
|
||||
}
|
||||
41
gradle/posix.gradle
Normal file
41
gradle/posix.gradle
Normal file
@@ -0,0 +1,41 @@
|
||||
apply from: rootProject.file("gradle/ide.gradle")
|
||||
|
||||
kotlin {
|
||||
targets {
|
||||
if (project.ext.ideaActive) {
|
||||
fromPreset(project.ext.ideaPreset, 'posix')
|
||||
} else {
|
||||
fromPreset(presets.linuxX64, 'linuxX64')
|
||||
fromPreset(presets.iosArm64, 'iosArm64')
|
||||
fromPreset(presets.iosX64, 'iosX64')
|
||||
fromPreset(presets.macosX64, 'macosX64')
|
||||
/* fromPreset(presets.iosArm32, 'iosArm32') */
|
||||
fromPreset(presets.mingwX64, 'mingwX64')
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
sourceSets {
|
||||
posixMain.dependencies {
|
||||
implementation group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-core-native', version: coroutines_version
|
||||
implementation group: 'org.jetbrains.kotlinx', name: 'kotlinx-io-native', version: kotlinx_io_version
|
||||
implementation group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-io-native', version: kotlinx_io_version
|
||||
|
||||
implementation "org.jetbrains.kotlinx:atomicfu:$atomic_fu_version"
|
||||
}
|
||||
|
||||
posixTest { dependsOn posixMain}
|
||||
posixMain { dependsOn commonMain }
|
||||
|
||||
if (!project.ext.ideaActive) {
|
||||
configure([/*iosArm32Main, */ iosArm64Main, iosX64Main, macosX64Main, linuxX64Main, mingwX64Main]) {
|
||||
dependsOn posixMain
|
||||
}
|
||||
configure([/*iosArm32Test, */ iosArm64Test, iosX64Test, macosX64Test, linuxX64Test, mingwX64Test]) {
|
||||
dependsOn posixTest
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
project.ext.set("hasNative", true)
|
||||
@@ -2,14 +2,42 @@ apply plugin: 'maven'
|
||||
apply plugin: 'maven-publish'
|
||||
apply plugin: 'com.jfrog.bintray'
|
||||
|
||||
apply from: rootProject.file('gradle/platform.gradle')
|
||||
apply from: rootProject.file('gradle/maven.gradle')
|
||||
apply from: project.rootProject.file('gradle/pom.gradle')
|
||||
|
||||
def platform = platformOf(project)
|
||||
def skipDokka = project.path.contains("ktor-samples") || project == rootProject || project.name in dokkaExcludes || platform != 'jvm'
|
||||
task emptyJar(type: Jar) {
|
||||
}
|
||||
|
||||
if (!skipDokka) {
|
||||
apply from: rootProject.file('gradle/dokka.gradle')
|
||||
task stubJavadoc(type: Jar) {
|
||||
classifier 'javadoc'
|
||||
}
|
||||
|
||||
task stubDokka(type: Jar) {
|
||||
classifier 'kdoc'
|
||||
}
|
||||
|
||||
def selectArtifactId(project, type) {
|
||||
def name = project.name
|
||||
def OBSOLETE = "$name-$type-obsolete"
|
||||
def isCommon = project.ext.has("commonStructure")
|
||||
def commonIsRoot = project.ext.has("commonStructure") && project.ext.commonStructure
|
||||
def hasNative = project.ext.has("hasNative") && project.ext.hasNative
|
||||
|
||||
switch (type) {
|
||||
case 'metadata':
|
||||
if (!isCommon) return OBSOLETE
|
||||
return commonIsRoot ? "$name" : "$name-common"
|
||||
break
|
||||
case 'kotlinMultiplatform':
|
||||
if (!hasNative) return OBSOLETE
|
||||
return isCommon ? "$name-native" : "$name"
|
||||
break
|
||||
case 'jvm':
|
||||
return commonIsRoot ? "$name-jvm" : "$name"
|
||||
break
|
||||
default:
|
||||
return isCommon || hasNative ? "$name-$type" : "$name"
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
@@ -22,34 +50,71 @@ publishing {
|
||||
}
|
||||
}
|
||||
}
|
||||
publications.all {
|
||||
pom.withXml(configureMavenCentralMetadata)
|
||||
def id = selectArtifactId(project, it.name)
|
||||
it.artifactId = id
|
||||
if (id.endsWith('native')) {
|
||||
it.artifact stubJavadoc
|
||||
it.artifact stubDokka
|
||||
it.artifact emptyJar
|
||||
}
|
||||
}
|
||||
|
||||
publications {
|
||||
mavenProject(MavenPublication) {
|
||||
if (platform != 'native') {
|
||||
from components.java
|
||||
}
|
||||
groupId project.group
|
||||
artifactId project.name
|
||||
version project.version
|
||||
kotlin.targets.all { target ->
|
||||
def publication = publishing.publications.findByName(target.name)
|
||||
|
||||
artifact sourceJar
|
||||
|
||||
if (!skipDokka) {
|
||||
artifact javadocJar {
|
||||
classifier 'javadoc'
|
||||
}
|
||||
|
||||
artifact dokkaJar {
|
||||
classifier 'kdoc'
|
||||
}
|
||||
if (publication != null) {
|
||||
if (target.platformType.name == 'jvm') {
|
||||
publication.artifact javadocJar
|
||||
publication.artifact dokkaJar
|
||||
} else {
|
||||
publication.artifact stubJavadoc
|
||||
publication.artifact stubDokka
|
||||
}
|
||||
|
||||
configurePom(pom)
|
||||
if (target.platformType.name != 'native') {
|
||||
publication.gradleModuleMetadataFile = null
|
||||
tasks.matching { it.name == "generateMetadataFileFor${name.capitalize()}Publication" }.all {
|
||||
onlyIf { false }
|
||||
}
|
||||
} else {
|
||||
publication.artifact emptyJar
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
publications.removeIf { it.artifactId.endsWith("-obsolete") }
|
||||
}
|
||||
|
||||
bintray {
|
||||
user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
|
||||
key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
|
||||
publish = true
|
||||
override = true
|
||||
|
||||
pkg {
|
||||
userOrg = 'kotlin'
|
||||
repo = 'ktor'
|
||||
name = 'ktor'
|
||||
licenses = ['Apache-2.0']
|
||||
vcsUrl = 'https://github.com/ktorio/ktor'
|
||||
|
||||
version {
|
||||
name = project.version
|
||||
released = new Date()
|
||||
vcsTag = project.version
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def skipUpload = project.path.contains("ktor-samples")
|
||||
if (!skipUpload) {
|
||||
apply from: rootProject.file("gradle/bintray.gradle")
|
||||
// TODO :kludge this is required for K/N publishing
|
||||
bintrayUpload.dependsOn publishToMavenLocal
|
||||
|
||||
// This is for easier debugging of bintray uploading problems
|
||||
bintrayUpload.doFirst {
|
||||
publications = project.publishing.publications.findAll { !it.name.contains('-test') }.collect {
|
||||
println("Uploading artifact '$it.groupId:$it.artifactId:$it.version' from publication '$it.name'")
|
||||
it
|
||||
}
|
||||
}
|
||||
|
||||
34
gradle/utility.gradle
Normal file
34
gradle/utility.gradle
Normal file
@@ -0,0 +1,34 @@
|
||||
project.ext.ideaActive = System.getProperty('idea.active') == 'true'
|
||||
|
||||
kotlin {
|
||||
targets {
|
||||
def manager = project.ext.hostManager
|
||||
def linuxEnabled = manager.isEnabled(presets.linuxX64.konanTarget)
|
||||
def macosEnabled = manager.isEnabled(presets.macosX64.konanTarget)
|
||||
def winEnabled = manager.isEnabled(presets.mingwX64.konanTarget)
|
||||
|
||||
project.ext.isLinuxHost = linuxEnabled
|
||||
project.ext.isMacosHost = macosEnabled
|
||||
project.ext.isWinHost = winEnabled
|
||||
|
||||
if (project.ext.ideaActive) {
|
||||
def ideaPreset = presets.linuxX64
|
||||
if (macosEnabled) ideaPreset = presets.macosX64
|
||||
if (winEnabled) ideaPreset = presets.mingwX64
|
||||
|
||||
project.ext.ideaPreset = ideaPreset
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def java_version = System.properties["java.version"]
|
||||
|
||||
switch (java_version) {
|
||||
case '1.8.0_191':
|
||||
case '1.8.0_192':
|
||||
project.ext.jetty_alpn_boot_version = "8.1.13.v20181017"
|
||||
break
|
||||
default:
|
||||
project.ext.jetty_alpn_boot_version = "8.1.12.v20180117"
|
||||
break
|
||||
}
|
||||
0
jvm/.gitkeep
Normal file
0
jvm/.gitkeep
Normal file
@@ -1,4 +1,3 @@
|
||||
|
||||
dependencies {
|
||||
compile project(':ktor-client:ktor-client-core')
|
||||
}
|
||||
kotlin.sourceSets.commonMain.dependencies {
|
||||
api project(':ktor-client:ktor-client-core')
|
||||
}
|
||||
|
||||
0
ktor-client/jvm/.gitkeep
Normal file
0
ktor-client/jvm/.gitkeep
Normal file
@@ -1,5 +1,9 @@
|
||||
dependencies {
|
||||
compile project(":ktor-client:ktor-client-core:ktor-client-core-jvm")
|
||||
|
||||
testCompile project(":ktor-client:ktor-client-tests")
|
||||
}
|
||||
kotlin.sourceSets {
|
||||
jvmMain.dependencies {
|
||||
api project(':ktor-client:ktor-client-core')
|
||||
}
|
||||
jvmTest.dependencies {
|
||||
api project(':ktor-client:ktor-client-tests')
|
||||
api project(':ktor-network:ktor-network-tls')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,11 +16,11 @@ import io.ktor.server.netty.*
|
||||
import io.ktor.util.*
|
||||
import kotlinx.coroutines.*
|
||||
import org.junit.*
|
||||
import org.junit.Test
|
||||
import java.io.*
|
||||
import java.security.*
|
||||
import javax.net.ssl.*
|
||||
import kotlin.test.*
|
||||
import kotlin.test.Test
|
||||
|
||||
class AndroidHttpsTest : TestWithKtor() {
|
||||
override val server: ApplicationEngine = embeddedServer(Netty, applicationEngineEnvironment {
|
||||
@@ -1,8 +1,11 @@
|
||||
description = "Apache backend for ktor http client"
|
||||
description = 'Apache backend for ktor http client'
|
||||
|
||||
dependencies {
|
||||
compile project(":ktor-client:ktor-client-core:ktor-client-core-jvm")
|
||||
compile group: "org.apache.httpcomponents", "name": "httpasyncclient", version: "4.1.3"
|
||||
|
||||
testCompile project(":ktor-client:ktor-client-tests")
|
||||
kotlin.sourceSets {
|
||||
jvmMain.dependencies {
|
||||
api project(':ktor-client:ktor-client-core')
|
||||
api group: 'org.apache.httpcomponents', name: 'httpasyncclient', version: '4.1.3'
|
||||
}
|
||||
jvmTest.dependencies {
|
||||
api project(':ktor-client:ktor-client-tests')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
description = "CIO backend for ktor http client"
|
||||
description = 'CIO backend for ktor http client'
|
||||
|
||||
dependencies {
|
||||
compile project(":ktor-client:ktor-client-core:ktor-client-core-jvm")
|
||||
compile project(":ktor-http:ktor-http-cio")
|
||||
compile project(":ktor-network:ktor-network-tls")
|
||||
|
||||
testCompile project(":ktor-client:ktor-client-tests")
|
||||
}
|
||||
kotlin.sourceSets {
|
||||
jvmMain.dependencies {
|
||||
api project(':ktor-client:ktor-client-core')
|
||||
api project(':ktor-http:ktor-http-cio')
|
||||
api project(':ktor-network:ktor-network-tls')
|
||||
}
|
||||
jvmTest.dependencies {
|
||||
api project(':ktor-client:ktor-client-tests')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import io.ktor.client.response.*
|
||||
import io.ktor.http.*
|
||||
import io.ktor.http.cio.*
|
||||
import io.ktor.util.date.*
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.io.*
|
||||
import kotlin.coroutines.*
|
||||
|
||||
@@ -93,7 +93,13 @@ internal class ConnectionPipeline(
|
||||
|
||||
responseChannel?.use {
|
||||
try {
|
||||
parseHttpBody(contentLength, transferEncoding, connectionType, networkInput, this)
|
||||
parseHttpBody(
|
||||
contentLength,
|
||||
transferEncoding,
|
||||
connectionType,
|
||||
networkInput,
|
||||
this
|
||||
)
|
||||
} finally {
|
||||
callContext[Job]?.invokeOnCompletion {
|
||||
rawResponse.release()
|
||||
@@ -1,8 +1,14 @@
|
||||
description = "Ktor http client"
|
||||
description = 'Ktor http client'
|
||||
|
||||
dependencies {
|
||||
compile project(":ktor-http")
|
||||
compile project(":ktor-utils")
|
||||
|
||||
testCompile project(":ktor-client:ktor-client-mock")
|
||||
kotlin.sourceSets {
|
||||
commonMain.dependencies {
|
||||
api project(':ktor-http')
|
||||
}
|
||||
jvmMain.dependencies {
|
||||
api project(':ktor-network')
|
||||
}
|
||||
jvmTest.dependencies {
|
||||
api project(':ktor-client:ktor-client-mock')
|
||||
api project(':ktor-client:ktor-client-tests')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ fun <T : HttpClientEngineConfig> HttpClient(
|
||||
@HttpClientDsl
|
||||
fun HttpClient(
|
||||
engine: HttpClientEngine,
|
||||
block: HttpClientConfig<*>.()->Unit
|
||||
block: HttpClientConfig<*>.() -> Unit
|
||||
): HttpClient = HttpClient(engine, HttpClientConfig<HttpClientEngineConfig>().apply(block))
|
||||
|
||||
/**
|
||||
@@ -13,7 +13,7 @@ class HttpClientConfig<T : HttpClientEngineConfig> {
|
||||
private val features = mutableMapOf<AttributeKey<*>, (HttpClient) -> Unit>()
|
||||
private val customInterceptors = mutableMapOf<String, (HttpClient) -> Unit>()
|
||||
|
||||
internal var engineConfig: T.()->Unit = {}
|
||||
internal var engineConfig: T.() -> Unit = {}
|
||||
|
||||
/**
|
||||
* Configure engine parameters.
|
||||
@@ -26,3 +26,15 @@ suspend fun HttpClient.call(
|
||||
url.takeFrom(urlString)
|
||||
block()
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a [HttpClientCall] from this [HttpClient],
|
||||
* an [url] and an optional [block] configuring a [HttpRequestBuilder].
|
||||
*/
|
||||
suspend fun HttpClient.call(
|
||||
url: Url,
|
||||
block: suspend HttpRequestBuilder.() -> Unit = {}
|
||||
): HttpClientCall = call {
|
||||
this.url.takeFrom(url)
|
||||
block()
|
||||
}
|
||||
@@ -44,7 +44,12 @@ class HttpPlainText(var defaultCharset: Charset) {
|
||||
scope.responsePipeline.intercept(HttpResponsePipeline.Parse) { (info, response) ->
|
||||
if (info.type != String::class || response !is HttpResponse) return@intercept
|
||||
|
||||
proceedWith(HttpResponseContainer(info, feature.read(response)))
|
||||
try {
|
||||
val content = feature.read(response)
|
||||
proceedWith(HttpResponseContainer(info, content))
|
||||
} finally {
|
||||
response.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,6 +53,9 @@ interface HttpRequest : HttpMessage, CoroutineScope {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Default [HttpRequest] implementation.
|
||||
*/
|
||||
open class DefaultHttpRequest(override val call: HttpClientCall, data: HttpRequestData) : HttpRequest {
|
||||
override val coroutineContext: CoroutineContext get() = call.coroutineContext
|
||||
|
||||
@@ -20,6 +20,28 @@ suspend inline fun <reified T> HttpClient.request(
|
||||
suspend inline fun <reified T> HttpClient.request(block: HttpRequestBuilder.() -> Unit): T =
|
||||
request(HttpRequestBuilder().apply(block))
|
||||
|
||||
/**
|
||||
* Executes a [HttpClient] request, with the [urlString] and the information configured in builder [block]
|
||||
* and tries to receive a specific type [T], if fails, an exception is thrown.
|
||||
*/
|
||||
suspend inline fun <reified T> HttpClient.request(
|
||||
urlString: String, block: HttpRequestBuilder.() -> Unit
|
||||
): T = request(HttpRequestBuilder().apply {
|
||||
url(urlString)
|
||||
block()
|
||||
})
|
||||
|
||||
/**
|
||||
* Executes a [HttpClient] request, with the [url] and the information configured in builder [block]
|
||||
* and tries to receive a specific type [T], if fails, an exception is thrown.
|
||||
*/
|
||||
suspend inline fun <reified T> HttpClient.request(
|
||||
url: Url, block: HttpRequestBuilder.() -> Unit
|
||||
): T = request(HttpRequestBuilder().apply {
|
||||
url(url)
|
||||
block()
|
||||
})
|
||||
|
||||
/**
|
||||
* Executes a [HttpClient] GET request, with the information from the [builder]
|
||||
* and tries to receive a specific type [T], if fails, an exception is thrown.
|
||||
@@ -0,0 +1,109 @@
|
||||
package io.ktor.client.request
|
||||
|
||||
import io.ktor.client.*
|
||||
import io.ktor.http.*
|
||||
|
||||
/**
|
||||
* Executes a [HttpClient] GET request, with the specified [url] as Url and
|
||||
* an optional [block] receiving an [HttpRequestBuilder] for further configuring the request.
|
||||
*
|
||||
* Tries to receive a specific type [T], if fails, an exception is thrown.
|
||||
*/
|
||||
suspend inline fun <reified T> HttpClient.get(
|
||||
url: Url,
|
||||
block: HttpRequestBuilder.() -> Unit = {}
|
||||
): T = get {
|
||||
this.url.takeFrom(url)
|
||||
block()
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a [HttpClient] POST request, with the specified [url] as Url and
|
||||
* an optional [block] receiving an [HttpRequestBuilder] for further configuring the request.
|
||||
*
|
||||
* Tries to receive a specific type [T], if fails, an exception is thrown.
|
||||
*/
|
||||
suspend inline fun <reified T> HttpClient.post(
|
||||
url: Url,
|
||||
block: HttpRequestBuilder.() -> Unit = {}
|
||||
): T = post {
|
||||
this.url.takeFrom(url)
|
||||
block()
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a [HttpClient] PUT request, with the specified [url] as Url and
|
||||
* an optional [block] receiving an [HttpRequestBuilder] for further configuring the request.
|
||||
*
|
||||
* Tries to receive a specific type [T], if fails, an exception is thrown.
|
||||
*/
|
||||
suspend inline fun <reified T> HttpClient.put(
|
||||
url: Url,
|
||||
block: HttpRequestBuilder.() -> Unit = {}
|
||||
): T = put {
|
||||
this.url.takeFrom(url)
|
||||
block()
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a [HttpClient] PATCH request, with the specified [url] as Url and
|
||||
* an optional [block] receiving an [HttpRequestBuilder] for further configuring the request.
|
||||
*
|
||||
* Tries to receive a specific type [T], if fails, an exception is thrown.
|
||||
*/
|
||||
suspend inline fun <reified T> HttpClient.patch(
|
||||
url: Url,
|
||||
block: HttpRequestBuilder.() -> Unit = {}
|
||||
): T = patch {
|
||||
this.url.takeFrom(url)
|
||||
block()
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a [HttpClient] OPTIONS request, with the specified [url] as Url and
|
||||
* an optional [block] receiving an [HttpRequestBuilder] for further configuring the request.
|
||||
*
|
||||
* Tries to receive a specific type [T], if fails, an exception is thrown.
|
||||
*/
|
||||
suspend inline fun <reified T> HttpClient.options(
|
||||
url: Url,
|
||||
block: HttpRequestBuilder.() -> Unit = {}
|
||||
): T = options {
|
||||
this.url.takeFrom(url)
|
||||
block()
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a [HttpClient] HEAD request, with the specified [url] as Url and
|
||||
* an optional [block] receiving an [HttpRequestBuilder] for further configuring the request.
|
||||
*
|
||||
* Tries to receive a specific type [T], if fails, an exception is thrown.
|
||||
*/
|
||||
suspend inline fun <reified T> HttpClient.head(
|
||||
url: Url,
|
||||
block: HttpRequestBuilder.() -> Unit = {}
|
||||
): T = head {
|
||||
this.url.takeFrom(url)
|
||||
block()
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a [HttpClient] HEAD request, with the specified [url] as Url and
|
||||
* an optional [block] receiving an [HttpRequestBuilder] for further configuring the request.
|
||||
*
|
||||
* Tries to receive a specific type [T], if fails, an exception is thrown.
|
||||
*/
|
||||
suspend inline fun <reified T> HttpClient.delete(
|
||||
url: Url,
|
||||
block: HttpRequestBuilder.() -> Unit = {}
|
||||
): T = delete {
|
||||
this.url.takeFrom(url)
|
||||
block()
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the [HttpRequestBuilder.url] from [url].
|
||||
*/
|
||||
fun HttpRequestBuilder.url(url: Url): Unit {
|
||||
this.url.takeFrom(url)
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user