From eabe87db9acad28fdb6e0a695e03dcdf63e5c327 Mon Sep 17 00:00:00 2001 From: Yacine Rezgui Date: Fri, 18 Mar 2022 21:12:23 +0000 Subject: [PATCH] Migrate dependencies system (#92) * doc: correct usage of `ActivityResultContract` `launch` method (#86) * Rename MediaStore tests * Upgrade to Android Studio BumbleBee & AGP 7.1 * Update run configuration * Apply spotless * Fix closing resources when file copy is done * Add support for file paths (#87) * Deprecate SharedFileSystem in favor of AndroidFileSystem Add support for Photo Picker metadata fetching * Add appendingSink implementation * Add support for file paths (makes interactions with Internal Storage possible) * Implement delete for physical files Add more internal storage tests * Enable (temporarily) tests on GitHub Actions * Apply spotless * Update sample to use AndroidFileSystem Disable tests (they're getting cancelled on GitHub Actions for no reason...) * Improve greatly platform testing coverage Deprecate Uri.toPath in favor of Uri.toOkioPath Add scanFile method * Upgrade version number Update storage guide * Fix type selection in photo picker * Fix metadata fetchinf for photo picker URIs * Updating storage guide * Fix deprecation issue for the old createMediaStoreUri method Update sample to use new createMediaStoreUri method * Upgrade AGP to 7.1.1 * Fix a few mistakes in permission.md (#89) * Update Android 13 notice for the photo picker * Add refreshVersions Gradle plugin * Migrate dependencies management to refreshVersions plugin * Remove version catalog feature preview * Upgrade dependencies Remove unused dependencies Fix code imports * Get kotlinCompilerExtensionVersion from versions.properties * Remove completely versions catalog * Revert code change Co-authored-by: tobianoapps <14228120+sebastinto@users.noreply.github.com> Co-authored-by: Andreas --- bom/build.gradle.kts | 2 +- build.gradle.kts | 14 ++-- gradle/androidx.versions.toml | 11 --- gradle/compose.versions.toml | 12 --- gradle/libs.versions.toml | 12 --- lint.xml | 6 ++ permissions/build.gradle.kts | 14 ++-- .../permissions/RequestAccess.kt | 2 +- photopicker/build.gradle.kts | 10 +-- sample/build.gradle.kts | 38 +++++---- .../modernstorage/sample/MainActivity.kt | 3 +- settings.gradle.kts | 14 +--- storage/build.gradle.kts | 26 +++--- versions.properties | 82 +++++++++++++++++++ 14 files changed, 145 insertions(+), 101 deletions(-) delete mode 100644 gradle/androidx.versions.toml delete mode 100644 gradle/compose.versions.toml delete mode 100644 gradle/libs.versions.toml create mode 100644 lint.xml create mode 100644 versions.properties diff --git a/bom/build.gradle.kts b/bom/build.gradle.kts index e2100dfd..6e97a1af 100644 --- a/bom/build.gradle.kts +++ b/bom/build.gradle.kts @@ -8,7 +8,7 @@ dependencies { api(project(":permissions")) api(project(":photopicker")) api(project(":storage")) - api(libs.okio) + api(Square.okio) } } diff --git a/build.gradle.kts b/build.gradle.kts index 820af13b..66afcd5a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -23,8 +23,8 @@ buildscript { mavenCentral() } dependencies { - classpath("com.android.tools.build:gradle:7.1.1") - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31") + classpath(Android.tools.build.gradlePlugin) + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:_") // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -32,11 +32,11 @@ buildscript { } plugins { - id("com.diffplug.spotless") version "5.12.5" - id("org.jetbrains.dokka") version "1.4.32" - id("me.tylerbwong.gradle.metalava") version "0.1.9" apply false - id("com.vanniktech.maven.publish") version "0.18.0" apply false - id("org.jetbrains.kotlin.plugin.parcelize") version "1.4.32" apply false + id("com.diffplug.spotless") + id("org.jetbrains.dokka") + id("me.tylerbwong.gradle.metalava") apply false + id("com.vanniktech.maven.publish") apply false + id("org.jetbrains.kotlin.plugin.parcelize") apply false } allprojects { diff --git a/gradle/androidx.versions.toml b/gradle/androidx.versions.toml deleted file mode 100644 index 466bbd58..00000000 --- a/gradle/androidx.versions.toml +++ /dev/null @@ -1,11 +0,0 @@ -[libraries] -corektx = { module = "androidx.core:core-ktx", version = "1.7.0" } -appcompat = { module = "androidx.appcompat:appcompat", version = "1.4.0" } -material = { module = "com.google.android.material:material", version = "1.4.0" } -lifecycleruntimektx = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version = "2.4.0" } -junit = { module = "androidx.test.ext:junit", version = "1.1.3" } -junitktx = { module = "androidx.test.ext:junit-ktx", version = "1.1.3" } -espresso = { module = "androidx.test.espresso:espresso-core", version = "3.4.0" } -rules = { module = "androidx.test:rules", version = "1.4.0" } -uiautomator = { module = "androidx.test.uiautomator:uiautomator", version = "2.2.0" } -runner = { module = "androidx.test:runner", version = "1.4.0" } diff --git a/gradle/compose.versions.toml b/gradle/compose.versions.toml deleted file mode 100644 index eafc7ac2..00000000 --- a/gradle/compose.versions.toml +++ /dev/null @@ -1,12 +0,0 @@ -[versions] -current = "1.0.5" - -[libraries] -ui = { module = "androidx.compose.ui:ui", version.ref = "current" } -material = { module = "androidx.compose.material:material", version.ref = "current" } -icons = { module = "androidx.compose.material:material-icons-extended", version.ref = "current" } -uitoolingpreview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "current" } -activity = { module = "androidx.activity:activity-compose", version = "1.4.0" } -navigation = { module = "androidx.navigation:navigation-compose", version = "2.4.0-rc01" } -uitooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "current" } -junit = { module = "androidx.compose.ui:ui-test-junit4", version.ref = "current" } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml deleted file mode 100644 index e0a60342..00000000 --- a/gradle/libs.versions.toml +++ /dev/null @@ -1,12 +0,0 @@ -[versions] -kotlin = "1.5.31" - -[libraries] -stdlib-jdk7 = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk7", version.ref = "kotlin" } -coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version = "1.5.2" } - -okio = { module = "com.squareup.okio:okio", version = "3.0.0" } -glide = { module = "com.github.skydoves:landscapist-glide", version = "1.4.5" } - -junit = { module = "junit:junit", version = "4.13.2" } -robolectric = { module = "org.robolectric:robolectric", version = "4.7.3" } diff --git a/lint.xml b/lint.xml new file mode 100644 index 00000000..9b1f16ad --- /dev/null +++ b/lint.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/permissions/build.gradle.kts b/permissions/build.gradle.kts index fcfb01cc..0149fc1a 100644 --- a/permissions/build.gradle.kts +++ b/permissions/build.gradle.kts @@ -58,12 +58,10 @@ android { } dependencies { - - implementation(androidx.corektx) - implementation(androidx.appcompat) - implementation(androidx.material) - testImplementation(libs.junit) - testImplementation(libs.robolectric) - androidTestImplementation(androidx.junit) - androidTestImplementation(androidx.junitktx) + implementation(AndroidX.core.ktx) + implementation(AndroidX.activity.ktx) + testImplementation(Testing.junit4) + testImplementation(Testing.robolectric) + androidTestImplementation(AndroidX.test.ext.junit) + androidTestImplementation(AndroidX.test.ext.junitKtx) } diff --git a/permissions/src/main/java/com/google/modernstorage/permissions/RequestAccess.kt b/permissions/src/main/java/com/google/modernstorage/permissions/RequestAccess.kt index e76a42fe..8e62b5f2 100644 --- a/permissions/src/main/java/com/google/modernstorage/permissions/RequestAccess.kt +++ b/permissions/src/main/java/com/google/modernstorage/permissions/RequestAccess.kt @@ -21,7 +21,7 @@ import android.content.Intent import android.content.pm.PackageManager import androidx.activity.result.contract.ActivityResultContract import androidx.activity.result.contract.ActivityResultContracts -import androidx.activity.result.contract.ActivityResultContracts.RequestMultiplePermissions.EXTRA_PERMISSION_GRANT_RESULTS +import androidx.activity.result.contract.ActivityResultContracts.RequestMultiplePermissions.Companion.EXTRA_PERMISSION_GRANT_RESULTS import androidx.core.content.ContextCompat class RequestAccess : ActivityResultContract() { diff --git a/photopicker/build.gradle.kts b/photopicker/build.gradle.kts index 3364dbcd..a8666a05 100644 --- a/photopicker/build.gradle.kts +++ b/photopicker/build.gradle.kts @@ -51,9 +51,9 @@ android { dependencies { - implementation(androidx.corektx) - implementation(androidx.appcompat) - testImplementation(libs.junit) - androidTestImplementation(androidx.junit) - androidTestImplementation(androidx.junitktx) + implementation(AndroidX.core.ktx) + implementation(AndroidX.activity.ktx) + testImplementation(Testing.junit4) + androidTestImplementation(AndroidX.test.ext.junit) + androidTestImplementation(AndroidX.test.ext.junitKtx) } diff --git a/sample/build.gradle.kts b/sample/build.gradle.kts index d0d7536f..9b522e3e 100644 --- a/sample/build.gradle.kts +++ b/sample/build.gradle.kts @@ -1,3 +1,5 @@ +import de.fayard.refreshVersions.core.versionFor + /* * Copyright 2021 Google LLC * @@ -58,7 +60,7 @@ android { } composeOptions { - kotlinCompilerExtensionVersion = compose.versions.current.get() + kotlinCompilerExtensionVersion = versionFor(AndroidX.compose.compiler) } packagingOptions { @@ -70,16 +72,16 @@ android { dependencies { - implementation(androidx.corektx) - implementation(androidx.appcompat) - implementation(androidx.material) - implementation(compose.ui) - implementation(compose.material) - implementation(compose.icons) - implementation(compose.uitoolingpreview) - implementation(androidx.lifecycleruntimektx) - implementation(compose.activity) - implementation(compose.navigation) + implementation(AndroidX.core.ktx) + implementation(AndroidX.appCompat) + implementation(Google.android.material) + implementation(AndroidX.compose.ui) + implementation(AndroidX.compose.material) + implementation(AndroidX.compose.material.icons.extended) + implementation(AndroidX.compose.ui.toolingPreview) + implementation(AndroidX.lifecycle.runtimeKtx) + implementation(AndroidX.activity.compose) + implementation(AndroidX.navigation.compose) /* * In a real world project you can use the BOM to import the different dependencies without needing @@ -92,14 +94,14 @@ dependencies { */ implementation(project(":permissions")) implementation(project(":photopicker")) - implementation(libs.okio) + implementation(Square.okio) implementation(project(":storage")) - implementation(libs.glide) + implementation("com.github.skydoves:landscapist-glide:_") - testImplementation(libs.junit) - androidTestImplementation(androidx.junit) - androidTestImplementation(androidx.espresso) - androidTestImplementation(compose.junit) - debugImplementation(compose.uitooling) + testImplementation(Testing.junit4) + androidTestImplementation(AndroidX.test.ext.junit) + androidTestImplementation(AndroidX.test.espresso.core) + androidTestImplementation(AndroidX.compose.ui.testJunit4) + debugImplementation(AndroidX.compose.ui.tooling) } diff --git a/sample/src/main/java/com/google/modernstorage/sample/MainActivity.kt b/sample/src/main/java/com/google/modernstorage/sample/MainActivity.kt index 458e70c8..70e48e41 100644 --- a/sample/src/main/java/com/google/modernstorage/sample/MainActivity.kt +++ b/sample/src/main/java/com/google/modernstorage/sample/MainActivity.kt @@ -31,8 +31,7 @@ import com.google.modernstorage.sample.saf.SelectDocumentFileScreen import com.google.modernstorage.sample.ui.theme.ModernStorageTheme class MainActivity : ComponentActivity() { - @ExperimentalFoundationApi - @ExperimentalMaterialApi + @OptIn(ExperimentalMaterialApi::class, ExperimentalFoundationApi::class) override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { diff --git a/settings.gradle.kts b/settings.gradle.kts index 180a2bd1..a7f7d83c 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -13,17 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -enableFeaturePreview("VERSION_CATALOGS") - -dependencyResolutionManagement { - versionCatalogs { - create("compose") { - from(files("gradle/compose.versions.toml")) - } - create("androidx") { - from(files("gradle/androidx.versions.toml")) - } - } +plugins { + // See https://jmfayard.github.io/refreshVersions + id("de.fayard.refreshVersions") version "0.40.1" } rootProject.name = "ModernStorage" diff --git a/storage/build.gradle.kts b/storage/build.gradle.kts index 2b4522a3..b699f232 100644 --- a/storage/build.gradle.kts +++ b/storage/build.gradle.kts @@ -50,21 +50,21 @@ android { } dependencies { - implementation(libs.stdlib.jdk7) - implementation(libs.coroutines.android) - androidTestImplementation(libs.coroutines.android) + implementation(Kotlin.stdlib.jdk7) + implementation(KotlinX.coroutines.android) + androidTestImplementation(KotlinX.coroutines.android) - implementation(androidx.corektx) - implementation(androidx.appcompat) - implementation(libs.okio) + implementation(AndroidX.core.ktx) + implementation(AndroidX.appCompat) + implementation(Square.okio) - testImplementation(libs.junit) - androidTestImplementation(androidx.junit) - androidTestImplementation(androidx.junitktx) - androidTestImplementation(androidx.espresso) - androidTestImplementation(androidx.rules) - androidTestImplementation(androidx.uiautomator) - androidTestImplementation(androidx.runner) + testImplementation(Testing.junit4) + androidTestImplementation(AndroidX.test.ext.junit) + androidTestImplementation(AndroidX.test.ext.junitKtx) + androidTestImplementation(AndroidX.test.espresso.core) + androidTestImplementation(AndroidX.test.rules) + androidTestImplementation(AndroidX.test.uiAutomator) + androidTestImplementation(AndroidX.test.runner) } repositories { mavenCentral() diff --git a/versions.properties b/versions.properties new file mode 100644 index 00000000..45b95553 --- /dev/null +++ b/versions.properties @@ -0,0 +1,82 @@ +#### Dependencies and Plugin versions with their available updates. +#### Generated by `./gradlew refreshVersions` version 0.40.1 +#### +#### Don't manually edit or split the comments that start with four hashtags (####), +#### they will be overwritten by refreshVersions. +#### +#### suppress inspection "SpellCheckingInspection" for whole file +#### suppress inspection "UnusedProperty" for whole file + +## unused +version.org.jetbrains.dokka..jekyll-template-processing-plugin=1.6.10 + +## unused +version.org.jetbrains.dokka..gfm-template-processing-plugin=1.6.10 + +## unused +version.org.jetbrains.dokka..dokka-base=1.6.10 + +## unused +version.org.jetbrains.dokka..all-modules-page-plugin=1.6.10 + +version.robolectric=4.7.3 + +## unused +version.org.jetbrains.dokka..jekyll-plugin=1.4.32 + +## unused +version.org.jetbrains.dokka..javadoc-plugin=1.4.32 + +## unused +version.org.jetbrains.dokka..gfm-plugin=1.4.32 + +## unused +version.org.jacoco..org.jacoco.ant=0.8.3 + + version.okio=3.0.0 + +version.kotlinx.coroutines=1.6.0 + +version.kotlin=1.6.10 + +version.junit.junit=4.13.2 + +version.google.android.material=1.5.0 + +version.com.github.skydoves..landscapist-glide=1.5.0 + +version.androidx.test.uiautomator=2.2.0 + +version.androidx.test.runner=1.4.0 + +version.androidx.test.rules=1.4.0 + +version.androidx.test.ext.junit=1.1.3 + +version.androidx.test.espresso=3.4.0 + +version.androidx.navigation-compose=2.4.1 + +version.androidx.lifecycle=2.4.1 + +version.androidx.core=1.7.0 + +version.androidx.compose.ui=1.1.1 + +version.androidx.compose.material=1.1.1 + +version.androidx.compose.compiler=1.1.1 + +version.androidx.appcompat=1.4.1 + +version.androidx.activity=1.4.0 + +plugin.org.jetbrains.dokka=1.6.10 + +plugin.me.tylerbwong.gradle.metalava=0.2.1 + +plugin.com.vanniktech.maven.publish=0.19.0 + +plugin.com.diffplug.spotless=6.3.0 + +plugin.android=7.1.2