Skip to content

Commit

Permalink
General cleanup (Kotlin#2809)
Browse files Browse the repository at this point in the history
* Suppress all deprecated signatures from the documentation
* Migrate inline classes to value
* Get rid of annoying Gradle output when tasks are configured
* Opt-in into delicate coroutines API
* Get rid of legacy jvm_ir_enabled that was used for pre-release testing of JVM IR compiler
* Update README references
  • Loading branch information
qwwdfsad committed Jul 8, 2021
1 parent c9ab4fd commit f5e8740
Show file tree
Hide file tree
Showing 36 changed files with 171 additions and 96 deletions.
17 changes: 2 additions & 15 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.jetbrains.dokka.gradle.DokkaTaskPartial
import org.jetbrains.dokka.gradle.DokkaMultiModuleTask

apply plugin: 'jdk-convention'
apply from: rootProject.file("gradle/experimental.gradle")
apply from: rootProject.file("gradle/opt-in.gradle")

def coreModule = "kotlinx-coroutines-core"
// Not applicable for Kotlin plugin
Expand All @@ -36,9 +36,6 @@ buildscript {
throw new IllegalArgumentException("'kotlin_snapshot_version' should be defined when building with snapshot compiler")
}
}
// These three flags are enabled in train builds for JVM IR compiler testing
ext.jvm_ir_enabled = rootProject.properties['enable_jvm_ir'] != null
ext.jvm_ir_api_check_enabled = rootProject.properties['enable_jvm_ir_api_check'] != null
ext.native_targets_enabled = rootProject.properties['disable_native_targets'] == null

