diff --git a/buildSrc/src/main/kotlin/Extensions.kt b/buildSrc/src/main/kotlin/Extensions.kt index 233c17d75a..74c1c746d8 100644 --- a/buildSrc/src/main/kotlin/Extensions.kt +++ b/buildSrc/src/main/kotlin/Extensions.kt @@ -3,12 +3,8 @@ package coil import org.gradle.api.Project -import org.gradle.api.artifacts.Dependency -import org.gradle.api.artifacts.dsl.DependencyHandler import org.gradle.api.provider.Property import org.gradle.api.provider.SetProperty -import org.gradle.kotlin.dsl.kotlin -import org.gradle.kotlin.dsl.project import kotlin.math.pow val Project.minSdk: Int @@ -54,51 +50,6 @@ private inline fun List.sumByIndexed(selector: (Int, T) -> Int): Int { return sum } -private fun DependencyHandler.testImplementation(dependencyNotation: Any): Dependency? { - return add("testImplementation", dependencyNotation) -} - -private fun DependencyHandler.androidTestImplementation(dependencyNotation: Any): Dependency? { - return add("androidTestImplementation", dependencyNotation) -} - -fun DependencyHandler.addTestDependencies(kotlinVersion: String) { - testImplementation(project(":coil-test")) - - testImplementation(Library.JUNIT) - testImplementation(kotlin("test-junit", kotlinVersion)) - - testImplementation(Library.KOTLINX_COROUTINES_TEST) - - testImplementation(Library.ANDROIDX_TEST_CORE) - testImplementation(Library.ANDROIDX_TEST_JUNIT) - testImplementation(Library.ANDROIDX_TEST_RULES) - testImplementation(Library.ANDROIDX_TEST_RUNNER) - - testImplementation(Library.OKHTTP_MOCK_WEB_SERVER) - testImplementation(Library.OKIO_FAKE_FILESYSTEM) - - testImplementation(Library.ROBOLECTRIC) -} - -fun DependencyHandler.addAndroidTestDependencies(kotlinVersion: String) { - androidTestImplementation(project(":coil-test")) - - androidTestImplementation(Library.JUNIT) - androidTestImplementation(kotlin("test-junit", kotlinVersion)) - - androidTestImplementation(Library.KOTLINX_COROUTINES_TEST) - - androidTestImplementation(Library.MATERIAL) - - androidTestImplementation(Library.ANDROIDX_TEST_CORE) - androidTestImplementation(Library.ANDROIDX_TEST_JUNIT) - androidTestImplementation(Library.ANDROIDX_TEST_RULES) - androidTestImplementation(Library.ANDROIDX_TEST_RUNNER) - - androidTestImplementation(Library.OKHTTP_MOCK_WEB_SERVER) -} - inline infix fun Property.by(value: T) = set(value) inline infix fun SetProperty.by(value: Set) = set(value) diff --git a/buildSrc/src/main/kotlin/Library.kt b/buildSrc/src/main/kotlin/Library.kt deleted file mode 100644 index b1b3b4ff48..0000000000 --- a/buildSrc/src/main/kotlin/Library.kt +++ /dev/null @@ -1,59 +0,0 @@ -package coil - -object Library { - - // CORE - - private const val COROUTINES_VERSION = "1.6.0" - const val KOTLINX_COROUTINES_ANDROID = "org.jetbrains.kotlinx:kotlinx-coroutines-android:$COROUTINES_VERSION" - const val KOTLINX_COROUTINES_TEST = "org.jetbrains.kotlinx:kotlinx-coroutines-test:$COROUTINES_VERSION" - - const val ANDROIDX_ACTIVITY = "androidx.activity:activity-ktx:1.4.0" - const val ANDROIDX_ACTIVITY_COMPOSE = "androidx.activity:activity-compose:1.4.0" - const val ANDROIDX_APPCOMPAT_RESOURCES = "androidx.appcompat:appcompat-resources:1.4.1" - const val ANDROIDX_ANNOTATION = "androidx.annotation:annotation:1.3.0" - const val ANDROIDX_COLLECTION = "androidx.collection:collection:1.2.0" - const val ANDROIDX_CONSTRAINT_LAYOUT = "androidx.constraintlayout:constraintlayout:2.1.2" - const val ANDROIDX_CORE = "androidx.core:core-ktx:1.7.0" - const val ANDROIDX_EXIF_INTERFACE = "androidx.exifinterface:exifinterface:1.3.3" - const val ANDROIDX_RECYCLER_VIEW = "androidx.recyclerview:recyclerview:1.2.1" - const val ANDROIDX_VECTOR_DRAWABLE_ANIMATED = "androidx.vectordrawable:vectordrawable-animated:1.1.0" - - private const val LIFECYCLE_VERSION = "2.4.0" - const val ANDROIDX_LIFECYCLE_RUNTIME = "androidx.lifecycle:lifecycle-runtime:$LIFECYCLE_VERSION" - const val ANDROIDX_LIFECYCLE_VIEW_MODEL = "androidx.lifecycle:lifecycle-viewmodel-ktx:$LIFECYCLE_VERSION" - - const val COMPOSE_VERSION = "1.1.0-rc03" - const val COMPOSE_FOUNDATION = "androidx.compose.foundation:foundation:$COMPOSE_VERSION" - const val COMPOSE_MATERIAL = "androidx.compose.material:material:$COMPOSE_VERSION" - const val COMPOSE_UI_TEST_JUNIT = "androidx.compose.ui:ui-test-junit4:$COMPOSE_VERSION" - const val COMPOSE_UI_TEST_MANIFEST = "androidx.compose.ui:ui-test-manifest:$COMPOSE_VERSION" - - private const val ACCOMPANIST_VERSION = "0.22.1-rc" - const val ACCOMPANIST_DRAWABLE_PAINTER = "com.google.accompanist:accompanist-drawablepainter:$ACCOMPANIST_VERSION" - const val ACCOMPANIST_INSETS = "com.google.accompanist:accompanist-insets:$ACCOMPANIST_VERSION" - - private const val OKHTTP_VERSION = "4.9.3" - const val OKHTTP = "com.squareup.okhttp3:okhttp:$OKHTTP_VERSION" - const val OKHTTP_MOCK_WEB_SERVER = "com.squareup.okhttp3:mockwebserver:$OKHTTP_VERSION" - - private const val OKIO_VERSION = "3.0.0" - const val OKIO = "com.squareup.okio:okio:$OKIO_VERSION" - const val OKIO_FAKE_FILESYSTEM = "com.squareup.okio:okio-fakefilesystem:$OKIO_VERSION" - - const val MATERIAL = "com.google.android.material:material:1.5.0" - - const val ANDROID_SVG = "com.caverock:androidsvg-aar:1.4" - - // TEST - - const val JUNIT = "junit:junit:4.13.2" - - private const val ANDROIDX_TEST_VERSION = "1.4.0" - const val ANDROIDX_TEST_CORE = "androidx.test:core-ktx:$ANDROIDX_TEST_VERSION" - const val ANDROIDX_TEST_JUNIT = "androidx.test.ext:junit-ktx:1.1.3" - const val ANDROIDX_TEST_RULES = "androidx.test:rules:$ANDROIDX_TEST_VERSION" - const val ANDROIDX_TEST_RUNNER = "androidx.test:runner:$ANDROIDX_TEST_VERSION" - - const val ROBOLECTRIC = "org.robolectric:robolectric:4.7.3" -} diff --git a/buildSrc/src/main/kotlin/Projects.kt b/buildSrc/src/main/kotlin/Projects.kt index 96ca1108fc..8fbba4a718 100644 --- a/buildSrc/src/main/kotlin/Projects.kt +++ b/buildSrc/src/main/kotlin/Projects.kt @@ -11,78 +11,69 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions fun Project.setupLibraryModule( enableBuildConfig: Boolean = false, block: LibraryExtension.() -> Unit = {} -) { - setupBaseModule { - if (!enableBuildConfig) { - libraryVariants.all { - generateBuildConfigProvider?.configure { enabled = false } - } - } - packagingOptions { - // https://github.com/Kotlin/kotlinx.coroutines/issues/2023 - resources.pickFirsts += "META-INF/AL2.0" - resources.pickFirsts += "META-INF/LGPL2.1" - } - testOptions { - unitTests.isIncludeAndroidResources = true - } - block() +) = setupBaseModule { + libraryVariants.all { + generateBuildConfigProvider?.configure { enabled = enableBuildConfig } } + block() } -fun Project.setupAppModule(block: BaseAppModuleExtension.() -> Unit = {}) { - setupBaseModule { - defaultConfig { - versionCode = project.versionCode - versionName = project.versionName - resourceConfigurations += "en" - vectorDrawables.useSupportLibrary = true - } - block() +fun Project.setupAppModule( + block: BaseAppModuleExtension.() -> Unit = {} +) = setupBaseModule { + defaultConfig { + versionCode = project.versionCode + versionName = project.versionName + resourceConfigurations += "en" + vectorDrawables.useSupportLibrary = true } + block() } -private inline fun Project.setupBaseModule(crossinline block: T.() -> Unit = {}) { - extensions.configure("android") { - compileSdkVersion(project.compileSdk) - defaultConfig { - minSdk = project.minSdk - targetSdk = project.targetSdk - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 - } - kotlinOptions { - jvmTarget = "1.8" - allWarningsAsErrors = true +private inline fun Project.setupBaseModule( + crossinline block: T.() -> Unit = {} +) = extensions.configure("android") { + compileSdkVersion(project.compileSdk) + defaultConfig { + minSdk = project.minSdk + targetSdk = project.targetSdk + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = "1.8" + allWarningsAsErrors = true - val arguments = mutableListOf( - // https://kotlinlang.org/docs/compiler-reference.html#progressive - "-progressive", - // Generate native Java 8 default interface methods. - "-Xjvm-default=all", - // Generate smaller bytecode by not generating runtime not-null assertions. - "-Xno-call-assertions", - "-Xno-param-assertions", - "-Xno-receiver-assertions", - // https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-requires-opt-in/#requiresoptin - "-Xopt-in=kotlin.RequiresOptIn" - ) - if (project.name != "coil-test") { - arguments += "-Xopt-in=coil.annotation.ExperimentalCoilApi" - } - // https://youtrack.jetbrains.com/issue/KT-41985 - freeCompilerArgs += arguments - } - packagingOptions { - resources.pickFirsts += "META-INF/AL2.0" - resources.pickFirsts += "META-INF/LGPL2.1" - resources.pickFirsts += "META-INF/*kotlin_module" + val arguments = mutableListOf( + // https://kotlinlang.org/docs/compiler-reference.html#progressive + "-progressive", + // Generate native Java 8 default interface methods. + "-Xjvm-default=all", + // Generate smaller bytecode by not generating runtime not-null assertions. + "-Xno-call-assertions", + "-Xno-param-assertions", + "-Xno-receiver-assertions", + // https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-requires-opt-in/#requiresoptin + "-Xopt-in=kotlin.RequiresOptIn" + ) + if (project.name != "coil-test") { + arguments += "-Xopt-in=coil.annotation.ExperimentalCoilApi" } - (this as T).block() + // https://youtrack.jetbrains.com/issue/KT-41985 + freeCompilerArgs += arguments + } + packagingOptions { + resources.pickFirsts += "META-INF/AL2.0" + resources.pickFirsts += "META-INF/LGPL2.1" + resources.pickFirsts += "META-INF/*kotlin_module" + } + testOptions { + unitTests.isIncludeAndroidResources = true } + block() } private fun BaseExtension.kotlinOptions(block: KotlinJvmOptions.() -> Unit) { diff --git a/coil-base/build.gradle.kts b/coil-base/build.gradle.kts index 8989eddd1d..ad9d4fd51c 100644 --- a/coil-base/build.gradle.kts +++ b/coil-base/build.gradle.kts @@ -1,8 +1,4 @@ -import coil.Library -import coil.addAndroidTestDependencies -import coil.addTestDependencies import coil.setupLibraryModule -import org.jetbrains.kotlin.config.KotlinCompilerVersion plugins { id("com.android.library") @@ -12,27 +8,22 @@ plugins { id("com.vanniktech.maven.publish") } -setupLibraryModule { - sourceSets { - getByName("test").java.srcDir("src/sharedTest/java") - getByName("androidTest").java.srcDir("src/sharedTest/java") - } -} +setupLibraryModule() dependencies { - api(kotlin("stdlib-jdk8", KotlinCompilerVersion.VERSION)) - api(Library.KOTLINX_COROUTINES_ANDROID) - - implementation(Library.ANDROIDX_ANNOTATION) - implementation(Library.ANDROIDX_APPCOMPAT_RESOURCES) - implementation(Library.ANDROIDX_COLLECTION) - implementation(Library.ANDROIDX_CORE) - implementation(Library.ANDROIDX_EXIF_INTERFACE) - api(Library.ANDROIDX_LIFECYCLE_RUNTIME) + implementation(libs.androidx.annotation) + implementation(libs.androidx.appcompat.resources) + implementation(libs.androidx.collection) + implementation(libs.androidx.core) + implementation(libs.androidx.exifinterface) + api(libs.androidx.lifecycle.runtime) + api(libs.coroutines.android) + api(libs.okhttp) + api(libs.okio) - api(Library.OKHTTP) - api(Library.OKIO) + testImplementation(project(":coil-test")) + testImplementation(libs.bundles.test.jvm) - addTestDependencies(KotlinCompilerVersion.VERSION) - addAndroidTestDependencies(KotlinCompilerVersion.VERSION) + androidTestImplementation(project(":coil-test")) + androidTestImplementation(libs.bundles.test.android) } diff --git a/coil-base/src/androidTest/AndroidManifest.xml b/coil-base/src/androidTest/AndroidManifest.xml index bb86bb3abb..a22b4768e9 100644 --- a/coil-base/src/androidTest/AndroidManifest.xml +++ b/coil-base/src/androidTest/AndroidManifest.xml @@ -8,7 +8,7 @@ - + + android:viewportHeight="24.0"> diff --git a/coil-base/src/sharedTest/java/coil/SharedTestFunctions.kt b/coil-base/src/sharedTest/java/coil/SharedTestFunctions.kt deleted file mode 100644 index 67e858382a..0000000000 --- a/coil-base/src/sharedTest/java/coil/SharedTestFunctions.kt +++ /dev/null @@ -1,7 +0,0 @@ -package coil - -import android.graphics.Bitmap -import coil.size.Size - -val Bitmap.size: Size - get() = Size(width, height) diff --git a/coil-base/src/test/java/coil/intercept/EngineInterceptorTest.kt b/coil-base/src/test/java/coil/intercept/EngineInterceptorTest.kt index 593c122478..217bae312f 100644 --- a/coil-base/src/test/java/coil/intercept/EngineInterceptorTest.kt +++ b/coil-base/src/test/java/coil/intercept/EngineInterceptorTest.kt @@ -13,11 +13,11 @@ import coil.intercept.EngineInterceptor.ExecuteResult import coil.key.Keyer import coil.request.Options import coil.request.RequestService -import coil.size import coil.size.Size import coil.transform.CircleCropTransformation import coil.util.SystemCallbacks import coil.util.createRequest +import coil.util.size import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest import org.junit.Before diff --git a/coil-base/src/test/java/coil/util/DrawableUtilsTest.kt b/coil-base/src/test/java/coil/util/DrawableUtilsTest.kt index b5b69c18cd..c66b621904 100644 --- a/coil-base/src/test/java/coil/util/DrawableUtilsTest.kt +++ b/coil-base/src/test/java/coil/util/DrawableUtilsTest.kt @@ -11,7 +11,6 @@ import androidx.core.graphics.component3 import androidx.core.graphics.component4 import androidx.test.core.app.ApplicationProvider import coil.base.R -import coil.size import coil.size.Scale import coil.size.Size import org.junit.Test diff --git a/coil-compose-base/build.gradle.kts b/coil-compose-base/build.gradle.kts index cbbae755fd..1e04011452 100644 --- a/coil-compose-base/build.gradle.kts +++ b/coil-compose-base/build.gradle.kts @@ -1,8 +1,4 @@ -import coil.Library -import coil.addAndroidTestDependencies -import coil.addTestDependencies import coil.setupLibraryModule -import org.jetbrains.kotlin.config.KotlinCompilerVersion plugins { id("com.android.library") @@ -16,20 +12,21 @@ setupLibraryModule { compose = true } composeOptions { - kotlinCompilerExtensionVersion = Library.COMPOSE_VERSION + kotlinCompilerExtensionVersion = libs.versions.compose.get() } } dependencies { api(project(":coil-base")) - implementation(Library.ANDROIDX_CORE) - implementation(Library.ACCOMPANIST_DRAWABLE_PAINTER) - api(Library.COMPOSE_FOUNDATION) + implementation(libs.androidx.core) + implementation(libs.accompanist.drawablepainter) + api(libs.compose.foundation) - addTestDependencies(KotlinCompilerVersion.VERSION) - addAndroidTestDependencies(KotlinCompilerVersion.VERSION) + testImplementation(project(":coil-test")) + testImplementation(libs.bundles.test.jvm) - androidTestImplementation(Library.COMPOSE_UI_TEST_JUNIT) - androidTestImplementation(Library.COMPOSE_UI_TEST_MANIFEST) + androidTestImplementation(project(":coil-test")) + androidTestImplementation(libs.bundles.test.android) + androidTestImplementation(libs.compose.ui.test) } diff --git a/coil-compose-base/src/androidTest/AndroidManifest.xml b/coil-compose-base/src/androidTest/AndroidManifest.xml index 44187d95c2..f5f01e8f1d 100644 --- a/coil-compose-base/src/androidTest/AndroidManifest.xml +++ b/coil-compose-base/src/androidTest/AndroidManifest.xml @@ -5,14 +5,5 @@ - - - - - + diff --git a/coil-compose-base/src/androidTest/java/coil/compose/AsyncImagePainterTest.kt b/coil-compose-base/src/androidTest/java/coil/compose/AsyncImagePainterTest.kt index 611ab35ee9..ce93a2710b 100644 --- a/coil-compose-base/src/androidTest/java/coil/compose/AsyncImagePainterTest.kt +++ b/coil-compose-base/src/androidTest/java/coil/compose/AsyncImagePainterTest.kt @@ -1,7 +1,6 @@ package coil.compose import android.view.View -import androidx.activity.ComponentActivity import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column @@ -52,6 +51,7 @@ import coil.request.CachePolicy import coil.request.ErrorResult import coil.request.ImageRequest import coil.request.SuccessResult +import coil.util.TestActivity import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.flow.filter @@ -72,7 +72,7 @@ import kotlin.test.assertNull class AsyncImagePainterTest { @get:Rule - val composeTestRule = createAndroidComposeRule() + val composeTestRule = createAndroidComposeRule() private lateinit var server: MockWebServer private lateinit var requestTracker: ImageLoaderIdlingResource diff --git a/coil-compose-base/src/androidTest/java/coil/compose/AsyncImageTest.kt b/coil-compose-base/src/androidTest/java/coil/compose/AsyncImageTest.kt index 8e74f01add..012ffd2e4c 100644 --- a/coil-compose-base/src/androidTest/java/coil/compose/AsyncImageTest.kt +++ b/coil-compose-base/src/androidTest/java/coil/compose/AsyncImageTest.kt @@ -2,7 +2,6 @@ package coil.compose import android.graphics.BitmapFactory import android.view.View -import androidx.activity.ComponentActivity import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box @@ -48,6 +47,7 @@ import coil.request.ImageRequest import coil.request.Options import coil.request.SuccessResult import coil.size.Scale +import coil.util.TestActivity import kotlinx.coroutines.delay import okhttp3.mockwebserver.MockWebServer import org.junit.After @@ -64,7 +64,7 @@ import kotlin.test.fail class AsyncImageTest { @get:Rule - val composeTestRule = createAndroidComposeRule() + val composeTestRule = createAndroidComposeRule() private lateinit var server: MockWebServer private lateinit var requestTracker: ImageLoaderIdlingResource diff --git a/coil-compose-base/src/androidTest/java/coil/compose/utils/Utils.kt b/coil-compose-base/src/androidTest/java/coil/compose/utils/Utils.kt index 35e8fb57c0..434648f807 100644 --- a/coil-compose-base/src/androidTest/java/coil/compose/utils/Utils.kt +++ b/coil-compose-base/src/androidTest/java/coil/compose/utils/Utils.kt @@ -7,7 +7,6 @@ import android.net.Uri import android.os.Build.VERSION.SDK_INT import androidx.annotation.FloatRange import androidx.annotation.IdRes -import androidx.appcompat.content.res.AppCompatResources import androidx.compose.ui.geometry.Rect import androidx.compose.ui.graphics.ImageBitmap import androidx.compose.ui.graphics.asAndroidBitmap @@ -45,8 +44,7 @@ fun ImageBitmap.assertIsSimilarTo( @FloatRange(from = -1.0, to = 1.0) threshold: Double = 0.9 // Use a lower threshold by default. ) { val context = InstrumentationRegistry.getInstrumentation().targetContext - val expected = AppCompatResources.getDrawable(context, resId)!! - .toBitmap().scale(width, height, scale) + val expected = context.getDrawable(resId)!!.toBitmap().scale(width, height, scale) asAndroidBitmap().assertIsSimilarTo(expected, threshold) } diff --git a/coil-compose-singleton/build.gradle.kts b/coil-compose-singleton/build.gradle.kts index 8eee6e81f6..772bece37e 100644 --- a/coil-compose-singleton/build.gradle.kts +++ b/coil-compose-singleton/build.gradle.kts @@ -1,4 +1,3 @@ -import coil.Library import coil.setupLibraryModule plugins { @@ -13,7 +12,7 @@ setupLibraryModule { compose = true } composeOptions { - kotlinCompilerExtensionVersion = Library.COMPOSE_VERSION + kotlinCompilerExtensionVersion = libs.versions.compose.get() } } diff --git a/coil-gif/build.gradle.kts b/coil-gif/build.gradle.kts index cbeced2045..7c18079cd7 100644 --- a/coil-gif/build.gradle.kts +++ b/coil-gif/build.gradle.kts @@ -1,8 +1,4 @@ -import coil.Library -import coil.addAndroidTestDependencies -import coil.addTestDependencies import coil.setupLibraryModule -import org.jetbrains.kotlin.config.KotlinCompilerVersion plugins { id("com.android.library") @@ -16,9 +12,12 @@ setupLibraryModule() dependencies { api(project(":coil-base")) - implementation(Library.ANDROIDX_CORE) - implementation(Library.ANDROIDX_VECTOR_DRAWABLE_ANIMATED) + implementation(libs.androidx.core) + implementation(libs.androidx.vectordrawable.animated) - addTestDependencies(KotlinCompilerVersion.VERSION) - addAndroidTestDependencies(KotlinCompilerVersion.VERSION) + testImplementation(project(":coil-test")) + testImplementation(libs.bundles.test.jvm) + + androidTestImplementation(project(":coil-test")) + androidTestImplementation(libs.bundles.test.android) } diff --git a/coil-sample-common/build.gradle.kts b/coil-sample-common/build.gradle.kts index 09a63988d9..4133473c54 100644 --- a/coil-sample-common/build.gradle.kts +++ b/coil-sample-common/build.gradle.kts @@ -1,4 +1,3 @@ -import coil.Library import coil.setupLibraryModule plugins { @@ -14,6 +13,6 @@ dependencies { api(project(":coil-svg")) api(project(":coil-video")) - api(Library.ANDROIDX_CORE) - api(Library.ANDROIDX_LIFECYCLE_VIEW_MODEL) + api(libs.androidx.core) + api(libs.androidx.lifecycle.viewmodel) } diff --git a/coil-sample-compose/build.gradle.kts b/coil-sample-compose/build.gradle.kts index 90d239ffd1..ff980d2ab0 100644 --- a/coil-sample-compose/build.gradle.kts +++ b/coil-sample-compose/build.gradle.kts @@ -1,4 +1,3 @@ -import coil.Library import coil.setupAppModule plugins { @@ -22,7 +21,7 @@ setupAppModule { compose = true } composeOptions { - kotlinCompilerExtensionVersion = Library.COMPOSE_VERSION + kotlinCompilerExtensionVersion = libs.versions.compose.get() } } @@ -33,7 +32,7 @@ dependencies { implementation(project(":coil-svg")) implementation(project(":coil-video")) - implementation(Library.ANDROIDX_ACTIVITY_COMPOSE) - implementation(Library.ACCOMPANIST_INSETS) - implementation(Library.COMPOSE_MATERIAL) + implementation(libs.androidx.activity.compose) + implementation(libs.accompanist.insets) + implementation(libs.compose.material) } diff --git a/coil-sample-view/build.gradle.kts b/coil-sample-view/build.gradle.kts index c5ee39394a..e2b9cdde67 100644 --- a/coil-sample-view/build.gradle.kts +++ b/coil-sample-view/build.gradle.kts @@ -1,4 +1,3 @@ -import coil.Library import coil.setupAppModule plugins { @@ -30,8 +29,8 @@ dependencies { implementation(project(":coil-svg")) implementation(project(":coil-video")) - implementation(Library.ANDROIDX_ACTIVITY) - implementation(Library.ANDROIDX_CONSTRAINT_LAYOUT) - implementation(Library.ANDROIDX_RECYCLER_VIEW) - implementation(Library.MATERIAL) + implementation(libs.androidx.activity) + implementation(libs.androidx.constraintlayout) + implementation(libs.androidx.recyclerview) + implementation(libs.material) } diff --git a/coil-sample-view/src/main/res/values-night/styles.xml b/coil-sample-view/src/main/res/values-night/styles.xml index 96dbc91342..f63f4e35de 100644 --- a/coil-sample-view/src/main/res/values-night/styles.xml +++ b/coil-sample-view/src/main/res/values-night/styles.xml @@ -1,6 +1,6 @@ - diff --git a/coil-video/build.gradle.kts b/coil-video/build.gradle.kts index 1c78ad8514..035e57aa6c 100644 --- a/coil-video/build.gradle.kts +++ b/coil-video/build.gradle.kts @@ -1,8 +1,4 @@ -import coil.Library -import coil.addAndroidTestDependencies -import coil.addTestDependencies import coil.setupLibraryModule -import org.jetbrains.kotlin.config.KotlinCompilerVersion plugins { id("com.android.library") @@ -16,8 +12,11 @@ setupLibraryModule() dependencies { api(project(":coil-base")) - implementation(Library.ANDROIDX_CORE) + implementation(libs.androidx.core) - addTestDependencies(KotlinCompilerVersion.VERSION) - addAndroidTestDependencies(KotlinCompilerVersion.VERSION) + testImplementation(project(":coil-test")) + testImplementation(libs.bundles.test.jvm) + + androidTestImplementation(project(":coil-test")) + androidTestImplementation(libs.bundles.test.android) } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000000..ab0faee665 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,77 @@ +[versions] +accompanist = "0.22.1-rc" +compose = "1.1.0-rc03" +coroutines = "1.6.0" +lifecycle = "2.4.0" +okhttp = "4.9.3" +okio = "3.0.0" +test = "1.4.0" + +[libraries] +accompanist-drawablepainter = { module = "com.google.accompanist:accompanist-drawablepainter", version.ref = "accompanist" } +accompanist-insets = { module = "com.google.accompanist:accompanist-insets", version.ref = "accompanist" } + +androidx-activity = "androidx.activity:activity-ktx:1.4.0" +androidx-activity-compose = "androidx.activity:activity-compose:1.4.0" +androidx-appcompat-resources = "androidx.appcompat:appcompat-resources:1.4.1" +androidx-annotation = "androidx.annotation:annotation:1.3.0" +androidx-collection = "androidx.collection:collection:1.2.0" +androidx-constraintlayout = "androidx.constraintlayout:constraintlayout:2.1.3" +androidx-core = "androidx.core:core-ktx:1.7.0" +androidx-exifinterface = "androidx.exifinterface:exifinterface:1.3.3" +androidx-lifecycle-runtime = { module = "androidx.lifecycle:lifecycle-runtime", version.ref = "lifecycle" } +androidx-lifecycle-viewmodel = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "lifecycle" } +androidx-recyclerview = "androidx.recyclerview:recyclerview:1.2.1" +androidx-vectordrawable-animated = "androidx.vectordrawable:vectordrawable-animated:1.1.0" + +androidx-test-core = { module = "androidx.test:core-ktx", version.ref = "test" } +androidx-test-junit = "androidx.test.ext:junit-ktx:1.1.3" +androidx-test-rules = { module = "androidx.test:rules", version.ref = "test" } +androidx-test-runner = { module = "androidx.test:runner", version.ref = "test" } + +compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "compose" } +compose-material = { module = "androidx.compose.material:material", version.ref = "compose" } +compose-ui-test = { module = "androidx.compose.ui:ui-test-junit4", version.ref = "compose" } + +coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "coroutines" } +coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" } + +junit = "junit:junit:4.13.2" + +kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test-junit" } + +material = "com.google.android.material:material:1.5.0" + +okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" } +okhttp-mockwebserver = { module = "com.squareup.okhttp3:mockwebserver", version.ref = "okhttp" } + +okio = { module = "com.squareup.okio:okio", version.ref = "okio" } +okio-fakefilesystem = { module = "com.squareup.okio:okio-fakefilesystem", version.ref = "okio" } + +robolectric = "org.robolectric:robolectric:4.7.3" + +svg = "com.caverock:androidsvg-aar:1.4" + +[bundles] +test-jvm = [ + "androidx-test-core", + "androidx-test-junit", + "androidx-test-rules", + "androidx-test-runner", + "coroutines-test", + "junit", + "kotlin-test", + "okhttp-mockwebserver", + "okio-fakefilesystem", + "robolectric" +] +test-android = [ + "androidx-test-core", + "androidx-test-junit", + "androidx-test-rules", + "androidx-test-runner", + "coroutines-test", + "junit", + "kotlin-test", + "okhttp-mockwebserver" +] diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 669386b870..41dfb87909 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle.kts b/settings.gradle.kts index d4cc50bc3a..32cc153988 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -17,3 +17,6 @@ include( "coil-sample-view", "coil-test", ) + +// https://docs.gradle.org/7.4/userguide/declaring_dependencies.html#sec:type-safe-project-accessors +enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")