From 540a39bfcd41b6d900f56f458b0e7691104a6b1f Mon Sep 17 00:00:00 2001 From: Jesse Wilson Date: Tue, 6 Aug 2024 16:39:08 -0700 Subject: [PATCH 1/2] Rename build.gradle to build.gradle.kts --- build.gradle => build.gradle.kts | 0 .../leakcanary-android-core/{build.gradle => build.gradle.kts} | 0 .../{build.gradle => build.gradle.kts} | 0 .../leakcanary-android-process/{build.gradle => build.gradle.kts} | 0 .../leakcanary-android-release/{build.gradle => build.gradle.kts} | 0 .../leakcanary-android-startup/{build.gradle => build.gradle.kts} | 0 .../leakcanary-android-test/{build.gradle => build.gradle.kts} | 0 .../{build.gradle => build.gradle.kts} | 0 .../leakcanary-android-utils/{build.gradle => build.gradle.kts} | 0 leakcanary/leakcanary-android/{build.gradle => build.gradle.kts} | 0 leakcanary/leakcanary-app-aidl/{build.gradle => build.gradle.kts} | 0 .../leakcanary-app-service/{build.gradle => build.gradle.kts} | 0 leakcanary/leakcanary-app/{build.gradle => build.gradle.kts} | 0 leakcanary/leakcanary-core/{build.gradle => build.gradle.kts} | 0 .../{build.gradle => build.gradle.kts} | 0 leakcanary/leakcanary-gc/{build.gradle => build.gradle.kts} | 0 leakcanary/leakcanary-jvm-test/{build.gradle => build.gradle.kts} | 0 .../leakcanary-test-core/{build.gradle => build.gradle.kts} | 0 .../{build.gradle => build.gradle.kts} | 0 .../{build.gradle => build.gradle.kts} | 0 .../{build.gradle => build.gradle.kts} | 0 .../object-watcher-android/{build.gradle => build.gradle.kts} | 0 object-watcher/object-watcher/{build.gradle => build.gradle.kts} | 0 plumber/plumber-android-core/{build.gradle => build.gradle.kts} | 0 .../plumber-android-startup/{build.gradle => build.gradle.kts} | 0 plumber/plumber-android/{build.gradle => build.gradle.kts} | 0 .../leakcanary-android-sample/{build.gradle => build.gradle.kts} | 0 shark/shark-android/{build.gradle => build.gradle.kts} | 0 shark/shark-cli/{build.gradle => build.gradle.kts} | 0 shark/shark-graph/{build.gradle => build.gradle.kts} | 0 shark/shark-hprof-test/{build.gradle => build.gradle.kts} | 0 shark/shark-hprof/{build.gradle => build.gradle.kts} | 0 shark/shark-log/{build.gradle => build.gradle.kts} | 0 shark/shark-test/{build.gradle => build.gradle.kts} | 0 shark/shark/{build.gradle => build.gradle.kts} | 0 35 files changed, 0 insertions(+), 0 deletions(-) rename build.gradle => build.gradle.kts (100%) rename leakcanary/leakcanary-android-core/{build.gradle => build.gradle.kts} (100%) rename leakcanary/leakcanary-android-instrumentation/{build.gradle => build.gradle.kts} (100%) rename leakcanary/leakcanary-android-process/{build.gradle => build.gradle.kts} (100%) rename leakcanary/leakcanary-android-release/{build.gradle => build.gradle.kts} (100%) rename leakcanary/leakcanary-android-startup/{build.gradle => build.gradle.kts} (100%) rename leakcanary/leakcanary-android-test/{build.gradle => build.gradle.kts} (100%) rename leakcanary/leakcanary-android-uiautomator/{build.gradle => build.gradle.kts} (100%) rename leakcanary/leakcanary-android-utils/{build.gradle => build.gradle.kts} (100%) rename leakcanary/leakcanary-android/{build.gradle => build.gradle.kts} (100%) rename leakcanary/leakcanary-app-aidl/{build.gradle => build.gradle.kts} (100%) rename leakcanary/leakcanary-app-service/{build.gradle => build.gradle.kts} (100%) rename leakcanary/leakcanary-app/{build.gradle => build.gradle.kts} (100%) rename leakcanary/leakcanary-core/{build.gradle => build.gradle.kts} (100%) rename leakcanary/leakcanary-deobfuscation-gradle-plugin/{build.gradle => build.gradle.kts} (100%) rename leakcanary/leakcanary-gc/{build.gradle => build.gradle.kts} (100%) rename leakcanary/leakcanary-jvm-test/{build.gradle => build.gradle.kts} (100%) rename leakcanary/leakcanary-test-core/{build.gradle => build.gradle.kts} (100%) rename object-watcher/object-watcher-android-androidx/{build.gradle => build.gradle.kts} (100%) rename object-watcher/object-watcher-android-core/{build.gradle => build.gradle.kts} (100%) rename object-watcher/object-watcher-android-startup/{build.gradle => build.gradle.kts} (100%) rename object-watcher/object-watcher-android/{build.gradle => build.gradle.kts} (100%) rename object-watcher/object-watcher/{build.gradle => build.gradle.kts} (100%) rename plumber/plumber-android-core/{build.gradle => build.gradle.kts} (100%) rename plumber/plumber-android-startup/{build.gradle => build.gradle.kts} (100%) rename plumber/plumber-android/{build.gradle => build.gradle.kts} (100%) rename samples/leakcanary-android-sample/{build.gradle => build.gradle.kts} (100%) rename shark/shark-android/{build.gradle => build.gradle.kts} (100%) rename shark/shark-cli/{build.gradle => build.gradle.kts} (100%) rename shark/shark-graph/{build.gradle => build.gradle.kts} (100%) rename shark/shark-hprof-test/{build.gradle => build.gradle.kts} (100%) rename shark/shark-hprof/{build.gradle => build.gradle.kts} (100%) rename shark/shark-log/{build.gradle => build.gradle.kts} (100%) rename shark/shark-test/{build.gradle => build.gradle.kts} (100%) rename shark/shark/{build.gradle => build.gradle.kts} (100%) diff --git a/build.gradle b/build.gradle.kts similarity index 100% rename from build.gradle rename to build.gradle.kts diff --git a/leakcanary/leakcanary-android-core/build.gradle b/leakcanary/leakcanary-android-core/build.gradle.kts similarity index 100% rename from leakcanary/leakcanary-android-core/build.gradle rename to leakcanary/leakcanary-android-core/build.gradle.kts diff --git a/leakcanary/leakcanary-android-instrumentation/build.gradle b/leakcanary/leakcanary-android-instrumentation/build.gradle.kts similarity index 100% rename from leakcanary/leakcanary-android-instrumentation/build.gradle rename to leakcanary/leakcanary-android-instrumentation/build.gradle.kts diff --git a/leakcanary/leakcanary-android-process/build.gradle b/leakcanary/leakcanary-android-process/build.gradle.kts similarity index 100% rename from leakcanary/leakcanary-android-process/build.gradle rename to leakcanary/leakcanary-android-process/build.gradle.kts diff --git a/leakcanary/leakcanary-android-release/build.gradle b/leakcanary/leakcanary-android-release/build.gradle.kts similarity index 100% rename from leakcanary/leakcanary-android-release/build.gradle rename to leakcanary/leakcanary-android-release/build.gradle.kts diff --git a/leakcanary/leakcanary-android-startup/build.gradle b/leakcanary/leakcanary-android-startup/build.gradle.kts similarity index 100% rename from leakcanary/leakcanary-android-startup/build.gradle rename to leakcanary/leakcanary-android-startup/build.gradle.kts diff --git a/leakcanary/leakcanary-android-test/build.gradle b/leakcanary/leakcanary-android-test/build.gradle.kts similarity index 100% rename from leakcanary/leakcanary-android-test/build.gradle rename to leakcanary/leakcanary-android-test/build.gradle.kts diff --git a/leakcanary/leakcanary-android-uiautomator/build.gradle b/leakcanary/leakcanary-android-uiautomator/build.gradle.kts similarity index 100% rename from leakcanary/leakcanary-android-uiautomator/build.gradle rename to leakcanary/leakcanary-android-uiautomator/build.gradle.kts diff --git a/leakcanary/leakcanary-android-utils/build.gradle b/leakcanary/leakcanary-android-utils/build.gradle.kts similarity index 100% rename from leakcanary/leakcanary-android-utils/build.gradle rename to leakcanary/leakcanary-android-utils/build.gradle.kts diff --git a/leakcanary/leakcanary-android/build.gradle b/leakcanary/leakcanary-android/build.gradle.kts similarity index 100% rename from leakcanary/leakcanary-android/build.gradle rename to leakcanary/leakcanary-android/build.gradle.kts diff --git a/leakcanary/leakcanary-app-aidl/build.gradle b/leakcanary/leakcanary-app-aidl/build.gradle.kts similarity index 100% rename from leakcanary/leakcanary-app-aidl/build.gradle rename to leakcanary/leakcanary-app-aidl/build.gradle.kts diff --git a/leakcanary/leakcanary-app-service/build.gradle b/leakcanary/leakcanary-app-service/build.gradle.kts similarity index 100% rename from leakcanary/leakcanary-app-service/build.gradle rename to leakcanary/leakcanary-app-service/build.gradle.kts diff --git a/leakcanary/leakcanary-app/build.gradle b/leakcanary/leakcanary-app/build.gradle.kts similarity index 100% rename from leakcanary/leakcanary-app/build.gradle rename to leakcanary/leakcanary-app/build.gradle.kts diff --git a/leakcanary/leakcanary-core/build.gradle b/leakcanary/leakcanary-core/build.gradle.kts similarity index 100% rename from leakcanary/leakcanary-core/build.gradle rename to leakcanary/leakcanary-core/build.gradle.kts diff --git a/leakcanary/leakcanary-deobfuscation-gradle-plugin/build.gradle b/leakcanary/leakcanary-deobfuscation-gradle-plugin/build.gradle.kts similarity index 100% rename from leakcanary/leakcanary-deobfuscation-gradle-plugin/build.gradle rename to leakcanary/leakcanary-deobfuscation-gradle-plugin/build.gradle.kts diff --git a/leakcanary/leakcanary-gc/build.gradle b/leakcanary/leakcanary-gc/build.gradle.kts similarity index 100% rename from leakcanary/leakcanary-gc/build.gradle rename to leakcanary/leakcanary-gc/build.gradle.kts diff --git a/leakcanary/leakcanary-jvm-test/build.gradle b/leakcanary/leakcanary-jvm-test/build.gradle.kts similarity index 100% rename from leakcanary/leakcanary-jvm-test/build.gradle rename to leakcanary/leakcanary-jvm-test/build.gradle.kts diff --git a/leakcanary/leakcanary-test-core/build.gradle b/leakcanary/leakcanary-test-core/build.gradle.kts similarity index 100% rename from leakcanary/leakcanary-test-core/build.gradle rename to leakcanary/leakcanary-test-core/build.gradle.kts diff --git a/object-watcher/object-watcher-android-androidx/build.gradle b/object-watcher/object-watcher-android-androidx/build.gradle.kts similarity index 100% rename from object-watcher/object-watcher-android-androidx/build.gradle rename to object-watcher/object-watcher-android-androidx/build.gradle.kts diff --git a/object-watcher/object-watcher-android-core/build.gradle b/object-watcher/object-watcher-android-core/build.gradle.kts similarity index 100% rename from object-watcher/object-watcher-android-core/build.gradle rename to object-watcher/object-watcher-android-core/build.gradle.kts diff --git a/object-watcher/object-watcher-android-startup/build.gradle b/object-watcher/object-watcher-android-startup/build.gradle.kts similarity index 100% rename from object-watcher/object-watcher-android-startup/build.gradle rename to object-watcher/object-watcher-android-startup/build.gradle.kts diff --git a/object-watcher/object-watcher-android/build.gradle b/object-watcher/object-watcher-android/build.gradle.kts similarity index 100% rename from object-watcher/object-watcher-android/build.gradle rename to object-watcher/object-watcher-android/build.gradle.kts diff --git a/object-watcher/object-watcher/build.gradle b/object-watcher/object-watcher/build.gradle.kts similarity index 100% rename from object-watcher/object-watcher/build.gradle rename to object-watcher/object-watcher/build.gradle.kts diff --git a/plumber/plumber-android-core/build.gradle b/plumber/plumber-android-core/build.gradle.kts similarity index 100% rename from plumber/plumber-android-core/build.gradle rename to plumber/plumber-android-core/build.gradle.kts diff --git a/plumber/plumber-android-startup/build.gradle b/plumber/plumber-android-startup/build.gradle.kts similarity index 100% rename from plumber/plumber-android-startup/build.gradle rename to plumber/plumber-android-startup/build.gradle.kts diff --git a/plumber/plumber-android/build.gradle b/plumber/plumber-android/build.gradle.kts similarity index 100% rename from plumber/plumber-android/build.gradle rename to plumber/plumber-android/build.gradle.kts diff --git a/samples/leakcanary-android-sample/build.gradle b/samples/leakcanary-android-sample/build.gradle.kts similarity index 100% rename from samples/leakcanary-android-sample/build.gradle rename to samples/leakcanary-android-sample/build.gradle.kts diff --git a/shark/shark-android/build.gradle b/shark/shark-android/build.gradle.kts similarity index 100% rename from shark/shark-android/build.gradle rename to shark/shark-android/build.gradle.kts diff --git a/shark/shark-cli/build.gradle b/shark/shark-cli/build.gradle.kts similarity index 100% rename from shark/shark-cli/build.gradle rename to shark/shark-cli/build.gradle.kts diff --git a/shark/shark-graph/build.gradle b/shark/shark-graph/build.gradle.kts similarity index 100% rename from shark/shark-graph/build.gradle rename to shark/shark-graph/build.gradle.kts diff --git a/shark/shark-hprof-test/build.gradle b/shark/shark-hprof-test/build.gradle.kts similarity index 100% rename from shark/shark-hprof-test/build.gradle rename to shark/shark-hprof-test/build.gradle.kts diff --git a/shark/shark-hprof/build.gradle b/shark/shark-hprof/build.gradle.kts similarity index 100% rename from shark/shark-hprof/build.gradle rename to shark/shark-hprof/build.gradle.kts diff --git a/shark/shark-log/build.gradle b/shark/shark-log/build.gradle.kts similarity index 100% rename from shark/shark-log/build.gradle rename to shark/shark-log/build.gradle.kts diff --git a/shark/shark-test/build.gradle b/shark/shark-test/build.gradle.kts similarity index 100% rename from shark/shark-test/build.gradle rename to shark/shark-test/build.gradle.kts diff --git a/shark/shark/build.gradle b/shark/shark/build.gradle.kts similarity index 100% rename from shark/shark/build.gradle rename to shark/shark/build.gradle.kts From ffdf55c3a5528deea3979a45d143df11e81d3073 Mon Sep 17 00:00:00 2001 From: Jesse Wilson Date: Tue, 6 Aug 2024 16:40:25 -0700 Subject: [PATCH 2/2] Actually convert --- build.gradle.kts | 112 +++++++++--------- gradle/libs.versions.toml | 3 + .../leakcanary-android-core/build.gradle.kts | 77 ++++++------ .../build.gradle.kts | 48 ++++---- .../build.gradle.kts | 20 ++-- .../build.gradle.kts | 35 +++--- .../build.gradle.kts | 18 +-- .../leakcanary-android-test/build.gradle.kts | 32 ++--- .../build.gradle.kts | 18 +-- .../leakcanary-android-utils/build.gradle.kts | 18 +-- .../leakcanary-android/build.gradle.kts | 32 ++--- .../leakcanary-app-aidl/build.gradle.kts | 18 +-- .../leakcanary-app-service/build.gradle.kts | 22 ++-- leakcanary/leakcanary-app/build.gradle.kts | 96 +++++++-------- leakcanary/leakcanary-core/build.gradle.kts | 18 +-- .../build.gradle.kts | 38 +++--- leakcanary/leakcanary-gc/build.gradle.kts | 8 +- .../leakcanary-jvm-test/build.gradle.kts | 16 +-- .../leakcanary-test-core/build.gradle.kts | 14 ++- .../build.gradle.kts | 20 ++-- .../build.gradle.kts | 28 ++--- .../build.gradle.kts | 18 +-- .../object-watcher-android/build.gradle.kts | 16 +-- .../object-watcher/build.gradle.kts | 16 +-- plumber/plumber-android-core/build.gradle.kts | 26 ++-- .../plumber-android-startup/build.gradle.kts | 20 ++-- plumber/plumber-android/build.gradle.kts | 20 ++-- .../build.gradle.kts | 81 ++++++------- shark/shark-android/build.gradle.kts | 26 ++-- shark/shark-cli/build.gradle.kts | 37 +++--- shark/shark-graph/build.gradle.kts | 22 ++-- shark/shark-hprof-test/build.gradle.kts | 14 ++- shark/shark-hprof/build.gradle.kts | 20 ++-- shark/shark-log/build.gradle.kts | 12 +- shark/shark-test/build.gradle.kts | 12 +- shark/shark/build.gradle.kts | 22 ++-- 36 files changed, 553 insertions(+), 500 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 385673d77c..c8aaa5698d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,26 +1,28 @@ -import org.jetbrains.dokka.gradle.DokkaTask +import com.vanniktech.maven.publish.MavenPublishBaseExtension import com.vanniktech.maven.publish.SonatypeHost +import io.gitlab.arturbosch.detekt.extensions.DetektExtension +import java.net.URL +import kotlinx.validation.ApiValidationExtension +import org.gradle.api.tasks.testing.logging.TestExceptionFormat +import org.jetbrains.dokka.gradle.DokkaTask +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile buildscript { - ext.versions = [ - 'minSdk' : 14, - 'compileSdk': 34, - ] repositories { google() gradlePluginPortal() mavenCentral() } dependencies { - classpath libs.gradlePlugin.android - classpath libs.gradlePlugin.kotlin - classpath libs.gradlePlugin.dokka - classpath libs.gradlePlugin.mavenPublish - classpath libs.gradlePlugin.detekt - classpath libs.gradlePlugin.binaryCompatibility - classpath libs.gradlePlugin.keeper - classpath libs.gradlePlugin.sqldelight - classpath 'com.google.dagger:hilt-android-gradle-plugin:2.43.2' + classpath(libs.gradlePlugin.android) + classpath(libs.gradlePlugin.kotlin) + classpath(libs.gradlePlugin.dokka) + classpath(libs.gradlePlugin.mavenPublish) + classpath(libs.gradlePlugin.detekt) + classpath(libs.gradlePlugin.binaryCompatibility) + classpath(libs.gradlePlugin.keeper) + classpath(libs.gradlePlugin.sqldelight) + classpath("com.google.dagger:hilt-android-gradle-plugin:2.43.2") } } @@ -29,16 +31,16 @@ buildscript { // When making a change that results in a public ABI change, the apiCheck task will fail. When this // happens, run ./gradlew apiDump to generate updated *.api files, and add those to your commit. // See https://github.com/Kotlin/binary-compatibility-validator -apply plugin: 'binary-compatibility-validator' +apply(plugin = "binary-compatibility-validator") -apiValidation { +extensions.configure { // Ignore projects that are not uploaded to Maven Central - ignoredProjects += ["leakcanary-app", "leakcanary-android-sample", "shark-test", "shark-hprof-test", "shark-cli"] + ignoredProjects += listOf("leakcanary-app", "leakcanary-android-sample", "shark-test", "shark-hprof-test", "shark-cli") } // This plugin needs to be applied to the root projects for the dokkaGfmCollector task we use to // generate the documentation site. -apply plugin: 'org.jetbrains.dokka' +apply(plugin = "org.jetbrains.dokka") repositories { // Needed for the Dokka plugin. @@ -58,30 +60,32 @@ subprojects { jcenter() } - apply plugin: 'io.gitlab.arturbosch.detekt' + apply(plugin = "io.gitlab.arturbosch.detekt") - tasks.withType(JavaCompile).configureEach { - options.compilerArgs += [ - '-Xlint:all', - '-Xlint:-serial', - '-Xlint:-deprecation', + tasks.withType { + options.compilerArgs.addAll( + listOf( + "-Xlint:all", + "-Xlint:-serial", + "-Xlint:-deprecation", // espresso-core classes say they're compiled with 51.0 but contain 52.0 attributes. // warning: [classfile] MethodParameters attribute introduced in version 52.0 class files is ignored in version 51.0 class files - // '-Werror' - ] + // "-Werror" + ) + ) } - tasks.withType(Test).configureEach { + tasks.withType { testLogging { - exceptionFormat 'FULL' - showCauses true - showExceptions true - showStackTraces true + exceptionFormat = TestExceptionFormat.FULL + showCauses = true + showExceptions = true + showStackTraces = true } } - detekt { - config = rootProject.files('config/detekt-config.yml') + extensions.configure { + config = rootProject.files("config/detekt-config.yml") parallel = true reports { xml.enabled = false @@ -96,30 +100,30 @@ subprojects { } // Config shared for subprojects except leakcanary-deobfuscation-gradle-plugin -configure(subprojects.findAll { - !(["leakcanary-deobfuscation-gradle-plugin"].contains(it.name)) +configure(subprojects.filter { + it.name !in listOf("leakcanary-deobfuscation-gradle-plugin") }) { - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach { + tasks.withType { kotlinOptions { - jvmTarget = '1.8' + jvmTarget = "1.8" } } } // Config shared for subprojects except apps -configure(subprojects.findAll { - !(["leakcanary-app", "leakcanary-android-sample"].contains(it.name)) +configure(subprojects.filter { + it.name !in listOf("leakcanary-app", "leakcanary-android-sample") }) { // Note: to skip Dokka on some projects we could add it individually to projects we actually // want. - apply plugin: 'org.jetbrains.dokka' - group = GROUP - version = VERSION_NAME + apply(plugin = "org.jetbrains.dokka") + group = property("GROUP").toString() + version = property("VERSION_NAME").toString() - tasks.withType(DokkaTask.class).configureEach { + tasks.withType { dokkaSourceSets.configureEach { reportUndocumented.set(false) - displayName.set(null) + displayName.set(null as String?) platform.set(org.jetbrains.dokka.Platform.jvm) perPackageOption { @@ -134,16 +138,16 @@ configure(subprojects.findAll { } skipDeprecated.set(true) externalDocumentationLink { - url.set(new URL("https://square.github.io/okio/2.x/okio/")) + url.set(URL("https://square.github.io/okio/2.x/okio/")) } externalDocumentationLink { - url.set(new URL("https://square.github.io/moshi/1.x/moshi/")) + url.set(URL("https://square.github.io/moshi/1.x/moshi/")) } } } pluginManager.withPlugin("com.vanniktech.maven.publish") { - mavenPublishing { + extensions.configure { publishToMavenCentral(SonatypeHost.S01) signAllPublications() } @@ -152,13 +156,13 @@ configure(subprojects.findAll { //Copies git hooks from /hooks folder into .git; currently used to run Detekt during push //Git hook installation -tasks.register("installGitHooks", Copy) { - from new File(rootProject.rootDir, 'config/hooks') - into { new File(rootProject.rootDir, '.git/hooks') } - fileMode 0777 //Make files executable +tasks.register("installGitHooks") { + from(File(rootProject.rootDir, "config/hooks")) + into({ File(rootProject.rootDir, ".git/hooks") }) + fileMode = "0777".toInt(8) // Make files executable } -tasks.register("siteDokka", Copy) { +tasks.register("siteDokka") { description = "Generate dokka Github-flavored Markdown for the documentation site." group = "documentation" dependsOn(":dokkaGfmCollector") @@ -169,11 +173,11 @@ tasks.register("siteDokka", Copy) { from(layout.buildDirectory.dir("dokka/gfmCollector/leakcanary-repo")) // For whatever reason Dokka doesn't want to ignore the packages we told it to ignore. // Fine, we'll just ignore it here. - exclude '**/com.example.leakcanary/**' + exclude("**/com.example.leakcanary/**") into(rootProject.file("docs/api")) filter { line -> // Dokka adds [main]\ and [main]
everywhere, this just removes it. - line.replaceAll("\\[main\\]\\\\", "").replaceAll("\\[main\\]
", "") + line.replace("\\[main\\]\\\\", "").replace("\\[main\\]
", "") } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 43265b80bf..9cd723adac 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -15,11 +15,14 @@ [versions] # We would like to use Kotlin recent language features but keep Kotlin 1.3 library APIs # The benefit is that depending clients do not have to upgrade to Kotlin 1.4 +compose = "1.4.3" kotlin = "1.8.21" coroutines = "1.7.3" androidXTest = "1.1.0" androidXJunit = "1.1.3" workManager = "2.7.0" +androidMinSdk = "14" +androidCompileSdk = "34" [libraries] gradlePlugin-android = { module = "com.android.tools.build:gradle", version = "8.0.0" } diff --git a/leakcanary/leakcanary-android-core/build.gradle.kts b/leakcanary/leakcanary-android-core/build.gradle.kts index c9120750ea..0b20c6c37d 100644 --- a/leakcanary/leakcanary-android-core/build.gradle.kts +++ b/leakcanary/leakcanary-android-core/build.gradle.kts @@ -1,3 +1,5 @@ +import java.io.InputStreamReader + plugins { id("com.android.library") id("org.jetbrains.kotlin.android") @@ -5,55 +7,60 @@ plugins { } dependencies { - api projects.shark.sharkAndroid - api projects.objectWatcher.objectWatcherAndroidCore - api projects.objectWatcher.objectWatcherAndroidAndroidx - api projects.leakcanary.leakcanaryAndroidUtils - implementation libs.kotlin.stdlib + api(projects.shark.sharkAndroid) + api(projects.objectWatcher.objectWatcherAndroidCore) + api(projects.objectWatcher.objectWatcherAndroidAndroidx) + api(projects.leakcanary.leakcanaryAndroidUtils) + implementation(libs.kotlin.stdlib) // Optional dependency - compileOnly libs.androidX.work.runtime - compileOnly libs.androidX.work.multiprocess + compileOnly(libs.androidX.work.runtime) + compileOnly(libs.androidX.work.multiprocess) - testImplementation libs.assertjCore - testImplementation libs.junit - testImplementation libs.kotlin.reflect - testImplementation libs.mockito - testImplementation libs.mockitoKotlin - androidTestImplementation libs.androidX.test.espresso - androidTestImplementation libs.androidX.test.rules - androidTestImplementation libs.androidX.test.runner - androidTestImplementation libs.assertjCore - androidTestImplementation projects.shark.sharkHprofTest - androidTestUtil libs.androidX.test.orchestrator + testImplementation(libs.assertjCore) + testImplementation(libs.junit) + testImplementation(libs.kotlin.reflect) + testImplementation(libs.mockito) + testImplementation(libs.mockitoKotlin) + androidTestImplementation(libs.androidX.test.espresso) + androidTestImplementation(libs.androidX.test.rules) + androidTestImplementation(libs.androidX.test.runner) + androidTestImplementation(libs.assertjCore) + androidTestImplementation(projects.shark.sharkHprofTest) + androidTestUtil(libs.androidX.test.orchestrator) } -def gitSha() { - return 'git rev-parse --short HEAD'.execute().text.trim() +fun gitSha(): String { + val process = ProcessBuilder("git", "rev-parse", "--short", "HEAD").start() + return InputStreamReader(process.inputStream).readText().trim() } android { - resourcePrefix 'leak_canary_' - compileSdk versions.compileSdk + resourcePrefix = "leak_canary_" + compileSdk = libs.versions.androidCompileSdk.get().toInt() defaultConfig { - minSdk versions.minSdk + minSdk = libs.versions.androidMinSdk.get().toInt() // Avoid DeprecatedTargetSdkVersionDialog during UI tests - targetSdk versions.compileSdk - buildConfigField "String", "LIBRARY_VERSION", "\"${rootProject.ext.VERSION_NAME}\"" - buildConfigField "String", "GIT_SHA", "\"${gitSha()}\"" - consumerProguardFiles 'consumer-proguard-rules.pro' - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + targetSdk = libs.versions.androidCompileSdk.get().toInt() + buildConfigField("String", "LIBRARY_VERSION", "\"${rootProject.property("VERSION_NAME")}\"") + buildConfigField("String", "GIT_SHA", "\"${gitSha()}\"") + consumerProguardFiles("consumer-proguard-rules.pro") + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - testInstrumentationRunnerArguments clearPackageData: 'true' + testInstrumentationRunnerArguments( + mapOf( + "clearPackageData" to "true", + ) + ) testOptions { - execution 'ANDROIDX_TEST_ORCHESTRATOR' + execution = "ANDROIDX_TEST_ORCHESTRATOR" } } - namespace 'com.squareup.leakcanary.core' - testNamespace 'com.squareup.leakcanary.core.test' + namespace = "com.squareup.leakcanary.core" + testNamespace = "com.squareup.leakcanary.core.test" lint { - checkOnly 'Interoperability' - disable 'GoogleAppIndexingWarning' - error 'ObsoleteSdkInt' + checkOnly += "Interoperability" + disable += "GoogleAppIndexingWarning" + error += "ObsoleteSdkInt" } } diff --git a/leakcanary/leakcanary-android-instrumentation/build.gradle.kts b/leakcanary/leakcanary-android-instrumentation/build.gradle.kts index 50539d57b2..6eaddf1be3 100644 --- a/leakcanary/leakcanary-android-instrumentation/build.gradle.kts +++ b/leakcanary/leakcanary-android-instrumentation/build.gradle.kts @@ -5,40 +5,40 @@ plugins { } dependencies { - api projects.leakcanary.leakcanaryAndroidCore - api projects.leakcanary.leakcanaryAndroidTest - api projects.leakcanary.leakcanaryTestCore - api projects.shark.sharkAndroid + api(projects.leakcanary.leakcanaryAndroidCore) + api(projects.leakcanary.leakcanaryAndroidTest) + api(projects.leakcanary.leakcanaryTestCore) + api(projects.shark.sharkAndroid) - implementation libs.androidX.test.runner - implementation libs.kotlin.stdlib + implementation(libs.androidX.test.runner) + implementation(libs.kotlin.stdlib) // AppWatcher auto installer for running tests - androidTestImplementation projects.objectWatcher.objectWatcherAndroid + androidTestImplementation(projects.objectWatcher.objectWatcherAndroid) // Plumber auto installer for running tests - androidTestImplementation projects.plumber.plumberAndroid - androidTestImplementation libs.androidX.multidex - androidTestImplementation libs.androidX.test.core - androidTestImplementation libs.androidX.test.espresso - androidTestImplementation libs.androidX.test.rules - androidTestImplementation libs.androidX.fragment - androidTestImplementation libs.assertjCore + androidTestImplementation(projects.plumber.plumberAndroid) + androidTestImplementation(libs.androidX.multidex) + androidTestImplementation(libs.androidX.test.core) + androidTestImplementation(libs.androidX.test.espresso) + androidTestImplementation(libs.androidX.test.rules) + androidTestImplementation(libs.androidX.fragment) + androidTestImplementation(libs.assertjCore) } android { - compileSdk versions.compileSdk + compileSdk = libs.versions.androidCompileSdk.get().toInt() defaultConfig { - targetSdk versions.compileSdk - minSdk versions.minSdk - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - multiDexEnabled true + targetSdk = libs.versions.androidCompileSdk.get().toInt() + minSdk = libs.versions.androidMinSdk.get().toInt() + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + multiDexEnabled = true } buildFeatures.buildConfig = false - namespace 'com.squareup.leakcanary.instrumentation' - testNamespace 'com.squareup.leakcanary.instrumentation.test' + namespace = "com.squareup.leakcanary.instrumentation" + testNamespace = "com.squareup.leakcanary.instrumentation.test" lint { - checkOnly 'Interoperability' - disable 'GoogleAppIndexingWarning' - ignore 'InvalidPackage' + checkOnly += "Interoperability" + disable += "GoogleAppIndexingWarning" + ignore += "InvalidPackage" } } diff --git a/leakcanary/leakcanary-android-process/build.gradle.kts b/leakcanary/leakcanary-android-process/build.gradle.kts index 674d961f96..1e79009750 100644 --- a/leakcanary/leakcanary-android-process/build.gradle.kts +++ b/leakcanary/leakcanary-android-process/build.gradle.kts @@ -5,23 +5,23 @@ plugins { } dependencies { - api projects.shark.sharkLog - api projects.objectWatcher.objectWatcherAndroidCore + api(projects.shark.sharkLog) + api(projects.objectWatcher.objectWatcherAndroidCore) - implementation libs.kotlin.stdlib - implementation libs.androidX.work.multiprocess + implementation(libs.kotlin.stdlib) + implementation(libs.androidX.work.multiprocess) } android { - compileSdk versions.compileSdk + compileSdk = libs.versions.androidCompileSdk.get().toInt() defaultConfig { - minSdk versions.minSdk + minSdk = libs.versions.androidMinSdk.get().toInt() } buildFeatures.buildConfig = false - namespace 'com.squareup.leakcanary' + namespace = "com.squareup.leakcanary" lint { - checkOnly 'Interoperability' - disable 'GoogleAppIndexingWarning' - ignore 'InvalidPackage' + checkOnly += "Interoperability" + disable += "GoogleAppIndexingWarning" + ignore += "InvalidPackage" } } diff --git a/leakcanary/leakcanary-android-release/build.gradle.kts b/leakcanary/leakcanary-android-release/build.gradle.kts index e630558b47..6f9ce35d2c 100644 --- a/leakcanary/leakcanary-android-release/build.gradle.kts +++ b/leakcanary/leakcanary-android-release/build.gradle.kts @@ -1,3 +1,5 @@ +import java.io.InputStreamReader + plugins { id("com.android.library") id("org.jetbrains.kotlin.android") @@ -5,30 +7,31 @@ plugins { } dependencies { - api projects.shark.sharkAndroid - api projects.leakcanary.leakcanaryAndroidUtils + api(projects.shark.sharkAndroid) + api(projects.leakcanary.leakcanaryAndroidUtils) - implementation libs.kotlin.stdlib - implementation libs.okio2 + implementation(libs.kotlin.stdlib) + implementation(libs.okio2) } -def gitSha() { - return 'git rev-parse --short HEAD'.execute().text.trim() +fun gitSha(): String { + val process = ProcessBuilder("git", "rev-parse", "--short", "HEAD").start() + return InputStreamReader(process.inputStream).readText().trim() } android { - resourcePrefix 'leak_canary_' - compileSdk versions.compileSdk + resourcePrefix = "leak_canary_" + compileSdk = libs.versions.androidCompileSdk.get().toInt() defaultConfig { - minSdk 16 - buildConfigField "String", "LIBRARY_VERSION", "\"${rootProject.ext.VERSION_NAME}\"" - buildConfigField "String", "GIT_SHA", "\"${gitSha()}\"" - consumerProguardFiles 'consumer-proguard-rules.pro' + minSdk = 16 + buildConfigField("String", "LIBRARY_VERSION", "\"${rootProject.property("VERSION_NAME")}\"") + buildConfigField("String", "GIT_SHA", "\"${gitSha()}\"") + consumerProguardFiles("consumer-proguard-rules.pro") } - namespace 'com.squareup.leakcanary.release' + namespace = "com.squareup.leakcanary.release" lint { - checkOnly 'Interoperability' - disable 'GoogleAppIndexingWarning' - error 'ObsoleteSdkInt' + checkOnly += "Interoperability" + disable += "GoogleAppIndexingWarning" + error += "ObsoleteSdkInt" } } diff --git a/leakcanary/leakcanary-android-startup/build.gradle.kts b/leakcanary/leakcanary-android-startup/build.gradle.kts index c39f402f28..a3783ac8a7 100644 --- a/leakcanary/leakcanary-android-startup/build.gradle.kts +++ b/leakcanary/leakcanary-android-startup/build.gradle.kts @@ -5,23 +5,23 @@ plugins { } dependencies { - api projects.leakcanary.leakcanaryAndroidCore + api(projects.leakcanary.leakcanaryAndroidCore) // AppWatcher AndroidX Startup installer - implementation projects.objectWatcher.objectWatcherAndroidStartup + implementation(projects.objectWatcher.objectWatcherAndroidStartup) // Plumber AndroidX Startup installer - implementation projects.plumber.plumberAndroidStartup + implementation(projects.plumber.plumberAndroidStartup) } android { - compileSdk versions.compileSdk + compileSdk = libs.versions.androidCompileSdk.get().toInt() defaultConfig { - minSdk versions.minSdk + minSdk = libs.versions.androidMinSdk.get().toInt() } buildFeatures.buildConfig = false - namespace 'com.squareup.leakcanary.startup' + namespace = "com.squareup.leakcanary.startup" lint { - checkOnly 'Interoperability' - disable 'GoogleAppIndexingWarning' - ignore 'InvalidPackage' + checkOnly += "Interoperability" + disable += "GoogleAppIndexingWarning" + ignore += "InvalidPackage" } } diff --git a/leakcanary/leakcanary-android-test/build.gradle.kts b/leakcanary/leakcanary-android-test/build.gradle.kts index e921acc89e..8fb501aa4b 100644 --- a/leakcanary/leakcanary-android-test/build.gradle.kts +++ b/leakcanary/leakcanary-android-test/build.gradle.kts @@ -5,28 +5,28 @@ plugins { } dependencies { - api projects.leakcanary.leakcanaryCore - api projects.leakcanary.leakcanaryAndroidUtils - api projects.leakcanary.leakcanaryTestCore - api projects.shark.sharkAndroid + api(projects.leakcanary.leakcanaryCore) + api(projects.leakcanary.leakcanaryAndroidUtils) + api(projects.leakcanary.leakcanaryTestCore) + api(projects.shark.sharkAndroid) - implementation libs.androidX.test.runner + implementation(libs.androidX.test.runner) - androidTestImplementation libs.androidX.multidex - androidTestImplementation libs.androidX.test.core - androidTestImplementation libs.androidX.test.runner - androidTestImplementation libs.assertjCore + androidTestImplementation(libs.androidX.multidex) + androidTestImplementation(libs.androidX.test.core) + androidTestImplementation(libs.androidX.test.runner) + androidTestImplementation(libs.assertjCore) } android { - compileSdk versions.compileSdk + compileSdk = libs.versions.androidCompileSdk.get().toInt() defaultConfig { - targetSdk versions.compileSdk - minSdk versions.minSdk - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - multiDexEnabled true + targetSdk = libs.versions.androidCompileSdk.get().toInt() + minSdk = libs.versions.androidMinSdk.get().toInt() + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + multiDexEnabled = true } buildFeatures.buildConfig = false - namespace 'com.squareup.leakcanary.android.test' - testNamespace 'com.squareup.leakcanary.android.test.test' + namespace = "com.squareup.leakcanary.android.test" + testNamespace = "com.squareup.leakcanary.android.test.test" } diff --git a/leakcanary/leakcanary-android-uiautomator/build.gradle.kts b/leakcanary/leakcanary-android-uiautomator/build.gradle.kts index 00279f74e7..ebf73980b8 100644 --- a/leakcanary/leakcanary-android-uiautomator/build.gradle.kts +++ b/leakcanary/leakcanary-android-uiautomator/build.gradle.kts @@ -5,20 +5,20 @@ plugins { } dependencies { - api projects.leakcanary.leakcanaryCore - api projects.leakcanary.leakcanaryTestCore - api projects.shark.sharkAndroid - api libs.androidX.test.uiautomator + api(projects.leakcanary.leakcanaryCore) + api(projects.leakcanary.leakcanaryTestCore) + api(projects.shark.sharkAndroid) + api(libs.androidX.test.uiautomator) - implementation libs.androidX.test.monitor + implementation(libs.androidX.test.monitor) } android { - compileSdk versions.compileSdk + compileSdk = libs.versions.androidCompileSdk.get().toInt() defaultConfig { - targetSdk versions.compileSdk - minSdk 18 + targetSdk = libs.versions.androidCompileSdk.get().toInt() + minSdk = 18 } buildFeatures.buildConfig = false - namespace 'com.squareup.leakcanary.android.uiautomator' + namespace = "com.squareup.leakcanary.android.uiautomator" } diff --git a/leakcanary/leakcanary-android-utils/build.gradle.kts b/leakcanary/leakcanary-android-utils/build.gradle.kts index 548972b99d..6a811cdeee 100644 --- a/leakcanary/leakcanary-android-utils/build.gradle.kts +++ b/leakcanary/leakcanary-android-utils/build.gradle.kts @@ -5,22 +5,22 @@ plugins { } dependencies { - api projects.leakcanary.leakcanaryCore - api projects.shark.sharkLog + api(projects.leakcanary.leakcanaryCore) + api(projects.shark.sharkLog) - implementation libs.kotlin.stdlib + implementation(libs.kotlin.stdlib) } android { - compileSdk versions.compileSdk + compileSdk = libs.versions.androidCompileSdk.get().toInt() defaultConfig { - minSdk versions.minSdk + minSdk = libs.versions.androidMinSdk.get().toInt() } buildFeatures.buildConfig = false - namespace 'com.squareup.leakcanary.utils' + namespace = "com.squareup.leakcanary.utils" lint { - checkOnly 'Interoperability' - disable 'GoogleAppIndexingWarning' - error 'ObsoleteSdkInt' + checkOnly += "Interoperability" + disable += "GoogleAppIndexingWarning" + error += "ObsoleteSdkInt" } } diff --git a/leakcanary/leakcanary-android/build.gradle.kts b/leakcanary/leakcanary-android/build.gradle.kts index 87fb7b1cde..9205655225 100644 --- a/leakcanary/leakcanary-android/build.gradle.kts +++ b/leakcanary/leakcanary-android/build.gradle.kts @@ -5,31 +5,31 @@ plugins { } dependencies { - api projects.leakcanary.leakcanaryAndroidCore + api(projects.leakcanary.leakcanaryAndroidCore) // AppWatcher auto installer - api projects.objectWatcher.objectWatcherAndroid + api(projects.objectWatcher.objectWatcherAndroid) // Plumber auto installer - implementation projects.plumber.plumberAndroid - implementation libs.kotlin.stdlib + implementation(projects.plumber.plumberAndroid) + implementation(libs.kotlin.stdlib) - androidTestImplementation libs.androidX.test.espresso - androidTestImplementation libs.androidX.test.rules - androidTestImplementation libs.androidX.test.runner - androidTestImplementation libs.assertjCore - androidTestImplementation projects.shark.sharkHprofTest + androidTestImplementation(libs.androidX.test.espresso) + androidTestImplementation(libs.androidX.test.rules) + androidTestImplementation(libs.androidX.test.runner) + androidTestImplementation(libs.assertjCore) + androidTestImplementation(projects.shark.sharkHprofTest) } android { - compileSdk versions.compileSdk + compileSdk = libs.versions.androidCompileSdk.get().toInt() defaultConfig { - minSdk versions.minSdk - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + minSdk = libs.versions.androidMinSdk.get().toInt() + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } buildFeatures.buildConfig = false - namespace 'com.squareup.leakcanary' + namespace = "com.squareup.leakcanary" lint { - checkOnly 'Interoperability' - disable 'GoogleAppIndexingWarning' - ignore 'InvalidPackage' + checkOnly += "Interoperability" + disable += "GoogleAppIndexingWarning" + ignore += "InvalidPackage" } } diff --git a/leakcanary/leakcanary-app-aidl/build.gradle.kts b/leakcanary/leakcanary-app-aidl/build.gradle.kts index f711b55126..67ce3ea8ba 100644 --- a/leakcanary/leakcanary-app-aidl/build.gradle.kts +++ b/leakcanary/leakcanary-app-aidl/build.gradle.kts @@ -5,23 +5,23 @@ plugins { } dependencies { - implementation libs.kotlin.stdlib - implementation projects.shark.shark + implementation(libs.kotlin.stdlib) + implementation(projects.shark.shark) } android { - compileSdk versions.compileSdk + compileSdk = libs.versions.androidCompileSdk.get().toInt() defaultConfig { - minSdk versions.minSdk + minSdk = libs.versions.androidMinSdk.get().toInt() } buildFeatures { - aidl true + aidl = true } buildFeatures.buildConfig = false - namespace 'com.squareup.leakcanary.app.aidl' + namespace = "com.squareup.leakcanary.app.aidl" lint { - checkOnly 'Interoperability' - disable 'GoogleAppIndexingWarning' - ignore 'InvalidPackage' + checkOnly += "Interoperability" + disable += "GoogleAppIndexingWarning" + ignore += "InvalidPackage" } } diff --git a/leakcanary/leakcanary-app-service/build.gradle.kts b/leakcanary/leakcanary-app-service/build.gradle.kts index ccf54c1dbd..b013c7dbd9 100644 --- a/leakcanary/leakcanary-app-service/build.gradle.kts +++ b/leakcanary/leakcanary-app-service/build.gradle.kts @@ -5,26 +5,26 @@ plugins { } dependencies { - implementation libs.kotlin.stdlib + implementation(libs.kotlin.stdlib) } android { - compileSdk versions.compileSdk + compileSdk = libs.versions.androidCompileSdk.get().toInt() defaultConfig { - minSdk versions.minSdk + minSdk = libs.versions.androidMinSdk.get().toInt() } buildFeatures.buildConfig = false - namespace 'com.squareup.leakcanary.app.service' + namespace = "com.squareup.leakcanary.app.service" lint { - checkOnly 'Interoperability' - disable 'GoogleAppIndexingWarning' - ignore 'InvalidPackage' + checkOnly += "Interoperability" + disable += "GoogleAppIndexingWarning" + ignore += "InvalidPackage" } } dependencies { - implementation projects.leakcanary.leakcanaryAppAidl - implementation projects.leakcanary.leakcanaryAndroidCore - implementation projects.shark.shark - implementation projects.shark.sharkAndroid + implementation(projects.leakcanary.leakcanaryAppAidl) + implementation(projects.leakcanary.leakcanaryAndroidCore) + implementation(projects.shark.shark) + implementation(projects.shark.sharkAndroid) } diff --git a/leakcanary/leakcanary-app/build.gradle.kts b/leakcanary/leakcanary-app/build.gradle.kts index ad4ece3b1b..63884199da 100644 --- a/leakcanary/leakcanary-app/build.gradle.kts +++ b/leakcanary/leakcanary-app/build.gradle.kts @@ -1,3 +1,5 @@ +import java.io.InputStreamReader + plugins { id("com.android.application") id("org.jetbrains.kotlin.android") @@ -7,98 +9,96 @@ plugins { id("kotlin-parcelize") } -ext { - compose_version = '1.4.3' -} - -def gitSha() { - return 'git rev-parse --short HEAD'.execute().text.trim() +fun gitSha(): String { + val process = ProcessBuilder("git", "rev-parse", "--short", "HEAD").start() + return InputStreamReader(process.inputStream).readText().trim() } android { - namespace 'org.leakcanary' - compileSdk versions.compileSdk + namespace = "org.leakcanary" + compileSdk = libs.versions.androidCompileSdk.get().toInt() defaultConfig { - applicationId "org.leakcanary" + applicationId = "org.leakcanary" // 21 required by Compose - minSdk 21 - targetSdk versions.compileSdk + minSdk = 21 + targetSdk = libs.versions.androidCompileSdk.get().toInt() - buildConfigField "String", "GIT_SHA", "\"${gitSha()}\"" + buildConfigField("String", "GIT_SHA", "\"${gitSha()}\"") // TODO Figure out versioning scheme. Should this follow LeakCanary releases? - versionCode 1 - versionName "1.0" + versionCode = 1 + versionName = "1.0" - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" vectorDrawables { - useSupportLibrary true + useSupportLibrary = true } } buildTypes { - debug + debug { + } release { // TODO Enable R8 minification // minifyEnabled true - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") // TODO Proper signing config - signingConfig signingConfigs.debug + signingConfig = signingConfigs["debug"] } } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 } kotlinOptions { - jvmTarget = '1.8' + jvmTarget = "1.8" } buildFeatures { - compose true + compose = true } composeOptions { - kotlinCompilerExtensionVersion '1.4.7' + kotlinCompilerExtensionVersion = "1.4.7" } packagingOptions { resources { - excludes += '/META-INF/{AL2.0,LGPL2.1}' + excludes += "/META-INF/{AL2.0,LGPL2.1}" } } } dependencies { - implementation projects.leakcanary.leakcanaryAppAidl + implementation(projects.leakcanary.leakcanaryAppAidl) // TODO Move these to ./gradle/libs/versions/toml - implementation "app.cash.sqldelight:android-driver:2.0.0-alpha05" - implementation "app.cash.sqldelight:coroutines-extensions:2.0.0-alpha05" - implementation 'androidx.core:core-ktx:1.9.0' - implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1' - implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:2.5.1' - implementation 'androidx.activity:activity-compose:1.5.1' - implementation "androidx.compose.ui:ui:$compose_version" - implementation "androidx.compose.ui:ui-tooling-preview:$compose_version" - implementation 'androidx.compose.material3:material3:1.0.0-beta02' - implementation 'androidx.sqlite:sqlite-framework:2.2.0' - implementation 'me.saket.extendedspans:extendedspans:1.3.0' - testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test.ext:junit:1.1.3' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' - androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version" - debugImplementation "androidx.compose.ui:ui-tooling:$compose_version" - debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version" + implementation("app.cash.sqldelight:android-driver:2.0.0-alpha05") + implementation("app.cash.sqldelight:coroutines-extensions:2.0.0-alpha05") + implementation("androidx.core:core-ktx:1.9.0") + implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.5.1") + implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.5.1") + implementation("androidx.activity:activity-compose:1.5.1") + implementation("androidx.compose.ui:ui:${libs.versions.compose.get()}") + implementation("androidx.compose.ui:ui-tooling-preview:${libs.versions.compose.get()}") + implementation("androidx.compose.material3:material3:1.0.0-beta02") + implementation("androidx.sqlite:sqlite-framework:2.2.0") + implementation("me.saket.extendedspans:extendedspans:1.3.0") + testImplementation("junit:junit:4.13.2") + androidTestImplementation("androidx.test.ext:junit:1.1.3") + androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0") + androidTestImplementation("androidx.compose.ui:ui-test-junit4:${libs.versions.compose.get()}") + debugImplementation("androidx.compose.ui:ui-tooling:${libs.versions.compose.get()}") + debugImplementation("androidx.compose.ui:ui-test-manifest:${libs.versions.compose.get()}") // TODO Split out what's included in debug vs the subset for release - implementation projects.leakcanary.leakcanaryAndroid - implementation 'com.google.dagger:hilt-android:2.43.2' - implementation libs.okio2 - kapt 'com.google.dagger:hilt-compiler:2.43.2' + implementation(projects.leakcanary.leakcanaryAndroid) + implementation("com.google.dagger:hilt-android:2.43.2") + implementation(libs.okio2) + kapt("com.google.dagger:hilt-compiler:2.43.2") } kapt { - correctErrorTypes true + correctErrorTypes = true } diff --git a/leakcanary/leakcanary-core/build.gradle.kts b/leakcanary/leakcanary-core/build.gradle.kts index 35ba8a25f9..063abc2aa5 100644 --- a/leakcanary/leakcanary-core/build.gradle.kts +++ b/leakcanary/leakcanary-core/build.gradle.kts @@ -3,15 +3,17 @@ plugins { id("com.vanniktech.maven.publish") } -sourceCompatibility = JavaVersion.VERSION_1_8 -targetCompatibility = JavaVersion.VERSION_1_8 +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} dependencies { - api projects.leakcanary.leakcanaryGc - api projects.shark.shark - implementation libs.okio2 + api(projects.leakcanary.leakcanaryGc) + api(projects.shark.shark) + implementation(libs.okio2) - testImplementation libs.assertjCore - testImplementation libs.junit - testImplementation projects.shark.sharkHprofTest + testImplementation(libs.assertjCore) + testImplementation(libs.junit) + testImplementation(projects.shark.sharkHprofTest) } diff --git a/leakcanary/leakcanary-deobfuscation-gradle-plugin/build.gradle.kts b/leakcanary/leakcanary-deobfuscation-gradle-plugin/build.gradle.kts index dcebe742b5..65b2b8c0a3 100644 --- a/leakcanary/leakcanary-deobfuscation-gradle-plugin/build.gradle.kts +++ b/leakcanary/leakcanary-deobfuscation-gradle-plugin/build.gradle.kts @@ -1,3 +1,5 @@ +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + plugins { id("org.jetbrains.kotlin.jvm") id("java-gradle-plugin") @@ -6,34 +8,38 @@ plugins { gradlePlugin { plugins { - leakCanary { - id = 'com.squareup.leakcanary.deobfuscation' + register("leakCanary") { + id = "com.squareup.leakcanary.deobfuscation" implementationClass = - 'com.squareup.leakcanary.deobfuscation.LeakCanaryLeakDeobfuscationPlugin' + "com.squareup.leakcanary.deobfuscation.LeakCanaryLeakDeobfuscationPlugin" } } sourceSets { - test.java.srcDirs += 'src/test/test-project/src/main/java' + test { + java.srcDirs.add(file("src/test/test-project/src/main/java")) + } } } dependencies { - implementation libs.kotlin.stdlib - implementation libs.gradlePlugin.kotlin - implementation libs.gradlePlugin.android - compileOnly gradleApi() + implementation(libs.kotlin.stdlib) + implementation(libs.gradlePlugin.kotlin) + implementation(libs.gradlePlugin.android) + compileOnly(gradleApi()) - testImplementation libs.assertjCore - testImplementation libs.junit + testImplementation(libs.assertjCore) + testImplementation(libs.junit) } -sourceCompatibility = JavaVersion.VERSION_11 -targetCompatibility = JavaVersion.VERSION_11 +java { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 +} -tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach { - kotlinOptions { - jvmTarget = '11' - } +tasks.withType { + kotlinOptions { + jvmTarget = "11" + } } diff --git a/leakcanary/leakcanary-gc/build.gradle.kts b/leakcanary/leakcanary-gc/build.gradle.kts index 3ff8340897..1fe48b866d 100644 --- a/leakcanary/leakcanary-gc/build.gradle.kts +++ b/leakcanary/leakcanary-gc/build.gradle.kts @@ -3,9 +3,11 @@ plugins { id("com.vanniktech.maven.publish") } -sourceCompatibility = JavaVersion.VERSION_1_8 -targetCompatibility = JavaVersion.VERSION_1_8 +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} dependencies { - implementation libs.kotlin.stdlib + implementation(libs.kotlin.stdlib) } diff --git a/leakcanary/leakcanary-jvm-test/build.gradle.kts b/leakcanary/leakcanary-jvm-test/build.gradle.kts index b8bac03530..9096ca5253 100644 --- a/leakcanary/leakcanary-jvm-test/build.gradle.kts +++ b/leakcanary/leakcanary-jvm-test/build.gradle.kts @@ -3,14 +3,16 @@ plugins { id("com.vanniktech.maven.publish") } -sourceCompatibility = JavaVersion.VERSION_1_8 -targetCompatibility = JavaVersion.VERSION_1_8 +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} dependencies { - api projects.leakcanary.leakcanaryTestCore - api projects.shark.shark + api(projects.leakcanary.leakcanaryTestCore) + api(projects.shark.shark) - testImplementation libs.assertjCore - testImplementation libs.junit - testImplementation projects.shark.sharkHprofTest + testImplementation(libs.assertjCore) + testImplementation(libs.junit) + testImplementation(projects.shark.sharkHprofTest) } diff --git a/leakcanary/leakcanary-test-core/build.gradle.kts b/leakcanary/leakcanary-test-core/build.gradle.kts index 588a44442c..706be704e3 100644 --- a/leakcanary/leakcanary-test-core/build.gradle.kts +++ b/leakcanary/leakcanary-test-core/build.gradle.kts @@ -3,13 +3,15 @@ plugins { id("com.vanniktech.maven.publish") } -sourceCompatibility = JavaVersion.VERSION_1_8 -targetCompatibility = JavaVersion.VERSION_1_8 +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} dependencies { - api projects.leakcanary.leakcanaryCore - api projects.shark.shark - api libs.junit + api(projects.leakcanary.leakcanaryCore) + api(projects.shark.shark) + api(libs.junit) - testImplementation libs.assertjCore + testImplementation(libs.assertjCore) } diff --git a/object-watcher/object-watcher-android-androidx/build.gradle.kts b/object-watcher/object-watcher-android-androidx/build.gradle.kts index 4ce89e9c67..80343c1663 100644 --- a/object-watcher/object-watcher-android-androidx/build.gradle.kts +++ b/object-watcher/object-watcher-android-androidx/build.gradle.kts @@ -5,24 +5,24 @@ plugins { } dependencies { - api projects.objectWatcher.objectWatcherAndroidCore + api(projects.objectWatcher.objectWatcherAndroidCore) - implementation libs.kotlin.stdlib + implementation(libs.kotlin.stdlib) // Optional dependency - compileOnly libs.androidX.fragment + compileOnly(libs.androidX.fragment) } android { - compileSdk versions.compileSdk + compileSdk = libs.versions.androidCompileSdk.get().toInt() defaultConfig { - minSdk versions.minSdk - consumerProguardFiles 'consumer-proguard-rules.pro' + minSdk = libs.versions.androidMinSdk.get().toInt() + consumerProguardFiles("consumer-proguard-rules.pro") } buildFeatures.buildConfig = false - namespace 'com.squareup.leakcanary.fragments.androidx' + namespace = "com.squareup.leakcanary.fragments.androidx" lint { - checkOnly 'Interoperability' - disable 'GoogleAppIndexingWarning' - error 'ObsoleteSdkInt' + checkOnly += "Interoperability" + disable += "GoogleAppIndexingWarning" + error += "ObsoleteSdkInt" } } diff --git a/object-watcher/object-watcher-android-core/build.gradle.kts b/object-watcher/object-watcher-android-core/build.gradle.kts index 5f782ef375..ce5c794d3d 100644 --- a/object-watcher/object-watcher-android-core/build.gradle.kts +++ b/object-watcher/object-watcher-android-core/build.gradle.kts @@ -5,32 +5,32 @@ plugins { } dependencies { - api projects.objectWatcher.objectWatcher - api projects.leakcanary.leakcanaryAndroidUtils + api(projects.objectWatcher.objectWatcher) + api(projects.leakcanary.leakcanaryAndroidUtils) - implementation libs.curtains - implementation libs.kotlin.stdlib + implementation(libs.curtains) + implementation(libs.kotlin.stdlib) - testImplementation libs.assertjCore - testImplementation libs.junit - testImplementation libs.kotlin.reflect + testImplementation(libs.assertjCore) + testImplementation(libs.junit) + testImplementation(libs.kotlin.reflect) } android { - resourcePrefix 'leak_canary_watcher_' - compileSdk versions.compileSdk + resourcePrefix = "leak_canary_watcher_" + compileSdk = libs.versions.androidCompileSdk.get().toInt() defaultConfig { - minSdk versions.minSdk - consumerProguardFiles 'consumer-proguard-rules.pro' + minSdk = libs.versions.androidMinSdk.get().toInt() + consumerProguardFiles("consumer-proguard-rules.pro") } buildFeatures { buildConfig = false } - namespace 'com.squareup.leakcanary.objectwatcher.core' + namespace = "com.squareup.leakcanary.objectwatcher.core" lint { - checkOnly 'Interoperability' - disable 'GoogleAppIndexingWarning' + checkOnly += "Interoperability" + disable += "GoogleAppIndexingWarning" } } diff --git a/object-watcher/object-watcher-android-startup/build.gradle.kts b/object-watcher/object-watcher-android-startup/build.gradle.kts index 73e37bb0d3..a3d4e2b6ed 100644 --- a/object-watcher/object-watcher-android-startup/build.gradle.kts +++ b/object-watcher/object-watcher-android-startup/build.gradle.kts @@ -5,22 +5,22 @@ plugins { } dependencies { - api projects.objectWatcher.objectWatcherAndroidCore + api(projects.objectWatcher.objectWatcherAndroidCore) - implementation libs.androidX.startup + implementation(libs.androidX.startup) } android { - resourcePrefix 'leak_canary_watcher_' - compileSdk versions.compileSdk + resourcePrefix = "leak_canary_watcher_" + compileSdk = libs.versions.androidCompileSdk.get().toInt() defaultConfig { - minSdk versions.minSdk + minSdk = libs.versions.androidMinSdk.get().toInt() } buildFeatures.buildConfig = false - namespace 'com.squareup.leakcanary.objectwatcher.startup' + namespace = "com.squareup.leakcanary.objectwatcher.startup" lint { - checkOnly 'Interoperability' - disable 'GoogleAppIndexingWarning' - error 'ObsoleteSdkInt' + checkOnly += "Interoperability" + disable += "GoogleAppIndexingWarning" + error += "ObsoleteSdkInt" } } diff --git a/object-watcher/object-watcher-android/build.gradle.kts b/object-watcher/object-watcher-android/build.gradle.kts index 3d0d009c4c..f861ae755c 100644 --- a/object-watcher/object-watcher-android/build.gradle.kts +++ b/object-watcher/object-watcher-android/build.gradle.kts @@ -5,24 +5,24 @@ plugins { } dependencies { - api projects.objectWatcher.objectWatcherAndroidCore + api(projects.objectWatcher.objectWatcherAndroidCore) } android { - resourcePrefix 'leak_canary_watcher_' - compileSdk versions.compileSdk + resourcePrefix = "leak_canary_watcher_" + compileSdk = libs.versions.androidCompileSdk.get().toInt() defaultConfig { - minSdk versions.minSdk - consumerProguardFiles 'consumer-proguard-rules.pro' + minSdk = libs.versions.androidMinSdk.get().toInt() + consumerProguardFiles("consumer-proguard-rules.pro") } buildFeatures { buildConfig = false } - namespace 'com.squareup.leakcanary.objectwatcher' + namespace = "com.squareup.leakcanary.objectwatcher" lint { - checkOnly 'Interoperability' - disable 'GoogleAppIndexingWarning' + checkOnly += "Interoperability" + disable += "GoogleAppIndexingWarning" } } diff --git a/object-watcher/object-watcher/build.gradle.kts b/object-watcher/object-watcher/build.gradle.kts index 938660413f..9d1921a430 100644 --- a/object-watcher/object-watcher/build.gradle.kts +++ b/object-watcher/object-watcher/build.gradle.kts @@ -3,14 +3,16 @@ plugins { id("com.vanniktech.maven.publish") } -sourceCompatibility = JavaVersion.VERSION_1_8 -targetCompatibility = JavaVersion.VERSION_1_8 +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} dependencies { - implementation libs.kotlin.stdlib - api projects.shark.sharkLog - api projects.leakcanary.leakcanaryGc + implementation(libs.kotlin.stdlib) + api(projects.shark.sharkLog) + api(projects.leakcanary.leakcanaryGc) - testImplementation libs.assertjCore - testImplementation libs.junit + testImplementation(libs.assertjCore) + testImplementation(libs.junit) } diff --git a/plumber/plumber-android-core/build.gradle.kts b/plumber/plumber-android-core/build.gradle.kts index b849e4e629..13e670ae50 100644 --- a/plumber/plumber-android-core/build.gradle.kts +++ b/plumber/plumber-android-core/build.gradle.kts @@ -5,27 +5,27 @@ plugins { } dependencies { - api projects.shark.sharkLog - api projects.leakcanary.leakcanaryAndroidUtils + api(projects.shark.sharkLog) + api(projects.leakcanary.leakcanaryAndroidUtils) - implementation libs.kotlin.stdlib - implementation libs.curtains + implementation(libs.kotlin.stdlib) + implementation(libs.curtains) // Optional dependency - compileOnly libs.androidX.fragment + compileOnly(libs.androidX.fragment) } android { - resourcePrefix 'leak_canary_plumber' - compileSdk versions.compileSdk + resourcePrefix = "leak_canary_plumber" + compileSdk = libs.versions.androidCompileSdk.get().toInt() defaultConfig { - minSdk versions.minSdk - consumerProguardFiles 'consumer-proguard-rules.pro' + minSdk = libs.versions.androidMinSdk.get().toInt() + consumerProguardFiles("consumer-proguard-rules.pro") } buildFeatures.buildConfig = false - namespace 'com.squareup.leakcanary.plumber.core' + namespace = "com.squareup.leakcanary.plumber.core" lint { - checkOnly 'Interoperability' - disable 'GoogleAppIndexingWarning' - error 'ObsoleteSdkInt' + checkOnly += "Interoperability" + disable += "GoogleAppIndexingWarning" + error += "ObsoleteSdkInt" } } diff --git a/plumber/plumber-android-startup/build.gradle.kts b/plumber/plumber-android-startup/build.gradle.kts index a7adca5454..b57fc23566 100644 --- a/plumber/plumber-android-startup/build.gradle.kts +++ b/plumber/plumber-android-startup/build.gradle.kts @@ -5,23 +5,23 @@ plugins { } dependencies { - api projects.plumber.plumberAndroidCore + api(projects.plumber.plumberAndroidCore) - implementation libs.kotlin.stdlib - implementation libs.androidX.startup + implementation(libs.kotlin.stdlib) + implementation(libs.androidX.startup) } android { - resourcePrefix 'leak_canary_plumber' - compileSdk versions.compileSdk + resourcePrefix = "leak_canary_plumber" + compileSdk = libs.versions.androidCompileSdk.get().toInt() defaultConfig { - minSdk versions.minSdk + minSdk = libs.versions.androidMinSdk.get().toInt() } buildFeatures.buildConfig = false - namespace 'com.squareup.leakcanary.plumber.startup' + namespace = "com.squareup.leakcanary.plumber.startup" lint { - checkOnly 'Interoperability' - disable 'GoogleAppIndexingWarning' - error 'ObsoleteSdkInt' + checkOnly += "Interoperability" + disable += "GoogleAppIndexingWarning" + error += "ObsoleteSdkInt" } } diff --git a/plumber/plumber-android/build.gradle.kts b/plumber/plumber-android/build.gradle.kts index d43f6838cb..350b1c3c4a 100644 --- a/plumber/plumber-android/build.gradle.kts +++ b/plumber/plumber-android/build.gradle.kts @@ -5,23 +5,23 @@ plugins { } dependencies { - api projects.plumber.plumberAndroidCore + api(projects.plumber.plumberAndroidCore) - implementation libs.kotlin.stdlib + implementation(libs.kotlin.stdlib) } android { - resourcePrefix 'leak_canary_plumber' - compileSdk versions.compileSdk + resourcePrefix = "leak_canary_plumber" + compileSdk = libs.versions.androidCompileSdk.get().toInt() defaultConfig { - minSdk versions.minSdk - consumerProguardFiles 'consumer-proguard-rules.pro' + minSdk = libs.versions.androidMinSdk.get().toInt() + consumerProguardFiles("consumer-proguard-rules.pro") } buildFeatures.buildConfig = false - namespace 'com.squareup.leakcanary.plumber' + namespace = "com.squareup.leakcanary.plumber" lint { - checkOnly 'Interoperability' - disable 'GoogleAppIndexingWarning' - error 'ObsoleteSdkInt' + checkOnly += "Interoperability" + disable += "GoogleAppIndexingWarning" + error += "ObsoleteSdkInt" } } diff --git a/samples/leakcanary-android-sample/build.gradle.kts b/samples/leakcanary-android-sample/build.gradle.kts index 442faea770..0c86817972 100644 --- a/samples/leakcanary-android-sample/build.gradle.kts +++ b/samples/leakcanary-android-sample/build.gradle.kts @@ -8,91 +8,92 @@ plugins { keeper { variantFilter { - setIgnore(!project.hasProperty('minify')) + setIgnore(!project.hasProperty("minify")) } } dependencies { - debugImplementation projects.leakcanary.leakcanaryAndroid - debugImplementation projects.leakcanary.leakcanaryAppService - // debugImplementation projects.leakcanary.leakcanaryAndroidStartup + debugImplementation(projects.leakcanary.leakcanaryAndroid) + debugImplementation(projects.leakcanary.leakcanaryAppService) + // debugImplementation(projects.leakcanary.leakcanaryAndroidStartup) // Uncomment to use the :leakcanary process - // debugImplementation projects.leakcanary.leakcanaryAndroidProcess - releaseImplementation projects.leakcanary.leakcanaryAndroidRelease + // debugImplementation(projects.leakcanary.leakcanaryAndroidProcess) + releaseImplementation(projects.leakcanary.leakcanaryAndroidRelease) // Optional - releaseImplementation projects.objectWatcher.objectWatcherAndroid + releaseImplementation(projects.objectWatcher.objectWatcherAndroid) - implementation libs.kotlin.stdlib + implementation(libs.kotlin.stdlib) // Uncomment to use WorkManager - // implementation libs.androidX.work.runtime + // implementation(libs.androidX.work.runtime) - testImplementation libs.junit - testImplementation libs.robolectric + testImplementation(libs.junit) + testImplementation(libs.robolectric) - androidTestImplementation projects.leakcanary.leakcanaryAndroidInstrumentation - androidTestImplementation libs.androidX.test.espresso - androidTestImplementation libs.androidX.test.rules - androidTestImplementation libs.androidX.test.runner - androidTestImplementation libs.androidX.test.junit - androidTestImplementation libs.androidX.test.junitKtx - androidTestUtil libs.androidX.test.orchestrator + androidTestImplementation(projects.leakcanary.leakcanaryAndroidInstrumentation) + androidTestImplementation(libs.androidX.test.espresso) + androidTestImplementation(libs.androidX.test.rules) + androidTestImplementation(libs.androidX.test.runner) + androidTestImplementation(libs.androidX.test.junit) + androidTestImplementation(libs.androidX.test.junitKtx) + androidTestUtil(libs.androidX.test.orchestrator) } android { - compileSdk versions.compileSdk + compileSdk = libs.versions.androidCompileSdk.get().toInt() compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 } defaultConfig { - applicationId "com.example.leakcanary" - minSdk 16 - targetSdk versions.compileSdk + applicationId = "com.example.leakcanary" + minSdk = 16 + targetSdk = libs.versions.androidCompileSdk.get().toInt() - versionCode 1 - versionName "1.0" + versionCode = 1 + versionName = "1.0" - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" // Run ./gradlew leakcanary-android-sample:connectedCheck -Porchestrator - if (project.hasProperty('orchestrator')) { - testInstrumentationRunnerArguments clearPackageData: 'true' + if (project.hasProperty("orchestrator")) { + testInstrumentationRunnerArguments(mapOf("clearPackageData" to "true")) testOptions { - execution 'ANDROIDX_TEST_ORCHESTRATOR' + execution = "ANDROIDX_TEST_ORCHESTRATOR" } } } buildTypes { // Build with ./gradlew leakcanary-android-sample:installDebug -Pminify - if (project.hasProperty('minify')) { + if (project.hasProperty("minify")) { debug { - minifyEnabled true - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt') + isMinifyEnabled = true + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt")) } } else { - debug + debug { + } } release { - signingConfig signingConfigs.debug + signingConfig = signingConfigs["debug"] } } dexOptions { - dexInProcess false + dexInProcess = false } testOptions { unitTests { - includeAndroidResources = true + isIncludeAndroidResources = true } } - namespace 'com.example.leakcanary' - testNamespace 'com.squareup.leakcanary.instrumentation.test' + namespace = "com.example.leakcanary" + testNamespace = "com.squareup.leakcanary.instrumentation.test" lint { - disable 'GoogleAppIndexingWarning' + disable += "GoogleAppIndexingWarning" } } diff --git a/shark/shark-android/build.gradle.kts b/shark/shark-android/build.gradle.kts index 5bc2c0a8d3..9ae207c9ae 100644 --- a/shark/shark-android/build.gradle.kts +++ b/shark/shark-android/build.gradle.kts @@ -3,20 +3,22 @@ plugins { id("com.vanniktech.maven.publish") } -sourceCompatibility = JavaVersion.VERSION_1_8 -targetCompatibility = JavaVersion.VERSION_1_8 +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} dependencies { - api projects.shark.shark + api(projects.shark.shark) - implementation libs.kotlin.stdlib + implementation(libs.kotlin.stdlib) - testImplementation libs.assertjCore - testImplementation libs.junit - testImplementation libs.kotlinStatistics - testImplementation libs.mockito - testImplementation libs.mockitoKotlin - testImplementation libs.okio2 - testImplementation projects.shark.sharkTest - testImplementation projects.shark.sharkHprofTest + testImplementation(libs.assertjCore) + testImplementation(libs.junit) + testImplementation(libs.kotlinStatistics) + testImplementation(libs.mockito) + testImplementation(libs.mockitoKotlin) + testImplementation(libs.okio2) + testImplementation(projects.shark.sharkTest) + testImplementation(projects.shark.sharkHprofTest) } diff --git a/shark/shark-cli/build.gradle.kts b/shark/shark-cli/build.gradle.kts index a2d4d4ef1e..78e5bded14 100644 --- a/shark/shark-cli/build.gradle.kts +++ b/shark/shark-cli/build.gradle.kts @@ -1,4 +1,5 @@ -import org.jetbrains.kotlin.gradle.dsl.KotlinCompile +import java.util.Properties +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { id("org.jetbrains.kotlin.jvm") @@ -6,43 +7,47 @@ plugins { id("com.vanniktech.maven.publish") } -sourceCompatibility = JavaVersion.VERSION_1_8 -targetCompatibility = JavaVersion.VERSION_1_8 +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} // Workaround for https://stackoverflow.com/questions/48988778 // /cannot-inline-bytecode-built-with-jvm-target-1-8-into-bytecode-that-is-being-bui -tasks.withType(KotlinCompile).configureEach { +tasks.withType { kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8.toString() } dependencies { - api projects.shark.sharkAndroid + api(projects.shark.sharkAndroid) - implementation libs.clikt - implementation libs.neo4j - implementation libs.jline - implementation libs.kotlin.stdlib + implementation(libs.clikt) + implementation(libs.neo4j) + implementation(libs.jline) + implementation(libs.kotlin.stdlib) } application { - mainClassName = 'shark.MainKt' + mainClass.set("shark.MainKt") } -def generatedVersionDir = "${buildDir}/generated-version" +val generatedVersionDir = "${buildDir}/generated-version" sourceSets { main { - output.dir(generatedVersionDir, builtBy: 'generateVersionProperties') + output.dir(generatedVersionDir, "builtBy" to "generateVersionProperties") } } tasks.register("generateVersionProperties") { doLast { - def propertiesFile = file "$generatedVersionDir/version.properties" + val propertiesFile = file("$generatedVersionDir/version.properties") propertiesFile.parentFile.mkdirs() - def properties = new Properties() - properties.setProperty("version_name", rootProject.VERSION_NAME.toString()) - propertiesFile.withWriter { properties.store(it, null) } + val properties = Properties() + properties.setProperty("version_name", rootProject.property("VERSION_NAME").toString()) + propertiesFile.writer().use { + properties.store(it, null) + } } } tasks.named("processResources") { diff --git a/shark/shark-graph/build.gradle.kts b/shark/shark-graph/build.gradle.kts index ab83749fa1..403773f5ea 100644 --- a/shark/shark-graph/build.gradle.kts +++ b/shark/shark-graph/build.gradle.kts @@ -3,18 +3,20 @@ plugins { id("com.vanniktech.maven.publish") } -sourceCompatibility = JavaVersion.VERSION_1_8 -targetCompatibility = JavaVersion.VERSION_1_8 +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} dependencies { - api projects.shark.sharkHprof - api libs.androidX.collections + api(projects.shark.sharkHprof) + api(libs.androidX.collections) - implementation libs.kotlin.stdlib - implementation libs.okio2 + implementation(libs.kotlin.stdlib) + implementation(libs.okio2) - testImplementation libs.assertjCore - testImplementation libs.junit - testImplementation projects.shark.sharkTest - testImplementation projects.shark.sharkHprofTest + testImplementation(libs.assertjCore) + testImplementation(libs.junit) + testImplementation(projects.shark.sharkTest) + testImplementation(projects.shark.sharkHprofTest) } diff --git a/shark/shark-hprof-test/build.gradle.kts b/shark/shark-hprof-test/build.gradle.kts index 66a1a66fec..7698f5ad69 100644 --- a/shark/shark-hprof-test/build.gradle.kts +++ b/shark/shark-hprof-test/build.gradle.kts @@ -2,13 +2,15 @@ plugins { id("org.jetbrains.kotlin.jvm") } -sourceCompatibility = JavaVersion.VERSION_1_8 -targetCompatibility = JavaVersion.VERSION_1_8 +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} dependencies { - implementation libs.kotlin.stdlib - implementation libs.junit - implementation libs.okio2 + implementation(libs.kotlin.stdlib) + implementation(libs.junit) + implementation(libs.okio2) - implementation projects.shark.sharkHprof + implementation(projects.shark.sharkHprof) } diff --git a/shark/shark-hprof/build.gradle.kts b/shark/shark-hprof/build.gradle.kts index f03a1dfec5..765ce9f8c4 100644 --- a/shark/shark-hprof/build.gradle.kts +++ b/shark/shark-hprof/build.gradle.kts @@ -3,23 +3,25 @@ plugins { id("com.vanniktech.maven.publish") } -sourceCompatibility = JavaVersion.VERSION_1_8 -targetCompatibility = JavaVersion.VERSION_1_8 +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} dependencies { - api projects.shark.sharkLog + api(projects.shark.sharkLog) - implementation libs.kotlin.stdlib + implementation(libs.kotlin.stdlib) // compileOnly ensures this dependency is not exposed through this artifact's pom.xml in Maven Central. // Okio is a required dependency, but we're making it required on the "shark" artifact which is the main artifact that // should generally be used. The shark artifact depends on Okio 2.x (ensure compatibility with modern Okio). Depending on 1.x here // enables us to ensure binary compatibility with Okio 1.x and allow us to use the deprecated (error level) Okio APIs to keep that // compatibility. // See https://github.com/square/leakcanary/issues/1624 - compileOnly libs.okio1 - testImplementation libs.okio1 + compileOnly(libs.okio1) + testImplementation(libs.okio1) - testImplementation libs.assertjCore - testImplementation libs.junit - testImplementation projects.shark.sharkTest + testImplementation(libs.assertjCore) + testImplementation(libs.junit) + testImplementation(projects.shark.sharkTest) } diff --git a/shark/shark-log/build.gradle.kts b/shark/shark-log/build.gradle.kts index 8ebe0922c1..46920a1007 100644 --- a/shark/shark-log/build.gradle.kts +++ b/shark/shark-log/build.gradle.kts @@ -3,12 +3,14 @@ plugins { id("com.vanniktech.maven.publish") } -sourceCompatibility = JavaVersion.VERSION_1_8 -targetCompatibility = JavaVersion.VERSION_1_8 +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} dependencies { - implementation libs.kotlin.stdlib + implementation(libs.kotlin.stdlib) - testImplementation libs.assertjCore - testImplementation libs.junit + testImplementation(libs.assertjCore) + testImplementation(libs.junit) } diff --git a/shark/shark-test/build.gradle.kts b/shark/shark-test/build.gradle.kts index 5a46a6c69c..7f3966733d 100644 --- a/shark/shark-test/build.gradle.kts +++ b/shark/shark-test/build.gradle.kts @@ -2,12 +2,14 @@ plugins { id("org.jetbrains.kotlin.jvm") } -sourceCompatibility = JavaVersion.VERSION_1_8 -targetCompatibility = JavaVersion.VERSION_1_8 +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} dependencies { - implementation libs.kotlin.stdlib - implementation libs.assertjCore - implementation libs.junit + implementation(libs.kotlin.stdlib) + implementation(libs.assertjCore) + implementation(libs.junit) } diff --git a/shark/shark/build.gradle.kts b/shark/shark/build.gradle.kts index 84310f2712..25eb0bf190 100644 --- a/shark/shark/build.gradle.kts +++ b/shark/shark/build.gradle.kts @@ -3,18 +3,20 @@ plugins { id("com.vanniktech.maven.publish") } -sourceCompatibility = JavaVersion.VERSION_1_8 -targetCompatibility = JavaVersion.VERSION_1_8 +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} dependencies { - api projects.shark.sharkGraph + api(projects.shark.sharkGraph) - implementation libs.coroutines.core - implementation libs.kotlin.stdlib - implementation libs.okio2 + implementation(libs.coroutines.core) + implementation(libs.kotlin.stdlib) + implementation(libs.okio2) - testImplementation libs.assertjCore - testImplementation libs.junit - testImplementation projects.shark.sharkTest - testImplementation projects.shark.sharkHprofTest + testImplementation(libs.assertjCore) + testImplementation(libs.junit) + testImplementation(projects.shark.sharkTest) + testImplementation(projects.shark.sharkHprofTest) }