From c3761b6fbfe4e42ea8cb6408049b0d40006af464 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Odin=20Asbj=C3=B8rnsen?= Date: Mon, 1 May 2023 13:33:55 +0200 Subject: [PATCH 1/2] Prepare insets-ui gradle file for Kotlin DSL migration --- insets-ui/build.gradle | 64 +++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/insets-ui/build.gradle b/insets-ui/build.gradle index d4df2643e..15f5ed8fb 100644 --- a/insets-ui/build.gradle +++ b/insets-ui/build.gradle @@ -1,5 +1,5 @@ /* - * Copyright 2020 The Android Open Source Project + * Copyright 2023 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. @@ -15,10 +15,10 @@ */ plugins { - id 'com.android.library' - id 'kotlin-android' - id 'org.jetbrains.dokka' - id 'me.tylerbwong.gradle.metalava' + id("com.android.library") + id("kotlin-android") + id("org.jetbrains.dokka") + id("me.tylerbwong.gradle.metalava") } kotlin { @@ -26,36 +26,36 @@ kotlin { } android { - namespace "com.google.accompanist.insets.ui" + namespace = "com.google.accompanist.insets.ui" - compileSdkVersion 33 + compileSdkVersion = 33 defaultConfig { minSdkVersion 21 // targetSdkVersion has no effect for libraries. This is only used for the test APK targetSdkVersion 33 - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 } buildFeatures { - buildConfig false - compose true + buildConfig = false + compose = true } composeOptions { - kotlinCompilerExtensionVersion libs.versions.composeCompiler.get() + kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get() } lintOptions { - textReport true + textReport = true textOutput 'stdout' // We run a full lint analysis as build part in CI, so skip vital checks for assemble tasks - checkReleaseBuilds false + checkReleaseBuilds = false } packagingOptions { @@ -71,7 +71,7 @@ android { } unitTests.all { useJUnit { - excludeCategories 'com.google.accompanist.internal.test.IgnoreOnRobolectric' + excludeCategories "com.google.accompanist.internal.test.IgnoreOnRobolectric" } } animationsDisabled true @@ -96,34 +96,34 @@ metalava { } dependencies { - api project(':insets') - api libs.compose.material.material + api(project(":insets")) + api(libs.compose.material.material) - implementation libs.kotlin.coroutines.android + implementation(libs.kotlin.coroutines.android) // ====================== // Test dependencies // ====================== - androidTestImplementation project(':internal-testutils') - testImplementation project(':internal-testutils') + androidTestImplementation(project(":internal-testutils")) + testImplementation(project(":internal-testutils")) - androidTestImplementation libs.junit - testImplementation libs.junit + androidTestImplementation(libs.junit) + testImplementation(libs.junit) - androidTestImplementation libs.truth - testImplementation libs.truth + androidTestImplementation(libs.truth) + testImplementation(libs.truth) - androidTestImplementation libs.compose.ui.test.junit4 - testImplementation libs.compose.ui.test.junit4 + androidTestImplementation(libs.compose.ui.test.junit4) + testImplementation(libs.compose.ui.test.junit4) - androidTestImplementation libs.compose.ui.test.manifest - testImplementation libs.compose.ui.test.manifest + androidTestImplementation(libs.compose.ui.test.manifest) + testImplementation(libs.compose.ui.test.manifest) - androidTestImplementation libs.androidx.test.runner - testImplementation libs.androidx.test.runner + androidTestImplementation(libs.androidx.test.runner) + testImplementation(libs.androidx.test.runner) - testImplementation libs.robolectric + testImplementation(libs.robolectric) } apply plugin: "com.vanniktech.maven.publish" From e870e3f39f3571ea398ad5e81ab2d69241cd7c7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Odin=20Asbj=C3=B8rnsen?= Date: Mon, 1 May 2023 13:52:10 +0200 Subject: [PATCH 2/2] Migrate insets-ui to Kotlin DSL --- insets-ui/{build.gradle => build.gradle.kts} | 49 ++++++++++---------- 1 file changed, 25 insertions(+), 24 deletions(-) rename insets-ui/{build.gradle => build.gradle.kts} (73%) diff --git a/insets-ui/build.gradle b/insets-ui/build.gradle.kts similarity index 73% rename from insets-ui/build.gradle rename to insets-ui/build.gradle.kts index 15f5ed8fb..ac0763e37 100644 --- a/insets-ui/build.gradle +++ b/insets-ui/build.gradle.kts @@ -13,12 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +@file:Suppress("UnstableApiUsage") plugins { - id("com.android.library") - id("kotlin-android") - id("org.jetbrains.dokka") - id("me.tylerbwong.gradle.metalava") + id(libs.plugins.android.library.get().pluginId) + id(libs.plugins.android.kotlin.get().pluginId) + id(libs.plugins.jetbrains.dokka.get().pluginId) + id(libs.plugins.gradle.metalava.get().pluginId) + id(libs.plugins.vanniktech.maven.publish.get().pluginId) } kotlin { @@ -28,12 +30,12 @@ kotlin { android { namespace = "com.google.accompanist.insets.ui" - compileSdkVersion = 33 + compileSdk = 33 defaultConfig { - minSdkVersion 21 + minSdk = 21 // targetSdkVersion has no effect for libraries. This is only used for the test APK - targetSdkVersion 33 + targetSdk = 33 testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } @@ -51,40 +53,41 @@ android { kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get() } - lintOptions { + lint { textReport = true - textOutput 'stdout' + textOutput = File("stdout") // We run a full lint analysis as build part in CI, so skip vital checks for assemble tasks checkReleaseBuilds = false } - packagingOptions { + packaging { // Some of the META-INF files conflict with coroutines-test. Exclude them to enable // our test APK to build (has no effect on our AARs) - excludes += "/META-INF/AL2.0" - excludes += "/META-INF/LGPL2.1" + resources { + excludes += listOf("/META-INF/AL2.0", "/META-INF/LGPL2.1") + } } testOptions { unitTests { - includeAndroidResources = true + isIncludeAndroidResources = true } unitTests.all { - useJUnit { - excludeCategories "com.google.accompanist.internal.test.IgnoreOnRobolectric" + it.useJUnit { + excludeCategories("com.google.accompanist.internal.test.IgnoreOnRobolectric") } } - animationsDisabled true + animationsDisabled = true } sourceSets { - test { - java.srcDirs += 'src/sharedTest/kotlin' - res.srcDirs += 'src/sharedTest/res' + named("test") { + java.srcDirs("src/sharedTest/kotlin") + res.srcDirs("src/sharedTest/res") } - androidTest { - java.srcDirs += 'src/sharedTest/kotlin' - res.srcDirs += 'src/sharedTest/res' + named("androidTest") { + java.srcDirs("src/sharedTest/kotlin") + res.srcDirs("src/sharedTest/res") } } } @@ -125,5 +128,3 @@ dependencies { testImplementation(libs.robolectric) } - -apply plugin: "com.vanniktech.maven.publish"