Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/jb-main' into integration-releas…
Browse files Browse the repository at this point in the history
…e/compose-material3-adaptive/1.0

# Conflicts:
#	libraryversions.toml
  • Loading branch information
pjBooms committed Sep 18, 2024
2 parents 4ea0e37 + ed22cea commit 4363555
Show file tree
Hide file tree
Showing 484 changed files with 52,367 additions and 4,985 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package androidx.build

import java.io.ByteArrayOutputStream
import javax.inject.Inject
import org.gradle.api.Action
import org.gradle.api.Project
import org.gradle.api.attributes.Attribute
import org.gradle.api.tasks.Copy
Expand All @@ -32,7 +31,6 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetWithSimulatorTests
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest
import org.jetbrains.kotlin.gradle.targets.native.DefaultSimulatorTestRun
import org.jetbrains.kotlin.konan.target.KonanTarget
import org.tomlj.Toml
Expand Down Expand Up @@ -95,48 +93,37 @@ open class AndroidXComposeMultiplatformExtensionImpl @Inject constructor(
override fun wasm(): Unit = multiplatformExtension.run {
wasmJs {
browser {
testTask(Action<KotlinJsTest> {
testTask {
it.useKarma {
useChrome()
useConfigDirectory(
project.rootProject.projectDir.resolve("mpp/karma.config.d/wasm")
)
}
})
}
}
}

val resourcesDir = "${project.buildDir}/resources"
val resourcesDir = project.buildDir.resolve("resources")
val skikoWasm by project.configurations.creating

// Below code helps configure the tests for k/wasm targets
project.dependencies {
skikoWasm("org.jetbrains.skiko:skiko-js-wasm-runtime:${skikoVersion}")
}

val unzipTask = project.tasks.register("unzipSkikoForKWasm", Copy::class.java) {
it.destinationDir = project.file(resourcesDir)
it.from(skikoWasm.map { project.zipTree(it) })
}

val loadTestsTask = project.tasks.register("loadTests", Copy::class.java) {
val fetchSkikoWasmRuntime = project.tasks.register("fetchSkikoWasmRuntime", Copy::class.java) {
it.destinationDir = project.file(resourcesDir)
it.from(
project.rootProject.projectDir.resolve(
"mpp/load-wasm-tests/load-test-template.mjs"
)
)
it.filter {
it.replace("{module-name}", getDashedProjectName())
}
}

project.tasks.getByName("wasmJsTestProcessResources").apply {
dependsOn(loadTestsTask)
it.from(skikoWasm.map { artifact ->
project.zipTree(artifact)
.matching { pattern ->
pattern.include("skiko.wasm", "skiko.mjs")
}
})
}

project.tasks.getByName("wasmJsBrowserTest").apply {
dependsOn(unzipTask)
dependsOn(fetchSkikoWasmRuntime)
}

val commonMain = sourceSets.getByName("commonMain")
Expand All @@ -145,7 +132,7 @@ open class AndroidXComposeMultiplatformExtensionImpl @Inject constructor(

sourceSets.getByName("wasmJsTest").also {
it.resources.setSrcDirs(it.resources.srcDirs)
it.resources.srcDirs(unzipTask.map { it.destinationDir })
it.resources.srcDirs(fetchSkikoWasmRuntime.map { it.destinationDir })
}
}

Expand Down Expand Up @@ -271,22 +258,6 @@ open class AndroidXComposeMultiplatformExtensionImpl @Inject constructor(
// https://youtrack.jetbrains.com/issue/KT-55751/MPP-Gradle-Consumable-configurations-must-have-unique-attributes
private val instrumentedTestAttribute = Attribute.of("instrumentedTest", String::class.java)
private val instrumentedTestCompilationAttribute = Attribute.of("instrumentedTestCompilation", String::class.java)

// The consumer was configured to find a library for use during 'kotlin-metadata',
// preferably optimized for non-jvm, as well as
// attribute 'org.jetbrains.kotlin.platform.type'
// with value 'native',
// attribute 'org.jetbrains.kotlin.native.target'
// with value 'ios_simulator_arm64',
// attribute 'instrumentedTest'
// with value 'Test'.
// However we cannot choose between the following variants of project :compose:ui:ui:
// - uikitInstrumentedSimArm64ApiElements
// - uikitInstrumentedSimArm64MetadataElements
// - uikitSimArm64ApiElements
// - uikitSimArm64MetadataElements


override fun iosInstrumentedTest(): Unit =
multiplatformExtension.run {
fun getDeviceName(): String? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,21 @@ internal class CustomRootComponent(
fun addUsageFromConfiguration(configuration: Configuration, defaultUsage: KotlinUsageContext) {
val newDependency = customizeDependencyPerConfiguration(configuration)

// Dependencies from metadataApiElements, metadataSourcesElements.
// Includes not only commonMain, but also other non-target sourceSets (skikoMain, webMain)
val metadataDependencies = rootComponent.usages.flatMap { it.dependencies }

// Dependencies from debugApiElements and other Android configurations
val androidDependencies = defaultUsage.dependencies.toSet()

// Intersection of metadataDependencies and androidDependencies gives us commonMain deps
val commonMainDependencies = metadataDependencies.filter { it in androidDependencies }

extraUsages.add(
CustomUsage(
name = configuration.name,
attributes = configuration.attributes,
dependencies = setOf(newDependency) + defaultUsage.dependencies
dependencies = setOf(newDependency) + commonMainDependencies
)
)
}
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/public/src/main/kotlin/androidx/build/Version.kt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ data class Version(
private const val serialVersionUID = 345435634563L

private val VERSION_FILE_REGEX = Pattern.compile("^(res-)?(.*).txt$")
private val VERSION_REGEX = Pattern.compile("^(\\d+)\\.(\\d+)\\.(\\d+)((?:\\.\\d+)?(?:-.+)?)?$")
private val VERSION_REGEX = Pattern.compile("^(\\d+)\\.(\\d+)\\.(\\d+)((?:\\.\\d+)?(?:[-\\+].+)?)?$")

private fun checkedMatcher(versionString: String): Matcher {
val matcher = VERSION_REGEX.matcher(versionString)
Expand Down
Loading

0 comments on commit 4363555

Please sign in to comment.