[Gradle, Test] Move newMppDependenciesDsl test to functional tests
This commit is contained in:
committed by
Space Team
parent
13fbfad549
commit
3f8df88857
-42
@@ -1529,48 +1529,6 @@ class NewMultiplatformIT : BaseGradleIT() {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDependenciesDsl() = with(transformProjectWithPluginsDsl("newMppDependenciesDsl")) {
|
||||
val originalBuildscriptContent = gradleBuildScript("app").readText()
|
||||
|
||||
fun testDependencies() = testResolveAllConfigurations("app") {
|
||||
assertContains(">> :app:testNonTransitiveStringNotationApiDependenciesMetadata --> junit-4.13.2.jar")
|
||||
assertContains(">> :app:testNonTransitiveStringNotationApiDependenciesMetadata --> kotlin-stdlib-common-${KOTLIN_VERSION}.jar")
|
||||
val dependenciesOnNonTransitive = (Regex.escape(">> :app:testNonTransitiveStringNotationApiDependenciesMetadata") + " .*")
|
||||
.toRegex().findAll(output)
|
||||
|
||||
if (dependenciesOnNonTransitive.count() != 2) fail(
|
||||
"Expected two resolved dependencies on testNonTransitiveStringNotationApiDependenciesMetadata. " +
|
||||
"Found: ${dependenciesOnNonTransitive.toList().map { it.value }}"
|
||||
)
|
||||
|
||||
assertContains(">> :app:testNonTransitiveDependencyNotationApiDependenciesMetadata --> kotlin-reflect-${defaultBuildOptions().kotlinVersion}.jar")
|
||||
|
||||
// All scoped DependenciesMetadata should resolve consistently into the same version
|
||||
assertContains(">> :app:testExplicitKotlinVersionApiDependenciesMetadata --> kotlin-reflect-1.3.0.jar")
|
||||
assertContains(">> :app:testExplicitKotlinVersionImplementationDependenciesMetadata --> kotlin-reflect-1.3.0.jar")
|
||||
assertContains(">> :app:testExplicitKotlinVersionCompileOnlyDependenciesMetadata --> kotlin-reflect-1.3.0.jar")
|
||||
|
||||
assertContains(">> :app:testProjectWithConfigurationApiDependenciesMetadata --> output.txt")
|
||||
}
|
||||
|
||||
testDependencies()
|
||||
|
||||
// Then run with Gradle Kotlin DSL; the build script needs some correction to be a valid GK DSL script:
|
||||
gradleBuildScript("app").run {
|
||||
modify {
|
||||
originalBuildscriptContent
|
||||
.replace(": ", " = ")
|
||||
.replace("def ", " val ")
|
||||
.replace("new File(cacheRedirectorFile)", "File(cacheRedirectorFile)")
|
||||
.replace("id \"org.jetbrains.kotlin.test.fixes.android\"", "id(\"org.jetbrains.kotlin.test.fixes.android\")")
|
||||
}
|
||||
renameTo(projectDir.resolve("app/build.gradle.kts"))
|
||||
}
|
||||
|
||||
testDependencies()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testMultipleTargetsSamePlatform() = with(Project("newMppMultipleTargetsSamePlatform", gradleVersion)) {
|
||||
testResolveAllConfigurations("app") {
|
||||
|
||||
-39
@@ -1,39 +0,0 @@
|
||||
plugins {
|
||||
id("org.jetbrains.kotlin.multiplatform").version("<pluginMarkerVersion>")
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvm("jvm6")
|
||||
js { }
|
||||
|
||||
sourceSets {
|
||||
create("testNonTransitiveStringNotation") {
|
||||
dependencies {
|
||||
api("junit:junit:4.13.2") { setTransitive(false) }
|
||||
}
|
||||
}
|
||||
create("testNonTransitiveDependencyNotation") {
|
||||
dependencies {
|
||||
api(kotlin("reflect")) { setTransitive(false) }
|
||||
}
|
||||
}
|
||||
create("testExplicitKotlinVersion") {
|
||||
dependencies {
|
||||
api(kotlin("reflect", "1.3.0"))
|
||||
implementation(kotlin("reflect", "1.2.71"))
|
||||
compileOnly(kotlin("reflect", "1.2.70"))
|
||||
runtimeOnly(kotlin("reflect", "1.2.60"))
|
||||
}
|
||||
}
|
||||
create("testProjectWithConfiguration") {
|
||||
dependencies {
|
||||
api(project(path: ":lib", configuration: "outputConfiguration"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
configurations {
|
||||
outputConfiguration
|
||||
}
|
||||
|
||||
artifacts {
|
||||
outputConfiguration file('output.txt')
|
||||
}
|
||||
-1
@@ -1 +0,0 @@
|
||||
include ':lib', ':app'
|
||||
+96
@@ -7,6 +7,10 @@
|
||||
|
||||
package org.jetbrains.kotlin.gradle.regressionTests
|
||||
|
||||
import org.gradle.api.artifacts.Configuration
|
||||
import org.gradle.api.artifacts.Dependency
|
||||
import org.gradle.api.artifacts.ModuleDependency
|
||||
import org.gradle.api.artifacts.ProjectDependency
|
||||
import org.gradle.api.attributes.AttributeContainer
|
||||
import org.gradle.api.attributes.Category
|
||||
import org.gradle.api.attributes.Usage
|
||||
@@ -30,6 +34,98 @@ import kotlin.test.assertTrue
|
||||
|
||||
class ConfigurationsTest : MultiplatformExtensionTest() {
|
||||
|
||||
@Test
|
||||
fun `source set dependencies dsl test`() {
|
||||
val lib = buildProjectWithMPP(projectBuilder = { withName("lib"); withParent(project) }) {
|
||||
kotlin {
|
||||
jvm()
|
||||
linuxX64()
|
||||
}
|
||||
|
||||
configurations.create("outputConfiguration") {
|
||||
it.isCanBeConsumed = true
|
||||
it.isCanBeResolved = false
|
||||
}
|
||||
}
|
||||
|
||||
kotlin.jvm()
|
||||
kotlin.linuxX64()
|
||||
|
||||
kotlin.sourceSets.getByName("commonMain").dependencies {
|
||||
api("junit:junit:4.13.2") { setTransitive(false) }
|
||||
api(kotlin("reflect")) { setTransitive(false) }
|
||||
api(kotlin("reflect", "1.3.0"))
|
||||
implementation(kotlin("reflect", "1.2.71"))
|
||||
compileOnly(kotlin("reflect", "1.2.70"))
|
||||
runtimeOnly(kotlin("reflect", "1.2.60"))
|
||||
api(project(path = ":lib", configuration = "outputConfiguration"))
|
||||
}
|
||||
|
||||
project.evaluate()
|
||||
|
||||
val commonMainApi = project.configurations.getByName("commonMainApi")
|
||||
val commonMainImplementation = project.configurations.getByName("commonMainImplementation")
|
||||
val commonMainCompileOnly = project.configurations.getByName("commonMainCompileOnly")
|
||||
val commonMainRuntimeOnly = project.configurations.getByName("commonMainRuntimeOnly")
|
||||
|
||||
fun Configuration.assertHasDependency(criterionName: String, criterion: Dependency.() -> Boolean) {
|
||||
val allDependenciesString = allDependencies.joinToString("\n")
|
||||
val message = "Configuration expected to have dependency: ${criterionName}.\n" +
|
||||
"But it has only dependencies: \n$allDependenciesString"
|
||||
assertTrue(message) { allDependencies.any(criterion) }
|
||||
}
|
||||
|
||||
commonMainApi.assertHasDependency("non-transitive string notation of junit:junit:4.13.2") {
|
||||
this is ModuleDependency &&
|
||||
group == "junit" &&
|
||||
name == "junit" &&
|
||||
version == "4.13.2" &&
|
||||
!isTransitive
|
||||
}
|
||||
|
||||
commonMainApi.assertHasDependency("non-transitive dependency notation of kotlin-reflect without version") {
|
||||
this is ModuleDependency &&
|
||||
group == "org.jetbrains.kotlin" &&
|
||||
name == "kotlin-reflect" &&
|
||||
version == null &&
|
||||
!isTransitive
|
||||
}
|
||||
|
||||
commonMainApi.assertHasDependency("dependency notation of kotlin-reflect:1.3.0") {
|
||||
this is ModuleDependency &&
|
||||
group == "org.jetbrains.kotlin" &&
|
||||
name == "kotlin-reflect" &&
|
||||
version == "1.3.0"
|
||||
}
|
||||
|
||||
commonMainApi.assertHasDependency("project notation of :lib:outputConfiguration") {
|
||||
this is ProjectDependency &&
|
||||
dependencyProject == lib &&
|
||||
targetConfiguration == "outputConfiguration"
|
||||
}
|
||||
|
||||
commonMainImplementation.assertHasDependency("dependency notation of kotlin-reflect:1.2.71") {
|
||||
this is ModuleDependency &&
|
||||
group == "org.jetbrains.kotlin" &&
|
||||
name == "kotlin-reflect" &&
|
||||
version == "1.2.71"
|
||||
}
|
||||
|
||||
commonMainCompileOnly.assertHasDependency("dependency notation of kotlin-reflect:1.2.70") {
|
||||
this is ModuleDependency &&
|
||||
group == "org.jetbrains.kotlin" &&
|
||||
name == "kotlin-reflect" &&
|
||||
version == "1.2.70"
|
||||
}
|
||||
|
||||
commonMainRuntimeOnly.assertHasDependency("dependency notation of kotlin-reflect:1.2.60") {
|
||||
this is ModuleDependency &&
|
||||
group == "org.jetbrains.kotlin" &&
|
||||
name == "kotlin-reflect" &&
|
||||
version == "1.2.60"
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `consumable configurations except sourcesElements with platform target are marked with Category LIBRARY`() {
|
||||
kotlin.linuxX64()
|
||||
|
||||
Reference in New Issue
Block a user