[Gradle] Implement IdeAndroidDependencyResolutionTest
Added failing test for: KT-56430
This commit is contained in:
committed by
Space Team
parent
dec9704cea
commit
7341f37838
+4
@@ -17,6 +17,10 @@ import org.jetbrains.kotlin.gradle.plugin.ide.IdeDependencyResolver.Companion.SO
|
|||||||
|
|
||||||
fun interface IdeAdditionalArtifactResolver {
|
fun interface IdeAdditionalArtifactResolver {
|
||||||
fun resolve(sourceSet: KotlinSourceSet, dependencies: Set<IdeaKotlinDependency>)
|
fun resolve(sourceSet: KotlinSourceSet, dependencies: Set<IdeaKotlinDependency>)
|
||||||
|
|
||||||
|
object Empty : IdeAdditionalArtifactResolver {
|
||||||
|
override fun resolve(sourceSet: KotlinSourceSet, dependencies: Set<IdeaKotlinDependency>) = Unit
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun IdeDependencyResolver.withAdditionalArtifactResolver(resolver: IdeAdditionalArtifactResolver) =
|
internal fun IdeDependencyResolver.withAdditionalArtifactResolver(resolver: IdeAdditionalArtifactResolver) =
|
||||||
|
|||||||
+1
-1
@@ -129,7 +129,7 @@ interface IdeMultiplatformImport {
|
|||||||
|
|
||||||
enum class AdditionalArtifactResolutionPhase {
|
enum class AdditionalArtifactResolutionPhase {
|
||||||
PreAdditionalArtifactResolution,
|
PreAdditionalArtifactResolution,
|
||||||
SourcesAndJavadocArtifactResolution,
|
SourcesAndDocumentationResolution,
|
||||||
PostAdditionalArtifactResolution
|
PostAdditionalArtifactResolution
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.utils.addToStdlib.measureTimeMillisWithResult
|
|||||||
import kotlin.system.measureTimeMillis
|
import kotlin.system.measureTimeMillis
|
||||||
|
|
||||||
|
|
||||||
|
@Suppress("LoggingStringTemplateAsArgument")
|
||||||
internal class IdeMultiplatformImportImpl(
|
internal class IdeMultiplatformImportImpl(
|
||||||
private val extension: KotlinProjectExtension
|
private val extension: KotlinProjectExtension
|
||||||
) : IdeMultiplatformImport {
|
) : IdeMultiplatformImport {
|
||||||
|
|||||||
+79
@@ -0,0 +1,79 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@file:Suppress("FunctionName")
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.gradle.dependencyResolutionTests.tcs
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.gradle.dependencyResolutionTests.mavenCentralCacheRedirector
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.multiplatformExtension
|
||||||
|
import org.jetbrains.kotlin.gradle.idea.tcs.IdeaKotlinBinaryDependency
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.ide.dependencyResolvers.IdeArtifactResolutionQuerySourcesAndDocumentationResolver
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.ide.kotlinIdeMultiplatformImport
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.ide.kotlinIdeMultiplatformImportStatistics
|
||||||
|
import org.jetbrains.kotlin.gradle.util.*
|
||||||
|
import org.jetbrains.kotlin.gradle.utils.androidExtension
|
||||||
|
import kotlin.test.BeforeTest
|
||||||
|
import kotlin.test.Test
|
||||||
|
import kotlin.test.fail
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Android is not supposed to resolve any dependencies in this import.
|
||||||
|
* 'Android' refers to the 'classic' Android plugins (like com.android.application, ...library, ...)
|
||||||
|
*/
|
||||||
|
class IdeAndroidDependencyResolutionTest {
|
||||||
|
|
||||||
|
private val project = buildProject {
|
||||||
|
enableDefaultStdlibDependency(true)
|
||||||
|
enableDependencyVerification(false)
|
||||||
|
setMultiplatformAndroidSourceSetLayoutVersion(2)
|
||||||
|
applyMultiplatformPlugin()
|
||||||
|
plugins.apply("com.android.library")
|
||||||
|
androidExtension.compileSdkVersion(33)
|
||||||
|
repositories.mavenLocal()
|
||||||
|
repositories.mavenCentralCacheRedirector()
|
||||||
|
|
||||||
|
multiplatformExtension.apply {
|
||||||
|
android()
|
||||||
|
sourceSets.getByName("commonMain").dependencies {
|
||||||
|
implementation("com.arkivanov.mvikotlin:mvikotlin:3.0.2")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.evaluate()
|
||||||
|
|
||||||
|
private val androidSourceSets = project.multiplatformExtension.android().compilations.flatMap { it.kotlinSourceSets }
|
||||||
|
.ifEmpty { fail("Expected at least one Android SourceSet") }
|
||||||
|
|
||||||
|
@BeforeTest
|
||||||
|
fun checkEnvironment() {
|
||||||
|
assumeAndroidSdkAvailable()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test - android source sets do not resolve binary dependencies`() {
|
||||||
|
androidSourceSets.forEach { sourceSet ->
|
||||||
|
val binaryDependencies = project.kotlinIdeMultiplatformImport.resolveDependencies(sourceSet)
|
||||||
|
.filterIsInstance<IdeaKotlinBinaryDependency>()
|
||||||
|
|
||||||
|
if (binaryDependencies.isNotEmpty()) {
|
||||||
|
fail("Expected no binary dependencies being resolved for Android. Found $binaryDependencies")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test - Android SourceSets - do not execute Sources And Documentation Resolver`() {
|
||||||
|
androidSourceSets.forEach { sourceSet ->
|
||||||
|
project.kotlinIdeMultiplatformImport.resolveDependencies(sourceSet)
|
||||||
|
if (
|
||||||
|
IdeArtifactResolutionQuerySourcesAndDocumentationResolver::class.java in
|
||||||
|
project.kotlinIdeMultiplatformImportStatistics.getExecutionTimes()
|
||||||
|
) {
|
||||||
|
fail("${IdeArtifactResolutionQuerySourcesAndDocumentationResolver::class.simpleName} as executed on ${sourceSet.name}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user