forked from Kotlin/kotlinx.coroutines
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce animalsniffer checks to coroutines and compile against Java… (
Kotlin#2963) * Introduce animalsniffer checks to coroutines and compile against Java 8 source and binary target, but still avoiding Java 7+ API * Do not use deprecated target, language desugaring will handle default interface methods and Math/Long/Int static methods * Partially migrate to .gradle.kts Fixes Kotlin#1589
- Loading branch information
1 parent
eb9a33c
commit f223698
Showing
14 changed files
with
93 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
buildSrc/src/main/kotlin/animalsniffer-convention.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
import ru.vyarus.gradle.plugin.animalsniffer.* | ||
|
||
subprojects { | ||
// Skip JDK 8 projects or unpublished ones | ||
if (!shouldSniff()) return@subprojects | ||
apply(plugin = "ru.vyarus.animalsniffer") | ||
configure<AnimalSnifferExtension> { | ||
sourceSets = listOf((project.extensions.getByName("sourceSets") as SourceSetContainer).getByName("main")) | ||
} | ||
val signature: Configuration by configurations | ||
dependencies { | ||
signature("net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature") | ||
signature("org.codehaus.mojo.signature:java17:1.0@signature") | ||
} | ||
} | ||
|
||
fun Project.shouldSniff(): Boolean { | ||
// Skip all non-JVM projects | ||
if (platformOf(project) != "jvm") return false | ||
val name = project.name | ||
if (name in unpublished || name in sourceless || name in androidNonCompatibleProjects) return false | ||
return true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,6 +90,11 @@ kotlin { | |
} | ||
} | ||
} | ||
|
||
jvm { | ||
// For animal sniffer | ||
withJava() | ||
} | ||
} | ||
|
||
configurations { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
kotlinx-coroutines-core/common/src/internal/InternalAnnotations.common.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
* Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
package kotlinx.coroutines.internal | ||
|
||
// Ignore JRE requirements for animal-sniffer, compileOnly dependency | ||
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.TYPE) | ||
@OptionalExpectation | ||
internal expect annotation class IgnoreJreRequirement() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
kotlinx-coroutines-core/jvm/src/internal/InternalAnnotations.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
* Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
package kotlinx.coroutines.internal | ||
|
||
@Suppress("ACTUAL_WITHOUT_EXPECT") // Not the same name to WA the bug in the compiler | ||
internal actual typealias IgnoreJreRequirement = org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement |