Test expected js target resources publication bahavior

^KT-65540
This commit is contained in:
Timofey Solonin
2024-03-05 17:20:35 +01:00
committed by Space Team
parent b765cf3f99
commit 76814a8bbe
26 changed files with 104 additions and 5 deletions
+1
View File
@@ -26,6 +26,7 @@
<trust group="org.jetbrains.kotlin" name="kotlin-compiler-runner" version="1\.9\.3[0-9](-.+)?|2\.0\.0(-.+)?" regex="true"/>
<trust group="org.jetbrains.kotlin" name="kotlin-daemon-client" version="1\.9\.3[0-9](-.+)?|2\.0\.0(-.+)?" regex="true"/>
<trust group="org.jetbrains.kotlin" name="kotlin-daemon-embeddable" version="1\.9\.3[0-9](-.+)?|2\.0\.0(-.+)?" regex="true"/>
<trust group="org.jetbrains.kotlin" name="kotlin-dom-api-compat" version="1\.9\.3[0-9](-.+)?|2\.0\.0(-.+)?" regex="true"/>
<trust group="org.jetbrains.kotlin" name="kotlin-gradle-plugin" version="1\.9\.3[0-9](-.+)?|2\.0\.0(-.+)?" regex="true"/>
<trust group="org.jetbrains.kotlin" name="kotlin-gradle-plugin-annotations" version="1\.9\.3[0-9](-.+)?|2\.0\.0(-.+)?" regex="true"/>
<trust group="org.jetbrains.kotlin" name="kotlin-gradle-plugin-api" version="1\.9\.3[0-9](-.+)?|2\.0\.0(-.+)?" regex="true"/>
@@ -74,6 +74,7 @@ class MultiplatformResourcesConsumptionIT : KGPBaseTest() {
"linuxX64",
"wasmJs",
"wasmWasi",
"js",
) + if (HostManager.hostIsMac) listOf("iosArm64") else emptyList()
resolvableTargets.forEach { target ->
@@ -49,10 +49,12 @@ class MultiplatformResourcesDependencyIT : KGPBaseTest() {
":compileKotlinLinuxX64",
":compileKotlinWasmJs",
":compileKotlinWasmWasi",
":compileKotlinJs",
":project:compileKotlinJvm",
":project:compileKotlinLinuxX64",
":project:compileKotlinWasmJs",
":project:compileKotlinWasmWasi",
":project:compileKotlinJs",
)
if (HostManager.host.family.isAppleFamily) {
assertTasksExecuted(
@@ -129,6 +129,23 @@ class MultiplatformResourcesPublicationIT : KGPBaseTest() {
)
}
@DisplayName("Multiplatform resources publication for js target")
@GradleAndroidTest
fun testJsTargetResourcesPublication(
gradleVersion: GradleVersion,
androidVersion: String,
providedJdk: JdkVersions.ProvidedJdk,
) {
testEmbeddedResources(
gradleVersion,
androidVersion,
providedJdk,
publicationTask = ":publishJsPublicationToMavenRepository",
publishedArchive = "build/repo/test/publication-js/1.0/publication-js-1.0-kotlin_resources.kotlin_resources.zip",
referenceName = "js",
)
}
@DisplayName("Multiplatform resources publication when a previously non-existent source set with resource is added")
@GradleAndroidTest
fun testNativeTargetResourcesPublicationWithNewSourceSet(
@@ -38,6 +38,7 @@ kotlin {
linuxX64(),
wasmJs(),
wasmWasi(),
js(),
).forEach { target ->
val fontsFilter = if (target is KotlinAndroidTarget) listOf("fonts/*") else emptyList()
val relativeResourcePlacement = provider { File("embed/subproject") }
@@ -22,6 +22,7 @@ kotlin {
iosSimulatorArm64(),
wasmJs(),
wasmWasi(),
js(),
).forEach { target ->
val assemblyTask = publication.resolveResources(target)
tasks.register<Copy>("${target.disambiguationClassifier}ResolveResources") {
@@ -32,6 +32,7 @@ kotlin {
iosArm64(),
wasmJs(),
wasmWasi(),
js(),
).forEach { target ->
val relativeResourcePlacement = provider { File("embed/${project.name}") }
val sourceSetPathProvider: (KotlinSourceSet) -> (Provider<File>) = { sourceSet ->
@@ -32,6 +32,7 @@ kotlin {
linuxX64()
wasmJs()
wasmWasi()
js()
iosArm64()
iosSimulatorArm64()
@@ -40,6 +40,7 @@ kotlin {
iosSimulatorArm64(),
wasmJs(),
wasmWasi(),
js(),
).forEach { target ->
val fontsFilter = if (target is KotlinAndroidTarget) listOf("fonts/*") else emptyList()
val relativeResourcePlacement = provider { File("embed/${project.name}") }
@@ -38,6 +38,7 @@ class KotlinTargetVariantResourcesPublicationTests {
{ linuxX64() },
{ wasmWasi() },
{ wasmJs() },
{ js() },
)
)
}
@@ -52,6 +53,7 @@ class KotlinTargetVariantResourcesPublicationTests {
{ linuxX64() },
{ wasmWasi() },
{ wasmJs() },
{ js() },
)
)
}
@@ -68,6 +70,7 @@ class KotlinTargetVariantResourcesPublicationTests {
{ linuxX64() },
{ wasmWasi() },
{ wasmJs() },
{ js() },
)
)
}
@@ -81,10 +81,11 @@ class KotlinTargetVariantResourcesResolutionTests {
}
@Test
fun `test direct dependency - for wasmJs and wasmWasi targets - when using artifact view`() {
fun `test direct dependency - for wasmJs, wasmWasi, js targets - when using artifact view`() {
listOf<TargetProvider>(
{ wasmJs() },
{ wasmWasi() },
{ js() },
).forEach { target ->
testDirectDependencyOnResourcesProducer(
producerTarget = { target() },
@@ -141,6 +142,25 @@ class KotlinTargetVariantResourcesResolutionTests {
)
}
@Test
fun `test direct dependency - for js - when using resources configuration`() {
testDirectDependencyOnResourcesProducer(
producerTarget = { js() },
consumerTarget = { js() },
resolutionStrategy = KotlinTargetResourcesResolutionStrategy.ResourcesConfiguration,
filterResolvedFiles = {
it.filterNot {
it.path.contains("kotlin-stdlib-js") || it.path.contains("kotlin-dom-api-compat")
}.toSet()
},
expectedResult = { _, producer ->
hashSetOf(
producer.buildFile("kotlin-multiplatform-resources/zip-for-publication/js/producer.kotlin_resources.zip"),
)
},
)
}
@Test
fun `test transitive dependency - without resources in middle project - with configuration`() {
testTransitiveDependencyOnResourcesProducer(
@@ -198,6 +218,44 @@ class KotlinTargetVariantResourcesResolutionTests {
}
}
@Test
fun `test transitive dependency - without resources in middle project in js - with configuration`() {
dependencyScopesWithResources().forEach { dependencyScope ->
testTransitiveDependencyOnResourcesProducer(
targetProvider = { js() },
resolutionStrategy = KotlinTargetResourcesResolutionStrategy.VariantReselection,
dependencyScope = dependencyScope,
filterResolvedFiles = {
it.filterNot {
it.path.contains("kotlin-stdlib-js") || it.path.contains("kotlin-dom-api-compat")
}.toSet()
},
expectedResult = { _, _, producer ->
setOf(
producer.buildFile("kotlin-multiplatform-resources/zip-for-publication/js/producer.kotlin_resources.zip"),
)
}
)
}
}
@Test
fun `test transitive dependency - without resources in middle project in js - with artifact view`() {
dependencyScopesWithResources().forEach { dependencyScope ->
testTransitiveDependencyOnResourcesProducer(
targetProvider = { js() },
resolutionStrategy = KotlinTargetResourcesResolutionStrategy.VariantReselection,
dependencyScope = dependencyScope,
filterResolvedFiles = { it },
expectedResult = { _, _, producer ->
setOf(
producer.buildFile("kotlin-multiplatform-resources/zip-for-publication/js/producer.kotlin_resources.zip"),
)
}
)
}
}
@Test
fun `test transitive dependency - without resources in middle project - with artifact view`() {
testTransitiveDependencyOnResourcesProducer(
@@ -280,6 +338,7 @@ class KotlinTargetVariantResourcesResolutionTests {
val targetsToTest = listOf<TargetProvider>(
{ wasmJs() },
{ wasmWasi() },
{ js() },
{ linuxX64() },
{ iosArm64() },
)
@@ -304,9 +363,6 @@ class KotlinTargetVariantResourcesResolutionTests {
return listOf(
{ this::implementation },
{ this::api },
// What are these supposed to mean for resources?
// { this::compileOnly }, ?
// { this::runtimeOnly }, ?
)
}
@@ -537,7 +593,6 @@ class KotlinTargetVariantResourcesResolutionTests {
projectBuilder = projectBuilder,
preApplyCode = preApplyCode,
) {
enableDependencyVerification(false)
enableDefaultStdlibDependency(true)
repositories.mavenLocal()
repositories.mavenCentralCacheRedirector()