[go: nahoru, domu]

blob: 5f6535be168230a1f8ddc235c789d28e8d0d3816 [file] [log] [blame]
/*
* 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.
*/
import androidx.build.AndroidXComposePlugin
import androidx.build.LibraryType
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import static androidx.inspection.gradle.InspectionPluginKt.packageInspector
plugins {
id("AndroidXPlugin")
id("com.android.library")
id("AndroidXComposePlugin")
}
AndroidXComposePlugin.applyAndConfigureKotlinPlugin(project)
dependencies {
constraints {
// In 1.4.0-alpha02 there was a change made in :compose:ui:ui which fixed an issue where
// we were over-invalidating layout. This change caused a corresponding regression in
// foundation's CoreText, where it was expecting a layout to happen but with this change
// it would not. A corresponding fix for this was added in 1.4.0-alpha02 of
// :compose:foundation:foundation. By adding this constraint, we are ensuring that the
// if an app has this ui module _and_ the foundation module as a dependency, then the
// version of foundation will be at least this version. This will prevent the bug in
// foundation from occurring. This does _NOT_ require that the app have foundation as
// a dependency.
implementation(project(":compose:foundation:foundation")) {
because 'prevents a critical bug in Text'
}
}
if(!AndroidXComposePlugin.isMultiplatformEnabled(project)) {
/*
* When updating dependencies, make sure to make the an an analogous update in the
* corresponding block below
*/
implementation(libs.kotlinStdlibCommon)
implementation(libs.kotlinCoroutinesCore)
// when updating the runtime version please also update the runtime-saveable version
implementation(project(":compose:runtime:runtime"))
api(project(":compose:runtime:runtime-saveable"))
api(project(":compose:ui:ui-geometry"))
api(project(":compose:ui:ui-graphics"))
api(project(":compose:ui:ui-text"))
api(project(":compose:ui:ui-unit"))
api("androidx.annotation:annotation:1.5.0")
// This has stub APIs for access to legacy Android APIs, so we don't want
// any dependency on this module.
compileOnly(project(":compose:ui:ui-android-stubs"))
implementation(project(":compose:ui:ui-util"))
implementation(libs.kotlinStdlib)
implementation("androidx.autofill:autofill:1.0.0")
implementation(libs.kotlinCoroutinesAndroid)
implementation("androidx.activity:activity-ktx:1.5.1")
implementation("androidx.core:core:1.9.0")
implementation('androidx.collection:collection:1.0.0')
implementation("androidx.customview:customview-poolingcontainer:1.0.0")
implementation("androidx.savedstate:savedstate-ktx:1.2.0")
implementation("androidx.lifecycle:lifecycle-common-java8:2.5.1")
implementation("androidx.lifecycle:lifecycle-runtime:2.5.1")
implementation("androidx.lifecycle:lifecycle-viewmodel:2.5.1")
implementation("androidx.profileinstaller:profileinstaller:1.2.0")
testImplementation(libs.testRules)
testImplementation(libs.testRunner)
testImplementation(libs.kotlinCoroutinesTest)
testImplementation(libs.junit)
testImplementation(libs.truth)
testImplementation(libs.mockitoCore4)
testImplementation(libs.mockitoKotlin4)
testImplementation(libs.robolectric)
testImplementation(project(":compose:ui:ui-test-junit4"))
testImplementation(project(":compose:test-utils"))
androidTestImplementation(libs.testCore)
androidTestImplementation(libs.testRules)
androidTestImplementation(libs.testRunner)
androidTestImplementation(libs.testExtJunitKtx)
androidTestImplementation(libs.testUiautomator)
androidTestImplementation(libs.kotlinCoroutinesTest)
androidTestImplementation(libs.espressoCore)
androidTestImplementation(libs.bundles.espressoContrib)
androidTestImplementation(libs.junit)
androidTestImplementation(libs.dexmakerMockito)
androidTestImplementation(libs.mockitoCore)
androidTestImplementation(libs.truth)
androidTestImplementation(libs.mockitoKotlin)
androidTestImplementation(libs.material)
androidTestImplementation(project(":compose:animation:animation-core"))
androidTestImplementation(project(":compose:foundation:foundation"))
androidTestImplementation(project(":compose:foundation:foundation-layout"))
androidTestImplementation(project(":compose:material:material"))
androidTestImplementation(project(":compose:test-utils"))
androidTestImplementation(project(":internal-testutils-fonts"))
androidTestImplementation(project(":compose:ui:ui-test-junit4"))
androidTestImplementation(project(":internal-testutils-runtime"))
androidTestImplementation(project(":test:screenshot:screenshot"))
androidTestImplementation("androidx.recyclerview:recyclerview:1.3.0-alpha02")
androidTestImplementation("androidx.core:core-ktx:1.9.0")
androidTestImplementation("androidx.activity:activity-compose:1.5.1")
androidTestImplementation("androidx.appcompat:appcompat:1.3.0")
androidTestImplementation("androidx.fragment:fragment:1.3.0")
lintChecks(project(":compose:ui:ui-lint"))
lintPublish(project(":compose:ui:ui-lint"))
samples(project(":compose:ui:ui:ui-samples"))
}
}
packageInspector(project, ":compose:ui:ui-inspection")
if(AndroidXComposePlugin.isMultiplatformEnabled(project)) {
androidXComposeMultiplatform {
android()
desktop()
}
kotlin {
/*
* When updating dependencies, make sure to make the an an analogous update in the
* corresponding block above
*/
sourceSets {
commonMain.dependencies {
implementation(libs.kotlinStdlibCommon)
implementation(libs.kotlinCoroutinesCore)
// when updating the runtime version please also update the runtime-saveable version
implementation(project(":compose:runtime:runtime"))
api(project(":compose:runtime:runtime-saveable"))
api project(":compose:ui:ui-geometry")
api project(":compose:ui:ui-graphics")
api project(":compose:ui:ui-text")
api project(":compose:ui:ui-unit")
implementation(project(":compose:ui:ui-util"))
}
androidMain.dependencies {
implementation(libs.kotlinStdlib)
// This has stub APIs for access to legacy Android APIs, so we don't want
// any dependency on this module.
compileOnly(project(":compose:ui:ui-android-stubs"))
api("androidx.annotation:annotation:1.5.0")
implementation("androidx.autofill:autofill:1.0.0")
implementation(libs.kotlinCoroutinesAndroid)
implementation("androidx.activity:activity-ktx:1.5.1")
implementation("androidx.core:core:1.9.0")
implementation('androidx.collection:collection:1.0.0')
implementation("androidx.customview:customview-poolingcontainer:1.0.0")
implementation("androidx.savedstate:savedstate-ktx:1.2.0")
implementation("androidx.lifecycle:lifecycle-common-java8:2.5.1")
implementation("androidx.lifecycle:lifecycle-runtime:2.5.1")
implementation("androidx.lifecycle:lifecycle-viewmodel:2.5.1")
}
jvmMain.dependencies {
implementation(libs.kotlinStdlib)
}
skikoMain {
dependsOn(commonMain)
dependencies {
api(project(":compose:ui:ui-graphics"))
api(libs.skikoCommon)
}
}
desktopMain {
dependsOn(skikoMain)
dependencies {
implementation(libs.kotlinStdlibJdk8)
api(libs.kotlinCoroutinesSwing)
}
}
// TODO(b/214407011): These dependencies leak into instrumented tests as well. If you
// need to add Robolectric (which must be kept out of androidAndroidTest), use a top
// level dependencies block instead:
// `dependencies { testImplementation(libs.robolectric) }`
androidTest.dependencies {
implementation(libs.testRules)
implementation(libs.testRunner)
implementation(libs.kotlinCoroutinesTest)
implementation(libs.junit)
implementation(libs.truth)
implementation(libs.mockitoCore4)
implementation(libs.mockitoKotlin4)
implementation(project(":compose:ui:ui-test-junit4"))
implementation(project(":internal-testutils-fonts"))
implementation(project(":compose:test-utils"))
}
androidAndroidTest.dependencies {
implementation("androidx.fragment:fragment:1.3.0")
implementation("androidx.appcompat:appcompat:1.3.0")
implementation(libs.testUiautomator)
implementation(libs.testRules)
implementation(libs.testRunner)
implementation(libs.testExtJunitKtx)
implementation(libs.kotlinCoroutinesTest)
implementation(libs.espressoCore)
implementation(libs.bundles.espressoContrib)
implementation(libs.junit)
implementation(libs.dexmakerMockito)
implementation(libs.mockitoCore)
implementation(libs.truth)
implementation(libs.mockitoKotlin)
implementation(libs.material)
implementation(project(":compose:animation:animation-core"))
implementation(project(":compose:foundation:foundation"))
implementation(project(":compose:foundation:foundation-layout"))
implementation(project(":compose:material:material"))
implementation(project(":compose:test-utils"))
implementation(project(":internal-testutils-fonts"))
implementation(project(":compose:ui:ui-test-junit4"))
implementation(project(":internal-testutils-runtime"))
implementation(project(":test:screenshot:screenshot"))
implementation("androidx.recyclerview:recyclerview:1.3.0-alpha02")
implementation("androidx.core:core-ktx:1.2.0")
implementation("androidx.activity:activity-compose:1.5.1")
}
desktopTest.dependencies {
implementation(libs.truth)
implementation(libs.junit)
implementation(libs.mockitoCore)
implementation(libs.mockitoKotlin)
implementation(libs.skikoCurrentOs)
implementation(project(":compose:material:material"))
implementation(project(":compose:ui:ui-test-junit4"))
}
}
}
dependencies {
samples(project(":compose:ui:ui:ui-samples"))
// Can't declare this in kotlin { sourceSets { androidTest.dependencies { .. } } } as that
// leaks into instrumented tests (b/214407011)
testImplementation(libs.robolectric)
}
}
androidx {
name = "Compose UI primitives"
type = LibraryType.PUBLISHED_LIBRARY
inceptionYear = "2019"
description = "Compose UI primitives. This library contains the primitives that form the Compose UI Toolkit, such as drawing, measurement and layout."
legacyDisableKotlinStrictApiMode = true
}
if(AndroidXComposePlugin.isMultiplatformEnabled(project)) {
tasks.findByName("desktopTest").configure {
systemProperties["GOLDEN_PATH"] = project.rootDir.absolutePath + "/../../golden"
}
}
android {
testOptions.unitTests.includeAndroidResources = true
buildTypes.all {
consumerProguardFiles("proguard-rules.pro")
}
}
// Screenshot tests related setup
android {
sourceSets.androidTest.assets.srcDirs +=
project.rootDir.absolutePath + "/../../golden/compose/ui/ui"
namespace "androidx.compose.ui"
}
// Diagnostics for b/188565660
def verifyKotlinModule(String variant) {
project.afterEvaluate {
def capitalVariant = variant.capitalize()
def moduleFile = new File("${buildDir}/tmp/kotlin-classes/${variant}/META-INF/ui_${variant}.kotlin_module")
tasks.named("compile${capitalVariant}Kotlin").configure { t ->
t.doLast {
// This file should be large, about 3.2K. If this file is short then many symbols will fail to resolve
if (moduleFile.length() < 250) {
throw new GradleException("kotlin_module file ($moduleFile) too short! See b/188565660 for more information. File text: ${moduleFile.text}")
}
}
}
}
}
if (!AndroidXComposePlugin.isMultiplatformEnabled(project)) {
for (variant in ["debug", "release"]) {
verifyKotlinModule(variant)
}
}