[Gradle] Fixup assertions
KT-55189
This commit is contained in:
committed by
Space Team
parent
61c2c0680f
commit
02ec4cb1b5
+9
@@ -49,3 +49,12 @@ internal inline fun <reified T : Any> Any.findExtension(name: String): T? =
|
||||
|
||||
inline val Any.extraProperties: ExtraPropertiesExtension
|
||||
get() = (this as ExtensionAware).extensions.extraProperties
|
||||
|
||||
@JvmName("getOrNullTyped")
|
||||
internal inline fun <reified T : Any> ExtraPropertiesExtension.getOrNull(name: String): T? {
|
||||
return if (has(name)) get(name) as T else null
|
||||
}
|
||||
|
||||
internal fun ExtraPropertiesExtension.getOrNull(name: String): Any? {
|
||||
return if (has(name)) get(name) else null
|
||||
}
|
||||
|
||||
+3
-1
@@ -7,6 +7,8 @@ package org.jetbrains.kotlin.gradle.plugin.ide
|
||||
|
||||
import org.jetbrains.kotlin.gradle.idea.tcs.IdeaKotlinDependency
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
|
||||
import org.jetbrains.kotlin.gradle.plugin.extraProperties
|
||||
import org.jetbrains.kotlin.gradle.plugin.getOrNull
|
||||
import org.jetbrains.kotlin.gradle.plugin.sources.project
|
||||
|
||||
internal object IdeDependencyLogger : IdeDependencyEffect {
|
||||
@@ -14,7 +16,7 @@ internal object IdeDependencyLogger : IdeDependencyEffect {
|
||||
private const val propertyKey = "IdeDependencyLogger.log"
|
||||
|
||||
override fun invoke(sourceSet: KotlinSourceSet, dependencies: Set<IdeaKotlinDependency>) {
|
||||
val log = sourceSet.project.properties[propertyKey]?.toString() ?: return
|
||||
val log = sourceSet.project.extraProperties.getOrNull(propertyKey)?.toString() ?: return
|
||||
val coordinates = IdeaKotlinSourceCoordinates(sourceSet)
|
||||
if (log.isEmpty() || Regex(log).matches(coordinates.toString())) {
|
||||
IdeMultiplatformImport.logger.quiet(
|
||||
|
||||
+6
-4
@@ -14,6 +14,8 @@ import org.jetbrains.kotlin.gradle.idea.testFixtures.tcs.assertMatches
|
||||
import org.jetbrains.kotlin.gradle.idea.testFixtures.tcs.binaryCoordinates
|
||||
import org.jetbrains.kotlin.gradle.plugin.ide.dependencyResolvers.IdeNativePlatformDependencyResolver
|
||||
import org.jetbrains.kotlin.konan.target.HostManager
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget.LINUX_X64
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget.MACOS_ARM64
|
||||
import org.junit.Assume
|
||||
import kotlin.test.Test
|
||||
|
||||
@@ -31,8 +33,8 @@ class IdeNativePlatformDependencyResolverTest {
|
||||
val linuxX64Test = kotlin.sourceSets.getByName("linuxX64Test")
|
||||
|
||||
val dependencies = listOf(
|
||||
binaryCoordinates("org.jetbrains.kotlin.native:platform.posix:${project.konanVersion}"),
|
||||
binaryCoordinates(Regex("""org\.jetbrains\.kotlin\.native:.*:${project.konanVersion}"""))
|
||||
binaryCoordinates("org.jetbrains.kotlin.native:platform.posix:${project.konanVersion}:$LINUX_X64"),
|
||||
binaryCoordinates(Regex("""org\.jetbrains\.kotlin\.native:.*:${project.konanVersion}:$LINUX_X64"""))
|
||||
)
|
||||
|
||||
IdeNativePlatformDependencyResolver.resolve(commonMain).assertMatches(dependencies)
|
||||
@@ -54,8 +56,8 @@ class IdeNativePlatformDependencyResolverTest {
|
||||
val macosArm64Test = kotlin.sourceSets.getByName("macosArm64Test")
|
||||
|
||||
val dependencies = listOf(
|
||||
binaryCoordinates("org.jetbrains.kotlin.native:platform.CoreFoundation:${project.konanVersion}"),
|
||||
binaryCoordinates(Regex("""org\.jetbrains\.kotlin\.native:.*:${project.konanVersion}"""))
|
||||
binaryCoordinates("org.jetbrains.kotlin.native:platform.CoreFoundation:${project.konanVersion}:$MACOS_ARM64"),
|
||||
binaryCoordinates(Regex("""org\.jetbrains\.kotlin\.native:.*:${project.konanVersion}:$MACOS_ARM64"""))
|
||||
)
|
||||
|
||||
IdeNativePlatformDependencyResolver.resolve(commonMain).assertMatches(dependencies)
|
||||
|
||||
+5
-3
@@ -16,6 +16,8 @@ import org.jetbrains.kotlin.gradle.plugin.ide.dependencyResolvers.IdeNativeStdli
|
||||
import org.junit.Test
|
||||
|
||||
class IdeNativeStdlibResolverTest {
|
||||
|
||||
|
||||
@Test
|
||||
fun `test single linux target`() {
|
||||
val project = buildProjectWithMPP()
|
||||
@@ -28,7 +30,7 @@ class IdeNativeStdlibResolverTest {
|
||||
val linuxX64Main = kotlin.sourceSets.getByName("linuxX64Main")
|
||||
val linuxX64Test = kotlin.sourceSets.getByName("linuxX64Test")
|
||||
|
||||
val stdlibCoordinates = binaryCoordinates("org.jetbrains.kotlin:stdlib-native:${project.konanVersion}")
|
||||
val stdlibCoordinates = binaryCoordinates("org.jetbrains.kotlin.native:stdlib:${project.konanVersion}")
|
||||
|
||||
IdeNativeStdlibDependencyResolver.resolve(commonMain).assertMatches(stdlibCoordinates)
|
||||
IdeNativeStdlibDependencyResolver.resolve(commonTest).assertMatches(stdlibCoordinates)
|
||||
@@ -47,7 +49,7 @@ class IdeNativeStdlibResolverTest {
|
||||
val linuxX64Main = kotlin.sourceSets.getByName("linuxX64Main")
|
||||
val linuxX64Test = kotlin.sourceSets.getByName("linuxX64Test")
|
||||
|
||||
val stdlibCoordinates = binaryCoordinates("org.jetbrains.kotlin:stdlib-native:${project.konanVersion}")
|
||||
val stdlibCoordinates = binaryCoordinates("org.jetbrains.kotlin.native:stdlib:${project.konanVersion}")
|
||||
|
||||
IdeNativeStdlibDependencyResolver.resolve(linuxX64Main).assertMatches(stdlibCoordinates)
|
||||
IdeNativeStdlibDependencyResolver.resolve(linuxX64Test).assertMatches(stdlibCoordinates)
|
||||
@@ -79,7 +81,7 @@ class IdeNativeStdlibResolverTest {
|
||||
linuxX64Main.dependsOn(linuxTest)
|
||||
}
|
||||
|
||||
val stdlibCoordinates = binaryCoordinates("org.jetbrains.kotlin:stdlib-native:${project.konanVersion}")
|
||||
val stdlibCoordinates = binaryCoordinates("org.jetbrains.kotlin.native:stdlib:${project.konanVersion}")
|
||||
|
||||
IdeNativeStdlibDependencyResolver.resolve(linuxX64Main).assertMatches(stdlibCoordinates)
|
||||
IdeNativeStdlibDependencyResolver.resolve(linuxX64Test).assertMatches(stdlibCoordinates)
|
||||
|
||||
Reference in New Issue
Block a user