[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
|
inline val Any.extraProperties: ExtraPropertiesExtension
|
||||||
get() = (this as ExtensionAware).extensions.extraProperties
|
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.idea.tcs.IdeaKotlinDependency
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
|
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
|
import org.jetbrains.kotlin.gradle.plugin.sources.project
|
||||||
|
|
||||||
internal object IdeDependencyLogger : IdeDependencyEffect {
|
internal object IdeDependencyLogger : IdeDependencyEffect {
|
||||||
@@ -14,7 +16,7 @@ internal object IdeDependencyLogger : IdeDependencyEffect {
|
|||||||
private const val propertyKey = "IdeDependencyLogger.log"
|
private const val propertyKey = "IdeDependencyLogger.log"
|
||||||
|
|
||||||
override fun invoke(sourceSet: KotlinSourceSet, dependencies: Set<IdeaKotlinDependency>) {
|
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)
|
val coordinates = IdeaKotlinSourceCoordinates(sourceSet)
|
||||||
if (log.isEmpty() || Regex(log).matches(coordinates.toString())) {
|
if (log.isEmpty() || Regex(log).matches(coordinates.toString())) {
|
||||||
IdeMultiplatformImport.logger.quiet(
|
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.idea.testFixtures.tcs.binaryCoordinates
|
||||||
import org.jetbrains.kotlin.gradle.plugin.ide.dependencyResolvers.IdeNativePlatformDependencyResolver
|
import org.jetbrains.kotlin.gradle.plugin.ide.dependencyResolvers.IdeNativePlatformDependencyResolver
|
||||||
import org.jetbrains.kotlin.konan.target.HostManager
|
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 org.junit.Assume
|
||||||
import kotlin.test.Test
|
import kotlin.test.Test
|
||||||
|
|
||||||
@@ -31,8 +33,8 @@ class IdeNativePlatformDependencyResolverTest {
|
|||||||
val linuxX64Test = kotlin.sourceSets.getByName("linuxX64Test")
|
val linuxX64Test = kotlin.sourceSets.getByName("linuxX64Test")
|
||||||
|
|
||||||
val dependencies = listOf(
|
val dependencies = listOf(
|
||||||
binaryCoordinates("org.jetbrains.kotlin.native:platform.posix:${project.konanVersion}"),
|
binaryCoordinates("org.jetbrains.kotlin.native:platform.posix:${project.konanVersion}:$LINUX_X64"),
|
||||||
binaryCoordinates(Regex("""org\.jetbrains\.kotlin\.native:.*:${project.konanVersion}"""))
|
binaryCoordinates(Regex("""org\.jetbrains\.kotlin\.native:.*:${project.konanVersion}:$LINUX_X64"""))
|
||||||
)
|
)
|
||||||
|
|
||||||
IdeNativePlatformDependencyResolver.resolve(commonMain).assertMatches(dependencies)
|
IdeNativePlatformDependencyResolver.resolve(commonMain).assertMatches(dependencies)
|
||||||
@@ -54,8 +56,8 @@ class IdeNativePlatformDependencyResolverTest {
|
|||||||
val macosArm64Test = kotlin.sourceSets.getByName("macosArm64Test")
|
val macosArm64Test = kotlin.sourceSets.getByName("macosArm64Test")
|
||||||
|
|
||||||
val dependencies = listOf(
|
val dependencies = listOf(
|
||||||
binaryCoordinates("org.jetbrains.kotlin.native:platform.CoreFoundation:${project.konanVersion}"),
|
binaryCoordinates("org.jetbrains.kotlin.native:platform.CoreFoundation:${project.konanVersion}:$MACOS_ARM64"),
|
||||||
binaryCoordinates(Regex("""org\.jetbrains\.kotlin\.native:.*:${project.konanVersion}"""))
|
binaryCoordinates(Regex("""org\.jetbrains\.kotlin\.native:.*:${project.konanVersion}:$MACOS_ARM64"""))
|
||||||
)
|
)
|
||||||
|
|
||||||
IdeNativePlatformDependencyResolver.resolve(commonMain).assertMatches(dependencies)
|
IdeNativePlatformDependencyResolver.resolve(commonMain).assertMatches(dependencies)
|
||||||
|
|||||||
+5
-3
@@ -16,6 +16,8 @@ import org.jetbrains.kotlin.gradle.plugin.ide.dependencyResolvers.IdeNativeStdli
|
|||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
class IdeNativeStdlibResolverTest {
|
class IdeNativeStdlibResolverTest {
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `test single linux target`() {
|
fun `test single linux target`() {
|
||||||
val project = buildProjectWithMPP()
|
val project = buildProjectWithMPP()
|
||||||
@@ -28,7 +30,7 @@ class IdeNativeStdlibResolverTest {
|
|||||||
val linuxX64Main = kotlin.sourceSets.getByName("linuxX64Main")
|
val linuxX64Main = kotlin.sourceSets.getByName("linuxX64Main")
|
||||||
val linuxX64Test = kotlin.sourceSets.getByName("linuxX64Test")
|
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(commonMain).assertMatches(stdlibCoordinates)
|
||||||
IdeNativeStdlibDependencyResolver.resolve(commonTest).assertMatches(stdlibCoordinates)
|
IdeNativeStdlibDependencyResolver.resolve(commonTest).assertMatches(stdlibCoordinates)
|
||||||
@@ -47,7 +49,7 @@ class IdeNativeStdlibResolverTest {
|
|||||||
val linuxX64Main = kotlin.sourceSets.getByName("linuxX64Main")
|
val linuxX64Main = kotlin.sourceSets.getByName("linuxX64Main")
|
||||||
val linuxX64Test = kotlin.sourceSets.getByName("linuxX64Test")
|
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(linuxX64Main).assertMatches(stdlibCoordinates)
|
||||||
IdeNativeStdlibDependencyResolver.resolve(linuxX64Test).assertMatches(stdlibCoordinates)
|
IdeNativeStdlibDependencyResolver.resolve(linuxX64Test).assertMatches(stdlibCoordinates)
|
||||||
@@ -79,7 +81,7 @@ class IdeNativeStdlibResolverTest {
|
|||||||
linuxX64Main.dependsOn(linuxTest)
|
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(linuxX64Main).assertMatches(stdlibCoordinates)
|
||||||
IdeNativeStdlibDependencyResolver.resolve(linuxX64Test).assertMatches(stdlibCoordinates)
|
IdeNativeStdlibDependencyResolver.resolve(linuxX64Test).assertMatches(stdlibCoordinates)
|
||||||
|
|||||||
Reference in New Issue
Block a user