// Determine if any project dependency is using a snapshot version
Expand Down Expand Up @@ -167,9 +164,8 @@ configure(subprojects.findAll { !sourceless.contains(it.name) }) {

// Configure options for all Kotlin compilation tasks
tasks.withType(org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile).all {
kotlinOptions.freeCompilerArgs += experimentalAnnotations.collect { "-Xuse-experimental=" + it }
kotlinOptions.freeCompilerArgs += optInAnnotations.collect { "-Xopt-in=" + it }
kotlinOptions.freeCompilerArgs += "-progressive"
kotlinOptions.freeCompilerArgs += "-XXLanguage:+InlineClasses"
// Disable KT-36770 for RxJava2 integration
kotlinOptions.freeCompilerArgs += "-XXLanguage:-ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated"
// Remove null assertions to get smaller bytecode on Android
Expand Down Expand Up @@ -289,15 +285,6 @@ dependencies {
dokkaHtmlMultiModulePlugin("org.jetbrains.kotlinx:dokka-pathsaver-plugin:$knit_version")
}

// Disable binary compatibility check for JVM IR compiler output by default
if (jvm_ir_enabled) {
subprojects { project ->
configure(tasks.matching { it.name == "apiCheck" }) {
enabled = enabled && jvm_ir_api_check_enabled
}
}
}

// Opt-in for build scan in order to troubleshoot Gradle on TC
if (hasProperty('buildScan')) {
buildScan {
Expand Down
4 changes: 0 additions & 4 deletions buildSrc/src/main/kotlin/Publishing.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,8 @@ fun MavenPom.configureMavenCentralMetadata(project: Project) {
}

fun mavenRepositoryUri(): URI {
// TODO -SNAPSHOT detection can be made here as well
val repositoryId: String? = System.getenv("libs.repository.id")
return if (repositoryId == null) {
// Using implicitly created staging, for MPP it's likely to be a mistake because
// publication on TeamCity will create 3 independent staging repositories
System.err.println("Warning: using an implicitly created staging for coroutines")
URI("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
} else {
URI("https://oss.sonatype.org/service/local/staging/deployByRepositoryId/$repositoryId")
Expand Down
6 changes: 0 additions & 6 deletions buildSrc/src/main/kotlin/kotlin-jvm-conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ java {
targetCompatibility = JavaVersion.VERSION_1_6
}

if (rootProject.extra.get("jvm_ir_enabled") as Boolean) {
kotlin.target.compilations.configureEach {
kotlinOptions.useIR = true
}
}

dependencies {
testImplementation(kotlin("test"))
// Workaround to make addSuppressed work in tests
Expand Down
8 changes: 1 addition & 7 deletions gradle/compile-jvm-multiplatform.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@ sourceCompatibility = 1.6
targetCompatibility = 1.6

kotlin {
jvm {
if (rootProject.ext.jvm_ir_enabled) {
compilations.all {
kotlinOptions.useIR = true
}
}
}
jvm {}
sourceSets {
jvmTest.dependencies {
api "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
Expand Down
5 changes: 2 additions & 3 deletions gradle/experimental.gradle → gradle/opt-in.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
* Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

// For new mpp
ext.experimentalAnnotations = [
"kotlin.Experimental",
ext.optInAnnotations = [
"kotlin.experimental.ExperimentalTypeInference",
"kotlin.ExperimentalMultiplatform",
"kotlinx.coroutines.DelicateCoroutinesApi",
"kotlinx.coroutines.ExperimentalCoroutinesApi",
"kotlinx.coroutines.ObsoleteCoroutinesApi",
"kotlinx.coroutines.InternalCoroutinesApi",
Expand Down
8 changes: 1 addition & 7 deletions kotlinx-coroutines-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ kotlin {
}
languageSettings {
progressiveMode = true
experimentalAnnotations.each { useExperimentalAnnotation(it) }
optInAnnotations.each { useExperimentalAnnotation(it) }
}
}

Expand Down Expand Up @@ -201,12 +201,6 @@ jvmTest {
// Configure the IDEA runner for Lincheck
configureJvmForLincheck(jvmTest)
}
// TODO: JVM IR generates different stacktrace so temporary disable stacktrace tests
if (rootProject.ext.jvm_ir_enabled) {
filter {
excludeTestsMatching('kotlinx.coroutines.exceptions.StackTraceRecovery*')
}
}
}

// Setup manifest for kotlinx-coroutines-core-jvm.jar
Expand Down
10 changes: 5 additions & 5 deletions kotlinx-coroutines-core/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ helper function. [NonCancellable] job object is provided to suppress cancellatio
| ---------------- | --------------------------------------------- | ------------------------------------------------ | --------------------------
| [Job] | [join][Job.join] | [onJoin][Job.onJoin] | [isCompleted][Job.isCompleted]
| [Deferred] | [await][Deferred.await] | [onAwait][Deferred.onAwait] | [isCompleted][Job.isCompleted]
| [SendChannel][kotlinx.coroutines.channels.SendChannel] | [send][kotlinx.coroutines.channels.SendChannel.send] | [onSend][kotlinx.coroutines.channels.SendChannel.onSend] | [offer][kotlinx.coroutines.channels.SendChannel.offer]
| [ReceiveChannel][kotlinx.coroutines.channels.ReceiveChannel] | [receive][kotlinx.coroutines.channels.ReceiveChannel.receive] | [onReceive][kotlinx.coroutines.channels.ReceiveChannel.onReceive] | [poll][kotlinx.coroutines.channels.ReceiveChannel.poll]
| [ReceiveChannel][kotlinx.coroutines.channels.ReceiveChannel] | [receiveCatching][kotlinx.coroutines.channels.ReceiveChannel.receiveCatching] | [onReceiveCatching][kotlinx.coroutines.channels.ReceiveChannel.onReceiveCatching] | [poll][kotlinx.coroutines.channels.ReceiveChannel.poll]
| [SendChannel][kotlinx.coroutines.channels.SendChannel] | [send][kotlinx.coroutines.channels.SendChannel.send] | [onSend][kotlinx.coroutines.channels.SendChannel.onSend] | [trySend][kotlinx.coroutines.channels.SendChannel.trySend]
| [ReceiveChannel][kotlinx.coroutines.channels.ReceiveChannel] | [receive][kotlinx.coroutines.channels.ReceiveChannel.receive] | [onReceive][kotlinx.coroutines.channels.ReceiveChannel.onReceive] | [tryReceive][kotlinx.coroutines.channels.ReceiveChannel.tryReceive]
| [ReceiveChannel][kotlinx.coroutines.channels.ReceiveChannel] | [receiveCatching][kotlinx.coroutines.channels.ReceiveChannel.receiveCatching] | [onReceiveCatching][kotlinx.coroutines.channels.ReceiveChannel.onReceiveCatching] | [tryReceive][kotlinx.coroutines.channels.ReceiveChannel.tryReceive]
| [Mutex][kotlinx.coroutines.sync.Mutex] | [lock][kotlinx.coroutines.sync.Mutex.lock] | [onLock][kotlinx.coroutines.sync.Mutex.onLock] | [tryLock][kotlinx.coroutines.sync.Mutex.tryLock]
| none | [delay] | [onTimeout][kotlinx.coroutines.selects.SelectBuilder.onTimeout] | none

Expand Down Expand Up @@ -146,9 +146,9 @@ Low-level primitives for finer-grained control of coroutines.
[kotlinx.coroutines.channels.SendChannel.send]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.channels/-send-channel/send.html
[kotlinx.coroutines.channels.ReceiveChannel.receive]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.channels/-receive-channel/receive.html
[kotlinx.coroutines.channels.SendChannel.onSend]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.channels/-send-channel/on-send.html
[kotlinx.coroutines.channels.SendChannel.offer]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.channels/-send-channel/offer.html
[kotlinx.coroutines.channels.SendChannel.trySend]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.channels/-send-channel/try-send.html
[kotlinx.coroutines.channels.ReceiveChannel.onReceive]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.channels/-receive-channel/on-receive.html
[kotlinx.coroutines.channels.ReceiveChannel.poll]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.channels/-receive-channel/poll.html
[kotlinx.coroutines.channels.ReceiveChannel.tryReceive]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.channels/-receive-channel/try-receive.html
[kotlinx.coroutines.channels.ReceiveChannel.receiveCatching]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.channels/-receive-channel/receive-catching.html
[kotlinx.coroutines.channels.ReceiveChannel.onReceiveCatching]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.channels/-receive-channel/on-receive-catching.html

Expand Down
6 changes: 6 additions & 0 deletions kotlinx-coroutines-core/common/src/channels/Channel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ public interface SendChannel<in E> {
* ```
*
* See https://github.com/Kotlin/kotlinx.coroutines/issues/974 for more context.
*
* @suppress **Deprecated**.
*/
@Deprecated(
level = DeprecationLevel.WARNING,
Expand Down Expand Up @@ -308,6 +310,8 @@ public interface ReceiveChannel<out E> {
* The replacement `tryReceive().getOrNull()` is a default that ignores all close exceptions and
* proceeds with `null`, while `poll` throws an exception if the channel was closed with an exception.
* Replacement with the very same 'poll' semantics is `tryReceive().onClosed { if (it != null) throw it }.getOrNull()`
*
* @suppress **Deprecated**.
*/
@Deprecated(
level = DeprecationLevel.WARNING,
Expand Down Expand Up @@ -336,6 +340,8 @@ public interface ReceiveChannel<out E> {
* The replacement `receiveCatching().getOrNull()` is a safe default that ignores all close exceptions and
* proceeds with `null`, while `receiveOrNull` throws an exception if the channel was closed with an exception.
* Replacement with the very same `receiveOrNull` semantics is `receiveCatching().onClosed { if (it != null) throw it }.getOrNull()`.
*
* @suppress **Deprecated**
*/
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
@LowPriorityInOverloadResolution
Expand Down
Loading

0 comments on commit f5e8740

Please sign in to comment.