diff --git a/compose/runtime/runtime-annotation/build-fork.gradle b/compose/runtime/runtime-annotation/build-fork.gradle new file mode 100644 index 0000000000000..9d614eed7920f --- /dev/null +++ b/compose/runtime/runtime-annotation/build-fork.gradle @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * This file was created using the `createProject` gradle task (./gradlew createProject) + * + * Please use the task when creating a new project, rather than copying an existing project and + * modifying its settings. + */ + +import androidx.build.SoftwareType +import androidx.build.PlatformIdentifier + +plugins { + id("AndroidXPlugin") +} + +androidXMultiplatform { + androidLibrary { + namespace = "androidx.compose.runtime.annotation" + } + jvm() + mac() + linux() + mingwX64() + ios() + watchos() + tvos() + js() + wasmJs() + + defaultPlatform(PlatformIdentifier.JVM) +} diff --git a/compose/runtime/runtime-stub/build.gradle b/compose/runtime/runtime-stub/build.gradle new file mode 100644 index 0000000000000..203ef44fb96b9 --- /dev/null +++ b/compose/runtime/runtime-stub/build.gradle @@ -0,0 +1,62 @@ +/* + * Copyright 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * This file was created using the `createProject` gradle task (./gradlew createProject) + * + * Please use the task when creating a new project, rather than copying an existing project and + * modifying its settings. + */ + +import androidx.build.SoftwareType +import androidx.build.PlatformIdentifier +import com.android.build.api.dsl.KotlinMultiplatformAndroidHostTestCompilation + +plugins { + id("AndroidXPlugin") + id("AndroidXComposePlugin") + id("JetBrainsAndroidXPlugin") +} + +androidXMultiplatform { + redirect("androidx.compose.runtime") { + androidLibrary { + namespace = "org.jetbrains.compose.runtime" + compilations.withType(KotlinMultiplatformAndroidHostTestCompilation) { + it.returnDefaultValues = true + } + } + desktop() + mingwX64() + linux() + mac() + ios() + tvos() + watchos() + js() + wasmJs() + } + + defaultPlatform(PlatformIdentifier.ANDROID) + +} + +androidx { + name = "Compose Runtime" + type = SoftwareType.PUBLISHED_LIBRARY_ONLY_USED_BY_KOTLIN_CONSUMERS + inceptionYear = "2019" + description = "Tree composition support for code generated by the Compose compiler plugin and corresponding public API" +} diff --git a/compose/runtime/runtime/build-fork.gradle b/compose/runtime/runtime/build-fork.gradle index 203ef44fb96b9..bec0d0614850e 100644 --- a/compose/runtime/runtime/build-fork.gradle +++ b/compose/runtime/runtime/build-fork.gradle @@ -21,42 +21,95 @@ * modifying its settings. */ -import androidx.build.SoftwareType import androidx.build.PlatformIdentifier import com.android.build.api.dsl.KotlinMultiplatformAndroidHostTestCompilation plugins { id("AndroidXPlugin") id("AndroidXComposePlugin") - id("JetBrainsAndroidXPlugin") } androidXMultiplatform { - redirect("androidx.compose.runtime") { - androidLibrary { - namespace = "org.jetbrains.compose.runtime" - compilations.withType(KotlinMultiplatformAndroidHostTestCompilation) { - it.returnDefaultValues = true - } + androidLibrary { + namespace = "androidx.compose.runtime" + compilations.withType(KotlinMultiplatformAndroidHostTestCompilation) { + it.returnDefaultValues = true } - desktop() - mingwX64() - linux() - mac() - ios() - tvos() - watchos() - js() - wasmJs() } + desktop() + mingwX64() + linux() + mac() + ios() + tvos() + watchos() + js() + wasmJs() defaultPlatform(PlatformIdentifier.ANDROID) -} + sourceSets { + commonMain.dependencies { + api(libs.kotlinCoroutinesCore) + api("androidx.compose.runtime:runtime-annotation:1.11.3") + implementation("androidx.collection:collection:1.5.0") + } + + commonTest.dependencies { + implementation(libs.kotlinTest) + implementation(libs.kotlinCoroutinesTest) + implementation(libs.kotlinReflect) + implementation(project(":compose:runtime:runtime-test-utils")) + } + + create("nonEmulatorCommonTest").dependsOn(commonTest) + create("nonEmulatorJvmTest").dependsOn(nonEmulatorCommonTest) + + androidMain.dependencies { + api(libs.kotlinCoroutinesAndroid) + api("androidx.annotation:annotation-experimental:1.4.1") + } + + androidDeviceTest.dependencies { + implementation(libs.testExtJunit) + implementation(libs.testRules) + implementation(libs.testRunner) + implementation(libs.espressoCore) + implementation(libs.truth) + } + + androidHostTest.dependsOn(nonEmulatorJvmTest) + + create("nonAndroidMain").dependsOn(commonMain) + create("nonAndroidTest").dependsOn(commonTest) + + desktopMain.dependsOn(nonAndroidMain) -androidx { - name = "Compose Runtime" - type = SoftwareType.PUBLISHED_LIBRARY_ONLY_USED_BY_KOTLIN_CONSUMERS - inceptionYear = "2019" - description = "Tree composition support for code generated by the Compose compiler plugin and corresponding public API" + desktopTest { + dependsOn(nonEmulatorJvmTest) + dependsOn(nonAndroidTest) + } + + nonJvmMain { + dependsOn(nonAndroidMain) + dependencies { + implementation(libs.atomicFu) + } + } + + nativeMain.dependsOn(nonAndroidMain) + + nativeTest { + dependsOn(nonAndroidTest) + dependsOn(nonEmulatorCommonTest) + } + + webTest.dependsOn(nonEmulatorCommonTest) + + wasmJsMain.dependencies { + implementation(libs.kotlinXw3c) + } + } } + +group = "androidx.compose.runtime" diff --git a/compose/runtime/runtime/build.gradle b/compose/runtime/runtime/build.gradle index 203ef44fb96b9..54c243dbcd945 100644 --- a/compose/runtime/runtime/build.gradle +++ b/compose/runtime/runtime/build.gradle @@ -24,34 +24,108 @@ import androidx.build.SoftwareType import androidx.build.PlatformIdentifier import com.android.build.api.dsl.KotlinMultiplatformAndroidHostTestCompilation +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { id("AndroidXPlugin") id("AndroidXComposePlugin") - id("JetBrainsAndroidXPlugin") } androidXMultiplatform { - redirect("androidx.compose.runtime") { - androidLibrary { - namespace = "org.jetbrains.compose.runtime" - compilations.withType(KotlinMultiplatformAndroidHostTestCompilation) { - it.returnDefaultValues = true - } + androidLibrary { + namespace = "androidx.compose.runtime" + compilations.withType(KotlinMultiplatformAndroidHostTestCompilation) { + it.returnDefaultValues = true } - desktop() - mingwX64() - linux() - mac() - ios() - tvos() - watchos() - js() - wasmJs() } + desktop() + mingwX64() + linux() + mac() + ios() + tvos() + watchos() + js() + wasmJs() defaultPlatform(PlatformIdentifier.ANDROID) + sourceSets { + commonMain.dependencies { + api(libs.kotlinCoroutinesCore) + api(project(":compose:runtime:runtime-annotation")) + implementation("androidx.collection:collection:1.5.0") + } + + commonTest.dependencies { + implementation(libs.kotlinTest) + implementation(libs.kotlinCoroutinesTest) + implementation(libs.kotlinReflect) + implementation(project(":compose:runtime:runtime-test-utils")) + } + + create("nonEmulatorCommonTest").dependsOn(commonTest) + create("nonEmulatorJvmTest").dependsOn(nonEmulatorCommonTest) + + androidMain.dependencies { + api(libs.kotlinCoroutinesAndroid) + api("androidx.annotation:annotation-experimental:1.4.1") + } + + androidDeviceTest.dependencies { + implementation(libs.testExtJunit) + implementation(libs.testRules) + implementation(libs.testRunner) + implementation(libs.espressoCore) + implementation(libs.truth) + } + + androidHostTest.dependsOn(nonEmulatorJvmTest) + + create("nonAndroidMain").dependsOn(commonMain) + create("nonAndroidTest").dependsOn(commonTest) + + desktopMain.dependsOn(nonAndroidMain) + + desktopTest { + dependsOn(nonEmulatorJvmTest) + dependsOn(nonAndroidTest) + } + + nonJvmMain { + dependsOn(nonAndroidMain) + dependencies { + implementation(libs.atomicFu) + } + } + + nativeMain.dependsOn(nonAndroidMain) + + nativeTest { + dependsOn(nonAndroidTest) + dependsOn(nonEmulatorCommonTest) + } + + webTest.dependsOn(nonEmulatorCommonTest) + + wasmJsMain.dependencies { + implementation(libs.kotlinXw3c) + } + } +} + +dependencies { + lintChecks(project(":compose:runtime:runtime-lint")) + lintPublish(project(":compose:runtime:runtime-lint")) + + constraints { + // Prevents symbols duplication with old versions of JetBrains' fork. + // Starting with version 1.9.0, this module is published as empty artifact + // with dependency to this androidx module. + commonMainImplementation("org.jetbrains.compose.runtime:runtime:1.9.0") { + because "prevents symbols duplication" + } + } } androidx { @@ -59,4 +133,5 @@ androidx { type = SoftwareType.PUBLISHED_LIBRARY_ONLY_USED_BY_KOTLIN_CONSUMERS inceptionYear = "2019" description = "Tree composition support for code generated by the Compose compiler plugin and corresponding public API" + samples(project(":compose:runtime:runtime:runtime-samples")) } diff --git a/gradle.properties b/gradle.properties index e0e4b823bbb29..06de4f8224c83 100644 --- a/gradle.properties +++ b/gradle.properties @@ -112,6 +112,8 @@ kapt.use.k2=true # JetBrains fork only properties +jetbrains.androidx.use.androidx.sources.instead.of.artifacts=true + # jetbrains-fork in jb-main branch androidx.studio.type=jetbrains-fork diff --git a/settings-fork.gradle b/settings-fork.gradle index 3a4ea0957c6a7..fb5744314e047 100644 --- a/settings-fork.gradle +++ b/settings-fork.gradle @@ -309,9 +309,6 @@ boolean shouldIncludeForFilter(List includeList) { return false } -def includeProject(name, List filter = []) { - includeProject(name, null, filter) -} // createProjectDependencyGraph is provided by project-dependency-graph.groovy ext.projectDependencyGraph = createProjectDependencyGraph( settings, @@ -321,6 +318,8 @@ ext.projectDependencyGraph = createProjectDependencyGraph( @Field Set filteredProjects = new HashSet() filteredProjects.add(":lint-checks") +@Field Map projectToSubstituteArtifact = new HashMap() + // Calling includeProject(name, filePath) is shorthand for: // // include(name) @@ -330,12 +329,12 @@ filteredProjects.add(":lint-checks") // the project name in the IDE // the Maven artifactId // -def includeProject(String name, filePath, List filter = []) { +def includeProject(String name, filePath = null, String substituteArtifact = null) { if (projectPrefixFilter.isConfigured) { if (projectPrefixFilter.matches(name)) { filteredProjects.add(name) } - } else if (shouldIncludeForFilter(filter)) { + } else { filteredProjects.add(name) } def file @@ -352,6 +351,10 @@ def includeProject(String name, filePath, List filter = []) { file = new File(rootDir, name.substring(1).replace(":", "/")) } projectDependencyGraph.addToAllProjects(name, file) + + if (substituteArtifact != null) { + projectToSubstituteArtifact[name] = substituteArtifact + } } // TODO(https://youtrack.jetbrains.com/issue/CMP-9524/Support-the-same-setup-for-integration-and-jb-main-branches) @@ -419,7 +422,7 @@ includeProject(":compose:material:material-ripple") includeProject(":compose:material:material:material-samples", "compose/material/material/samples") includeProject(":compose:material3:material3:material3-samples", "compose/material3/material3/samples") includeProject(":compose:runtime") -includeProject(":compose:runtime:runtime") +includeProject(":compose:runtime:runtime", "compose/runtime/runtime-stub") includeProject(":compose:runtime:runtime-lint") includeProject(":compose:runtime:runtime-livedata") includeProject(":compose:runtime:runtime-livedata:runtime-livedata-samples", "compose/runtime/runtime-livedata/samples") @@ -543,6 +546,13 @@ includeProject(":test:screenshot:screenshot", "mpp/stub-project") includeProject(":window:window-core", "mpp/stub-project") includeProject(":window:window-testing", "mpp/stub-project") +if (providers.gradleProperty("jetbrains.androidx.use.androidx.sources.instead.of.artifacts").getOrElse("false").toBoolean()) { + includeProject(":androidx.compose", "compose") + includeProject(":androidx.compose:runtime", "compose/runtime") + includeProject(":androidx.compose:runtime:runtime", "compose/runtime/runtime", "androidx.compose.runtime:runtime") + includeProject(":androidx.compose:runtime:runtime-annotation", "compose/runtime/runtime-annotation", "androidx.compose.runtime:runtime-annotation") +} + // --------------------------------------------------------------------- // --- there should be no includeProject additions after this line ----- // --------------------------------------------------------------------- @@ -562,3 +572,14 @@ void includeRequestedProjectsAndDependencies() { } includeRequestedProjectsAndDependencies() gradle.ext.allProjectConsumers = allProjectsConsumers(projectDependencyGraph) + +def projectToSubstituteArtifactLocal = projectToSubstituteArtifact +gradle.allprojects { + configurations.all { + resolutionStrategy.dependencySubstitution { + projectToSubstituteArtifactLocal.each { projectPath, artifact -> + substitute module(artifact) using project(projectPath) + } + } + } +} \ No newline at end of file