diff --git a/README.md b/README.md index d82b78639a..e675caef6e 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,11 @@ [![JetBrains official project](https://jb.gg/badges/official.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub) [![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](https://www.apache.org/licenses/LICENSE-2.0) [![Download](https://img.shields.io/maven-central/v/org.jetbrains.kotlinx/kotlinx-coroutines-core/1.7.2)](https://central.sonatype.com/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core/1.7.2) -[![Kotlin](https://img.shields.io/badge/kotlin-1.8.20-blue.svg?logo=kotlin)](http://kotlinlang.org) +[![Kotlin](https://img.shields.io/badge/kotlin-1.9.0-blue.svg?logo=kotlin)](http://kotlinlang.org) [![Slack channel](https://img.shields.io/badge/chat-slack-green.svg?logo=slack)](https://kotlinlang.slack.com/messages/coroutines/) Library support for Kotlin coroutines with [multiplatform](#multiplatform) support. -This is a companion version for the Kotlin `1.8.20` release. +This is a companion version for the Kotlin `1.9.0` release. ```kotlin suspend fun main() = coroutineScope { @@ -93,7 +93,7 @@ And make sure that you use the latest Kotlin version: ```xml - 1.8.20 + 1.9.0 ``` @@ -112,10 +112,10 @@ And make sure that you use the latest Kotlin version: ```kotlin plugins { // For build.gradle.kts (Kotlin DSL) - kotlin("jvm") version "1.8.20" + kotlin("jvm") version "1.9.0" // For build.gradle (Groovy DSL) - id "org.jetbrains.kotlin.jvm" version "1.8.20" + id "org.jetbrains.kotlin.jvm" version "1.9.0" } ``` diff --git a/build.gradle b/build.gradle index e7d405e124..0e7ee1d471 100644 --- a/build.gradle +++ b/build.gradle @@ -63,7 +63,6 @@ buildscript { classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version" classpath "org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicfu_version" classpath "org.jetbrains.kotlinx:kotlinx-knit:$knit_version" - classpath "com.github.node-gradle:gradle-node-plugin:$gradle_node_version" classpath "org.jetbrains.kotlinx:binary-compatibility-validator:$binary_compatibility_validator_version" classpath "ru.vyarus:gradle-animalsniffer-plugin:1.5.4" // Android API check classpath "org.jetbrains.kotlin:atomicfu:$kotlin_version" @@ -161,7 +160,6 @@ configure(subprojects.findAll { !sourceless.contains(it.name) && it.name != core } apply from: rootProject.file("gradle/compile-js-multiplatform.gradle") - apply from: rootProject.file("gradle/publish-npm-js.gradle") kotlin.sourceSets.commonMain.dependencies { api project(":$coreModule") } @@ -303,7 +301,7 @@ allprojects { // --------------- Configure sub-projects that are published --------------- -def publishTasks = getTasksByName("publish", true) + getTasksByName("publishNpm", true) +def publishTasks = getTasksByName("publish", true) task deploy(dependsOn: publishTasks) diff --git a/buildSrc/src/main/kotlin/configure-compilation-conventions.gradle.kts b/buildSrc/src/main/kotlin/configure-compilation-conventions.gradle.kts index 9e22b4515c..a891cf0ec2 100644 --- a/buildSrc/src/main/kotlin/configure-compilation-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/configure-compilation-conventions.gradle.kts @@ -28,4 +28,4 @@ configure(subprojects) { } val KotlinCommonOptions.versionsAreNotOverridden: Boolean - get() = languageVersion == null && apiVersion == null \ No newline at end of file + get() = languageVersion == null && apiVersion == null diff --git a/buildSrc/src/main/kotlin/kotlin-js-conventions.gradle.kts b/buildSrc/src/main/kotlin/kotlin-js-conventions.gradle.kts index c1897ca749..f8c7ccab8d 100644 --- a/buildSrc/src/main/kotlin/kotlin-js-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/kotlin-js-conventions.gradle.kts @@ -5,6 +5,7 @@ // Platform-specific configuration to compile JS modules import org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile +import org.jetbrains.kotlin.gradle.targets.js.* plugins { kotlin("js") @@ -15,7 +16,7 @@ dependencies { } kotlin { - js(LEGACY) { + js(IR) { moduleName = project.name.removeSuffix("-js") } diff --git a/gradle.properties b/gradle.properties index d558080072..914291afcf 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ # Kotlin version=1.7.2-SNAPSHOT group=org.jetbrains.kotlinx -kotlin_version=1.8.20 +kotlin_version=1.9.0 # Dependencies junit_version=4.12 @@ -33,18 +33,6 @@ androidx_annotation_version=1.1.0 robolectric_version=4.9 baksmali_version=2.2.7 -# JS -kotlin.js.compiler=both -gradle_node_version=3.1.1 -node_version=10.0.0 -npm_version=5.7.1 -mocha_version=6.2.2 -mocha_headless_chrome_version=1.8.2 -mocha_teamcity_reporter_version=3.0.0 -source_map_support_version=0.5.16 -jsdom_version=15.2.1 -jsdom_global_version=3.0.2 - # Settings kotlin.incremental.multiplatform=true kotlin.native.ignoreDisabledTargets=true diff --git a/gradle/compile-js-multiplatform.gradle b/gradle/compile-js-multiplatform.gradle index c6fc757c7d..4200972cea 100644 --- a/gradle/compile-js-multiplatform.gradle +++ b/gradle/compile-js-multiplatform.gradle @@ -2,21 +2,12 @@ * Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -apply from: rootProject.file('gradle/node-js.gradle') - kotlin { js { moduleName = project.name - - // In 1.4.x it has in `both` and `legacy` mode and js() is of type `KotlinJsTarget` - // `irTarget` is non-null in `both` mode - // and contains appropriate `irTarget` with type `KotlinJsIrTarget` - // `irTarget` is null in `legacy` mode - if (it.irTarget != null) { - irTarget.nodejs() - irTarget.compilations['main']?.dependencies { - api "org.jetbrains.kotlinx:atomicfu-js:$atomicfu_version" - } + nodejs() + compilations['main']?.dependencies { + api "org.jetbrains.kotlinx:atomicfu-js:$atomicfu_version" } } @@ -26,55 +17,3 @@ kotlin { } } } - -// When source sets are configured -apply from: rootProject.file('gradle/test-mocha-js.gradle') - -def compileJsLegacy = tasks.hasProperty("compileKotlinJsLegacy") - ? compileKotlinJsLegacy - : compileKotlinJs - -def compileTestJsLegacy = tasks.hasProperty("compileTestKotlinJsLegacy") - ? compileTestKotlinJsLegacy - : compileTestKotlinJs - -compileJsLegacy.configure { - kotlinOptions.metaInfo = true - kotlinOptions.sourceMap = true - kotlinOptions.moduleKind = 'umd' - - kotlinOptions { - // drop -js suffix from outputFile - def baseName = project.name - "-js" - outputFile = new File(outputFileProperty.get().parent, baseName + ".js") - } -} - -compileTestJsLegacy.configure { - kotlinOptions.metaInfo = true - kotlinOptions.sourceMap = true - kotlinOptions.moduleKind = 'umd' -} - - -task populateNodeModules(type: Copy, dependsOn: compileTestJsLegacy) { - // we must copy output that is transformed by atomicfu - from(kotlin.js().compilations.main.output.allOutputs) - into node.nodeProjectDir.dir("node_modules") - - def configuration = configurations.hasProperty("jsLegacyTestRuntimeClasspath") - ? configurations.jsLegacyTestRuntimeClasspath - : configurations.jsTestRuntimeClasspath - - from(files { - configuration.collect { File file -> - file.name.endsWith(".jar") ? - zipTree(file.absolutePath).matching { - include '*.js' - include '*.js.map' - } : files() - } - }.builtBy(configuration)) -} - -npmInstall.dependsOn populateNodeModules diff --git a/gradle/node-js.gradle b/gradle/node-js.gradle deleted file mode 100644 index 5eddc5fa37..0000000000 --- a/gradle/node-js.gradle +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -apply plugin: 'com.github.node-gradle.node' - -node { - version = "$node_version" - npmVersion = "$npm_version" - download = true - nodeProjectDir = file(buildDir) -} - -// Configures testing for JS modules - -task prepareNodePackage(type: Copy) { - from("npm") { - include 'package.json' - // Postpone expansion of package.json until we configure version property in build.gradle - def copySpec = it - afterEvaluate { - copySpec.expand(project.properties + [kotlinDependency: ""]) - } - } - from("npm") { - exclude 'package.json' - } - into node.nodeProjectDir -} - -npmInstall.dependsOn prepareNodePackage - -// Workaround the problem with Node downloading -repositories.whenObjectAdded { - if (it instanceof IvyArtifactRepository) { - metadataSources { - artifact() - } - } -} diff --git a/gradle/publish-npm-js.gradle b/gradle/publish-npm-js.gradle deleted file mode 100644 index 9d4152770c..0000000000 --- a/gradle/publish-npm-js.gradle +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -def prop(name, defVal) { - def value = project.properties[name] - if (value == null) return defVal - return value -} - -def distTag(version) { - def i = version.indexOf('-') - if (i > 0) return version.substring(i + 1) - return "latest" -} - -def npmTemplateDir = file("$projectDir/npm") -def npmDeployDir = file("$buildDir/npm") - -def authToken = prop("kotlin.npmjs.auth.token", "") -def dryRun = prop("dryRun", "false") - -def jsLegacy = kotlin.targets.hasProperty("jsLegacy") - ? kotlin.targets.jsLegacy - : kotlin.targets.js - -// Note: publish transformed files using dependency on sourceSets.main.output -task preparePublishNpm(type: Copy) { - from(npmTemplateDir) { - // Postpone expansion of package.json until we configure version property in build.gradle - def copySpec = it - afterEvaluate { - copySpec.expand(project.properties + [kotlinDependency: "\"kotlin\": \"$kotlin_version\""]) - } - } - // we must publish output that is transformed by atomicfu - from(jsLegacy.compilations.main.output.allOutputs) - into npmDeployDir -} - -task publishNpm(type: NpmTask, dependsOn: [preparePublishNpm]) { - workingDir = npmDeployDir - - def npmDeployTag = distTag(version) - def deployArgs = ['publish', - "--//registry.npmjs.org/:_authToken=$authToken", - "--tag=$npmDeployTag"] - if (dryRun == "true") { - println("$npmDeployDir \$ npm arguments: $deployArgs") - args = ['pack'] - } else { - args = deployArgs - } -} diff --git a/gradle/test-mocha-js.gradle b/gradle/test-mocha-js.gradle deleted file mode 100644 index 1ec297e415..0000000000 --- a/gradle/test-mocha-js.gradle +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -// -- Testing with Mocha under Node - -task installDependenciesMochaNode(type: NpmTask, dependsOn: [npmInstall]) { - args = ['install', - "mocha@$mocha_version", - "source-map-support@$source_map_support_version", - '--no-save'] - if (project.hasProperty("teamcity")) args.addAll(["mocha-teamcity-reporter@$mocha_teamcity_reporter_version"]) -} - -def compileJsLegacy = tasks.hasProperty("compileKotlinJsLegacy") - ? compileKotlinJsLegacy - : compileKotlinJs - -def compileTestJsLegacy = tasks.hasProperty("compileTestKotlinJsLegacy") - ? compileTestKotlinJsLegacy - : compileTestKotlinJs - -// todo: use atomicfu-transformed test files here (not critical) -task testMochaNode(type: NodeTask, dependsOn: [compileTestJsLegacy, installDependenciesMochaNode]) { - script = file("${node.nodeProjectDir.getAsFile().get()}/node_modules/mocha/bin/mocha") - args = [compileTestJsLegacy.outputFileProperty.get().path, '--require', 'source-map-support/register'] - if (project.hasProperty("teamcity")) args.addAll(['--reporter', 'mocha-teamcity-reporter']) -} - -def jsLegacyTestTask = project.tasks.findByName('jsLegacyTest') ? jsLegacyTest : jsTest - -// TODO -//jsLegacyTestTask.dependsOn testMochaNode - -// -- Testing with Mocha under headless Chrome - -task installDependenciesMochaChrome(type: NpmTask, dependsOn: [npmInstall]) { - args = ['install', - "mocha@$mocha_version", - "mocha-headless-chrome@$mocha_headless_chrome_version", - "kotlin@$kotlin_version", - "kotlin-test@$kotlin_version", - '--no-save'] - if (project.hasProperty("teamcity")) args.addAll([ - "mocha-teamcity-reporter@$mocha_teamcity_reporter_version"]) -} - -def mochaChromeTestPage = file("$buildDir/test-page.html") - -task prepareMochaChrome(dependsOn: [compileTestJsLegacy, installDependenciesMochaChrome]) { - outputs.file(mochaChromeTestPage) -} - -prepareMochaChrome.doLast { - def nodeProjDir = node.nodeProjectDir.getAsFile().get() - mochaChromeTestPage.text = """ - - - Mocha Tests - - - - -
- - - - - - - - - - """ -} - -task testMochaChrome(type: NodeTask, dependsOn: prepareMochaChrome) { - script = file("${node.nodeProjectDir.getAsFile().get()}/node_modules/mocha-headless-chrome/bin/start") - args = [compileTestJsLegacy.outputFileProperty.get().path, '--file', mochaChromeTestPage] - if (project.hasProperty("teamcity")) args.addAll(['--reporter', 'mocha-teamcity-reporter']) -} - -// todo: Commented out because mocha-headless-chrome does not work on TeamCity -//jsTest.dependsOn testMochaChrome - -// -- Testing with Mocha under jsdom - -task installDependenciesMochaJsdom(type: NpmTask, dependsOn: [npmInstall]) { - args = ['install', - "mocha@$mocha_version", - "jsdom@$jsdom_version", - "jsdom-global@$jsdom_global_version", - "source-map-support@$source_map_support_version", - '--no-save'] - if (project.hasProperty("teamcity")) args.addAll(["mocha-teamcity-reporter@$mocha_teamcity_reporter_version"]) -} - -task testMochaJsdom(type: NodeTask, dependsOn: [compileTestJsLegacy, installDependenciesMochaJsdom]) { - script = file("${node.nodeProjectDir.getAsFile().get()}/node_modules/mocha/bin/mocha") - args = [compileTestJsLegacy.outputFileProperty.get().path, '--require', 'source-map-support/register', '--require', 'jsdom-global/register'] - if (project.hasProperty("teamcity")) args.addAll(['--reporter', 'mocha-teamcity-reporter']) -} - -// TODO -//jsLegacyTestTask.dependsOn testMochaJsdom diff --git a/integration-testing/gradle.properties b/integration-testing/gradle.properties index 30b2b5ed62..59811645d7 100644 --- a/integration-testing/gradle.properties +++ b/integration-testing/gradle.properties @@ -1,4 +1,4 @@ -kotlin_version=1.8.20 +kotlin_version=1.9.0 coroutines_version=1.7.2-SNAPSHOT asm_version=9.3 diff --git a/js/example-frontend-js/build.gradle.kts b/js/example-frontend-js/build.gradle.kts index 1cc587b740..ec718a28ad 100644 --- a/js/example-frontend-js/build.gradle.kts +++ b/js/example-frontend-js/build.gradle.kts @@ -3,22 +3,22 @@ */ kotlin { - js(LEGACY) { + js(IR) { binaries.executable() browser { - distribution { - directory = directory.parentFile.resolve("dist") - } - commonWebpackConfig { + distribution(Action { + outputDirectory.set(outputDirectory.get().asFile.parentFile.resolve("dist")) + }) + commonWebpackConfig(Action { cssSupport { enabled.set(true) } - } - testTask { + }) + testTask(Action { useKarma { useChromeHeadless() } - } + }) } } } diff --git a/kotlinx-coroutines-core/api/kotlinx-coroutines-core.api b/kotlinx-coroutines-core/api/kotlinx-coroutines-core.api index 9b548ac49f..1468d6803d 100644 --- a/kotlinx-coroutines-core/api/kotlinx-coroutines-core.api +++ b/kotlinx-coroutines-core/api/kotlinx-coroutines-core.api @@ -264,6 +264,7 @@ public final class kotlinx/coroutines/CoroutineStart : java/lang/Enum { public static final field DEFAULT Lkotlinx/coroutines/CoroutineStart; public static final field LAZY Lkotlinx/coroutines/CoroutineStart; public static final field UNDISPATCHED Lkotlinx/coroutines/CoroutineStart; + public static fun getEntries ()Lkotlin/enums/EnumEntries; public final fun invoke (Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)V public final fun invoke (Lkotlin/jvm/functions/Function2;Ljava/lang/Object;Lkotlin/coroutines/Continuation;)V public final fun isLazy ()Z @@ -667,6 +668,7 @@ public final class kotlinx/coroutines/channels/BufferOverflow : java/lang/Enum { public static final field DROP_LATEST Lkotlinx/coroutines/channels/BufferOverflow; public static final field DROP_OLDEST Lkotlinx/coroutines/channels/BufferOverflow; public static final field SUSPEND Lkotlinx/coroutines/channels/BufferOverflow; + public static fun getEntries ()Lkotlin/enums/EnumEntries; public static fun valueOf (Ljava/lang/String;)Lkotlinx/coroutines/channels/BufferOverflow; public static fun values ()[Lkotlinx/coroutines/channels/BufferOverflow; } @@ -907,6 +909,7 @@ public final class kotlinx/coroutines/channels/TickerChannelsKt { public final class kotlinx/coroutines/channels/TickerMode : java/lang/Enum { public static final field FIXED_DELAY Lkotlinx/coroutines/channels/TickerMode; public static final field FIXED_PERIOD Lkotlinx/coroutines/channels/TickerMode; + public static fun getEntries ()Lkotlin/enums/EnumEntries; public static fun valueOf (Ljava/lang/String;)Lkotlinx/coroutines/channels/TickerMode; public static fun values ()[Lkotlinx/coroutines/channels/TickerMode; } @@ -1178,6 +1181,7 @@ public final class kotlinx/coroutines/flow/SharingCommand : java/lang/Enum { public static final field START Lkotlinx/coroutines/flow/SharingCommand; public static final field STOP Lkotlinx/coroutines/flow/SharingCommand; public static final field STOP_AND_RESET_REPLAY_CACHE Lkotlinx/coroutines/flow/SharingCommand; + public static fun getEntries ()Lkotlin/enums/EnumEntries; public static fun valueOf (Ljava/lang/String;)Lkotlinx/coroutines/flow/SharingCommand; public static fun values ()[Lkotlinx/coroutines/flow/SharingCommand; } diff --git a/kotlinx-coroutines-core/build.gradle b/kotlinx-coroutines-core/build.gradle index 6b0d6c2c09..7724d190af 100644 --- a/kotlinx-coroutines-core/build.gradle +++ b/kotlinx-coroutines-core/build.gradle @@ -16,7 +16,6 @@ if (rootProject.ext.native_targets_enabled) { } apply from: rootProject.file("gradle/compile-js-multiplatform.gradle") -apply from: rootProject.file('gradle/publish-npm-js.gradle') apply from: rootProject.file('gradle/dokka.gradle.kts') apply from: rootProject.file('gradle/publish.gradle') diff --git a/kotlinx-coroutines-core/jvm/resources/DebugProbesKt.bin b/kotlinx-coroutines-core/jvm/resources/DebugProbesKt.bin index 9d171f3a7a..950dcf45be 100644 Binary files a/kotlinx-coroutines-core/jvm/resources/DebugProbesKt.bin and b/kotlinx-coroutines-core/jvm/resources/DebugProbesKt.bin differ diff --git a/kotlinx-coroutines-debug/api/kotlinx-coroutines-debug.api b/kotlinx-coroutines-debug/api/kotlinx-coroutines-debug.api index b671b1a488..11131fad42 100644 --- a/kotlinx-coroutines-debug/api/kotlinx-coroutines-debug.api +++ b/kotlinx-coroutines-debug/api/kotlinx-coroutines-debug.api @@ -39,6 +39,7 @@ public final class kotlinx/coroutines/debug/State : java/lang/Enum { public static final field CREATED Lkotlinx/coroutines/debug/State; public static final field RUNNING Lkotlinx/coroutines/debug/State; public static final field SUSPENDED Lkotlinx/coroutines/debug/State; + public static fun getEntries ()Lkotlin/enums/EnumEntries; public static fun valueOf (Ljava/lang/String;)Lkotlinx/coroutines/debug/State; public static fun values ()[Lkotlinx/coroutines/debug/State; }