| /* |
| * Copyright 2020 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 `create_project.py` script located in the |
| * `<AndroidX root>/development/project-creator` directory. |
| * |
| * Please use that script when creating a new project, rather than copying an existing project and |
| * modifying its settings. |
| */ |
| import org.jetbrains.kotlin.gradle.tasks.KotlinCompile |
| |
| plugins { |
| id("AndroidXPlugin") |
| id("com.android.library") |
| id("AndroidXComposePlugin") |
| } |
| |
| androidXMultiplatform { |
| android() |
| |
| sourceSets { |
| commonMain { |
| dependencies { |
| implementation(libs.kotlinStdlibCommon) |
| implementation(libs.kotlinCoroutinesCore) |
| implementation(projectOrArtifact(":compose:ui:ui")) |
| } |
| } |
| |
| commonTest { |
| dependencies { |
| implementation(kotlin("test-junit")) |
| } |
| } |
| |
| jvmMain { |
| dependsOn(commonMain) |
| dependencies { |
| implementation(libs.kotlinStdlib) |
| api(libs.kotlinCoroutinesCore) |
| } |
| } |
| |
| androidMain { |
| dependsOn(jvmMain) |
| dependencies { |
| api(libs.kotlinCoroutinesAndroid) |
| api("androidx.annotation:annotation:1.1.0") |
| |
| implementation("androidx.core:core-ktx:1.1.0") |
| } |
| } |
| |
| jvmTest { |
| dependsOn(commonTest) |
| dependencies { |
| } |
| } |
| |
| androidInstrumentedTest { |
| dependsOn(jvmTest) |
| dependencies { |
| implementation(projectOrArtifact(":compose:ui:ui")) |
| implementation(projectOrArtifact(":compose:material:material")) |
| implementation(projectOrArtifact(":compose:ui:ui-test-junit4")) |
| implementation(project(":compose:test-utils")) |
| implementation(projectOrArtifact(":activity:activity-compose")) |
| implementation(libs.testExtJunit) |
| implementation(libs.testRules) |
| implementation(libs.testRunner) |
| implementation(libs.truth) |
| } |
| } |
| |
| androidUnitTest { |
| dependsOn(jvmTest) |
| } |
| } |
| } |
| |
| android { |
| namespace "androidx.compose.runtime.integrationtests" |
| } |
| |
| tasks.withType(KotlinCompile).configureEach { |
| kotlinOptions { |
| incremental = false |
| freeCompilerArgs += [ |
| "-Xcontext-receivers", |
| "-P", |
| "plugin:androidx.compose.compiler.plugins.kotlin:sourceInformation=true" |
| ] |
| } |
| } |
| |
| public File findFile() { |
| project.file("src/androidAndroidTest/kotlin/androidx/compose/runtime/GroupSizeTests.kt") |
| } |
| |
| class UpdateExpectedGroupSizes extends DefaultTask { |
| @Internal |
| File source |
| |
| @Internal |
| String sizes |
| |
| @TaskAction |
| def exec() { |
| def newExpected = sizes.split(",") |
| if (newExpected.length != 3) { |
| if (newExpected.length < 3) |
| parameterError("Not enough parameters") |
| parameterError("Too many parameters") |
| } |
| if (!newExpected[1].isInteger()) { |
| parameterError("Groups field is not an integer") |
| } |
| if (!newExpected[1].isInteger()) { |
| parameterError("Slots field is not an integer") |
| } |
| def testName = newExpected[0] |
| def newGroups = newExpected[1] as Integer |
| def newSlots = newExpected[2] as Integer |
| |
| def lines = source.readLines() |
| def modified = false |
| |
| def namePattern = "\"$testName\"" |
| for (int i = 0; i < lines.size(); i++) { |
| String line = lines[i] |
| if (line.contains(namePattern)) { |
| def newGroupsIndex = lines[i + 1].indexOf("noMoreGroupsThan") |
| if (newGroupsIndex < 0) error("Group line not found for test $namePattern") |
| lines[i + 1] = lines[i + 1].replaceFirst(/[0-9]+/, "$newGroups") |
| def newSlotsIndex = lines[i + 2].indexOf("noMoreSlotsThan") |
| if (newSlotsIndex < 0) error("Group line not found for test $namePattern") |
| lines[i + 2] = lines[i + 2].replaceFirst(/[0-9]+/, "$newSlots") |
| modified = true |
| } |
| } |
| if (!modified) error("Could not find test $namePattern") |
| |
| // Update the file |
| def writer = source.newWriter() |
| lines.forEach {line -> |
| writer.write("$line\n") |
| } |
| writer.close() |
| } |
| |
| def parameterError(String message) { |
| error("$message, expected newExpectedGroups to look like " + |
| "<testsName>,<newGroups>,<newSlots>") |
| } |
| |
| def error(String message) { |
| throw new GradleException(message) |
| } |
| } |
| |
| afterEvaluate { |
| tasks.register("updateExpectedGroupSizes", UpdateExpectedGroupSizes) { task -> |
| task.source = findFile() |
| task.sizes = project.findProperty("compose.newExpectedSizes") |
| } |
| } |