From 045b7da9ba9bafb32f88709a16fa4d724cffa767 Mon Sep 17 00:00:00 2001 From: Lachlan McKee Date: Sun, 12 Feb 2023 17:03:07 +0000 Subject: [PATCH] Introduced dependency analysis plugin and fixed issues --- .github/workflows/build.yml | 5 +++- binder/build.gradle.kts | 7 +++-- build.gradle.kts | 26 +++++++++++++++++++ gradle/libs.versions.toml | 26 +++++++------------ mvicore-android/build.gradle.kts | 24 ++++++++--------- mvicore-debugdrawer/build.gradle.kts | 14 +++++----- .../mvicore-demo-app/build.gradle.kts | 8 +----- .../mvicore-demo-catapi/build.gradle.kts | 9 +++---- .../mvicore-demo-feature1/build.gradle.kts | 8 ++---- .../mvicore-demo-feature2/build.gradle.kts | 11 +++----- mvicore-diff/build.gradle.kts | 5 ++-- .../com/badoo/mvicore/ModelWatcherTest.kt | 4 +-- mvicore-plugin/common/build.gradle.kts | 3 ++- mvicore-plugin/idea/build.gradle.kts | 7 ++--- mvicore-plugin/middleware/build.gradle.kts | 11 ++++---- mvicore/build.gradle.kts | 8 +++--- 16 files changed, 91 insertions(+), 85 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d73ca214..ce7cd3eb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,6 +23,7 @@ jobs: with: arguments: | build + projectHealth mergeLintSarif mergeDetektSarif :plugins:buildPlugins @@ -46,7 +47,9 @@ jobs: uses: actions/upload-artifact@v3 with: name: reports - path: '**/build/reports' + path: | + **/build/reports/ + !**/build/reports/dependency-analysis/ instrumentation-tests: name: Instrumentation tests diff --git a/binder/build.gradle.kts b/binder/build.gradle.kts index 90769e42..8fde34fc 100644 --- a/binder/build.gradle.kts +++ b/binder/build.gradle.kts @@ -16,12 +16,11 @@ tasks.withType { } dependencies { - implementation(libs.rxjava2) + api(libs.rxjava2) implementation(libs.rxkotlin) implementation(libs.kotlin.stdlib) - testImplementation(libs.junit5) - testImplementation(libs.junit.params) - testImplementation(libs.junit.platform.launcher) + testRuntimeOnly(libs.junit5.engine) + testImplementation(libs.junit5.api) testImplementation(libs.mockito.kotlin) } diff --git a/build.gradle.kts b/build.gradle.kts index b496baf2..6b76638b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -16,6 +16,32 @@ buildscript { plugins { id("mvi-core-collect-sarif") + id("com.autonomousapps.dependency-analysis") version libs.versions.dependencyAnalysis.get() +} + +dependencyAnalysis { + issues { + all { + onIncorrectConfiguration { + severity("fail") + } + onUnusedDependencies { + severity("fail") + } + } + project(":mvicore-demo:mvicore-demo-app") { + onUnusedDependencies { + severity("fail") + exclude("com.jakewharton.scalpel:scalpel") // Accessed using reflection + } + } + project(":mvicore-android") { + onUnusedDependencies { + severity("fail") + exclude("androidx.test:runner") // Accessed using reflection + } + } + } } tasks.register("clean", Delete::class) { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 5c991310..3b680e8a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,7 @@ [versions] kotlinVersion = "1.7.10" detekt = "1.22.0" +dependencyAnalysis = "1.19.0" # Android androidLifecycleVersion = "2.5.1" @@ -23,14 +24,11 @@ scalpelVersion = "1.1.2" glideVersion = "4.13.2" # Testing -okhttpVersion = "3.14.9" retrofitVersion = "2.4.0" gsonVersion = "2.10.1" # Testing -junitVersion = "4.13.2" -junit5Version = "5.9.2" -junitPlatformLauncherVersion = "1.9.2" +junit5 = "5.9.2" supportTestVersion = "1.3.0" mockitoKotlinVersion = "4.1.0" @@ -39,7 +37,9 @@ mockitoKotlinVersion = "4.1.0" kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk7", version.ref = "kotlinVersion" } # Android -androidx-lifecycle-java8 = { module = "androidx.lifecycle:lifecycle-common-java8", version.ref = "androidLifecycleVersion" } +androidx-arch-core-runtime = "androidx.arch.core:core-runtime:2.1.0" +androidx-lifecycle-common = { module = "androidx.lifecycle:lifecycle-common", version.ref = "androidLifecycleVersion" } +androidx-lifecycle-runtime = { module = "androidx.lifecycle:lifecycle-runtime", version.ref = "androidLifecycleVersion" } androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidAppCompatVersion" } androidx-constraintlayout = { module = "androidx.constraintlayout:constraintlayout", version.ref = "constraintLayoutVersion" } google-material = { module = "com.google.android.material:material", version.ref = "androidMaterialVersion" } @@ -52,9 +52,6 @@ rxandroid = { module = "io.reactivex.rxjava2:rxandroid", version.ref = "rxAndroi # DI dagger-runtime = { module = "com.google.dagger:dagger", version.ref = "daggerVersion" } dagger-compiler = { module = "com.google.dagger:dagger-compiler", version.ref = "daggerVersion" } -dagger-android-runtime = { module = "com.google.dagger:dagger-android", version.ref = "daggerVersion" } -dagger-android-support = { module = "com.google.dagger:dagger-android-support", version.ref = "daggerVersion" } -dagger-android-processor = { module = "com.google.dagger:dagger-android-processor", version.ref = "daggerVersion" } # DebugDrawer debugdrawer-impl = { module = "com.github.lenguyenthanh.debugdrawer:debugdrawer", version.ref = "debugDrawerVersion" } @@ -63,7 +60,6 @@ debugdrawer-view-impl = { module = "com.github.lenguyenthanh.debugdrawer:debugdr debugdrawer-noop = { module = "com.github.lenguyenthanh.debugdrawer:debugdrawer-no-op", version.ref = "debugDrawerVersion" } debugdrawer-view-noop = { module = "com.github.lenguyenthanh.debugdrawer:debugdrawer-view-no-op", version.ref = "debugDrawerVersion" } debugdrawer-commons = { module = "com.github.lenguyenthanh.debugdrawer:debugdrawer-commons", version.ref = "debugDrawerVersion" } -debugdrawer-actions = { module = "com.github.lenguyenthanh.debugdrawer:debugdrawer-actions", version.ref = "debugDrawerVersion" } debugdrawer-scalpel = { module = "com.github.lenguyenthanh.debugdrawer:debugdrawer-scalpel", version.ref = "debugDrawerVersion" } debugdrawer-timber = { module = "com.github.lenguyenthanh.debugdrawer:debugdrawer-timber", version.ref = "debugDrawerVersion" } debugdrawer-networkQuality = { module = "com.github.lenguyenthanh.debugdrawer:debugdrawer-network-quality", version.ref = "debugDrawerVersion" } @@ -75,21 +71,19 @@ glide-runtime = { module = "com.github.bumptech.glide:glide", version.ref = "gli glide-compiler = { module = "com.github.bumptech.glide:compiler", version.ref = "glideVersion" } # Network -okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttpVersion" } retrofit-runtime = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofitVersion" } retrofit-adapter-rxjava2 = { module = "com.squareup.retrofit2:adapter-rxjava2", version.ref = "retrofitVersion" } retrofit-converter-simplexml = { module = "com.squareup.retrofit2:converter-simplexml", version.ref = "retrofitVersion" } gson = { module = "com.google.code.gson:gson", version.ref = "gsonVersion" } # Testing -junit = { module = "junit:junit", version.ref = "junitVersion" } -junit5 = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit5Version" } -junit-params = { module = "org.junit.jupiter:junit-jupiter-params", version = "junit5Version"} -junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher", version.ref = "junitPlatformLauncherVersion" } -kotlin-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlinVersion" } +junit4 = "junit:junit:4.13.2" +junit5-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junit5" } +junit5-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit5" } +junit5-params = { module = "org.junit.jupiter:junit-jupiter-params", version = "junit5"} mockito-kotlin = { module = "org.mockito.kotlin:mockito-kotlin", version.ref = "mockitoKotlinVersion" } androidx-test-runner = { module = "androidx.test:runner", version.ref = "supportTestVersion" } -androidx-test-rules = { module = "androidx.test:rules", version.ref = "supportTestVersion" } +hamcrest-core = "org.hamcrest:hamcrest-core:1.3" plugin-kotlin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlinVersion" } plugin-detekt = { module = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin", version.ref = "detekt" } diff --git a/mvicore-android/build.gradle.kts b/mvicore-android/build.gradle.kts index c0f88eef..d32a448c 100644 --- a/mvicore-android/build.gradle.kts +++ b/mvicore-android/build.gradle.kts @@ -36,21 +36,21 @@ android { } dependencies { - implementation(libs.androidx.appcompat) - implementation(libs.androidx.lifecycle.java8) - implementation(libs.kotlin.stdlib) + api(project(":mvicore")) + api(project(":binder")) + api(libs.androidx.lifecycle.common) + api(libs.rxjava2) - implementation(libs.rxjava2) - implementation(libs.rxkotlin) + implementation(libs.kotlin.stdlib) implementation(libs.rxandroid) - testImplementation(libs.junit5) - testImplementation(libs.junit.params) - testImplementation(libs.junit.platform.launcher) + testRuntimeOnly(libs.junit5.engine) + testImplementation(libs.junit5.api) + testImplementation(libs.junit5.params) + testImplementation(libs.androidx.arch.core.runtime) + testImplementation(libs.androidx.lifecycle.runtime) - androidTestImplementation(libs.junit) + androidTestImplementation(libs.junit4) androidTestImplementation(libs.androidx.test.runner) - androidTestImplementation(libs.androidx.test.rules) - - implementation(project(":mvicore")) + androidTestImplementation(libs.hamcrest.core) } diff --git a/mvicore-debugdrawer/build.gradle.kts b/mvicore-debugdrawer/build.gradle.kts index 871f08f2..01902b24 100644 --- a/mvicore-debugdrawer/build.gradle.kts +++ b/mvicore-debugdrawer/build.gradle.kts @@ -29,18 +29,16 @@ android { } dependencies { - implementation(libs.androidx.constraintlayout) + api(project(":mvicore")) + api(libs.debugdrawer.base) + debugApi(libs.debugdrawer.impl) + releaseApi(libs.debugdrawer.noop) + implementation(libs.androidx.constraintlayout) implementation(libs.rxjava2) - implementation(libs.rxkotlin) - implementation(libs.kotlin.stdlib) - implementation(libs.debugdrawer.base) - debugImplementation(libs.debugdrawer.impl) debugImplementation(libs.debugdrawer.view.impl) - releaseImplementation(libs.debugdrawer.noop) - releaseImplementation(libs.debugdrawer.view.noop) - implementation(project(":mvicore")) + releaseImplementation(libs.debugdrawer.view.noop) } diff --git a/mvicore-demo/mvicore-demo-app/build.gradle.kts b/mvicore-demo/mvicore-demo-app/build.gradle.kts index 1d4f67d8..dc1d2e52 100644 --- a/mvicore-demo/mvicore-demo-app/build.gradle.kts +++ b/mvicore-demo/mvicore-demo-app/build.gradle.kts @@ -41,6 +41,7 @@ dependencies { implementation(project(":mvicore-demo:mvicore-demo-feature1")) implementation(project(":mvicore-demo:mvicore-demo-feature2")) implementation(project(":mvicore-plugin:middleware")) + implementation(project(":binder")) // Kotlin implementation(libs.kotlin.stdlib) @@ -56,18 +57,12 @@ dependencies { // DI implementation(libs.dagger.runtime) - implementation(libs.dagger.android.runtime) - implementation(libs.dagger.android.support) kapt(libs.dagger.compiler) - kapt(libs.dagger.android.processor) // DebugDrawer debugImplementation(libs.debugdrawer.impl) - debugImplementation(libs.debugdrawer.view.impl) releaseImplementation(libs.debugdrawer.noop) - releaseImplementation(libs.debugdrawer.view.noop) implementation(libs.debugdrawer.commons) - implementation(libs.debugdrawer.actions) implementation(libs.debugdrawer.scalpel) implementation(libs.debugdrawer.base) implementation(libs.debugdrawer.timber) @@ -76,7 +71,6 @@ dependencies { // Utils implementation(libs.timber) implementation(libs.scalpel) - implementation(libs.okhttp) implementation(libs.glide.runtime) kapt(libs.glide.compiler) } diff --git a/mvicore-demo/mvicore-demo-catapi/build.gradle.kts b/mvicore-demo/mvicore-demo-catapi/build.gradle.kts index 64f76943..a431ecdf 100644 --- a/mvicore-demo/mvicore-demo-catapi/build.gradle.kts +++ b/mvicore-demo/mvicore-demo-catapi/build.gradle.kts @@ -27,13 +27,10 @@ android { } dependencies { - implementation(libs.kotlin.stdlib) - implementation(libs.androidx.appcompat) - - implementation(libs.rxjava2) - implementation(libs.rxandroid) + api(libs.rxjava2) + api(libs.retrofit.runtime) - implementation(libs.retrofit.runtime) + implementation(libs.kotlin.stdlib) implementation(libs.retrofit.adapter.rxjava2) implementation(libs.retrofit.converter.simplexml) diff --git a/mvicore-demo/mvicore-demo-feature1/build.gradle.kts b/mvicore-demo/mvicore-demo-feature1/build.gradle.kts index 73325480..d03ee065 100644 --- a/mvicore-demo/mvicore-demo-feature1/build.gradle.kts +++ b/mvicore-demo/mvicore-demo-feature1/build.gradle.kts @@ -27,11 +27,7 @@ android { } dependencies { - implementation(libs.kotlin.stdlib) - implementation(libs.androidx.appcompat) - - implementation(libs.rxjava2) - implementation(libs.rxandroid) + api(project(":mvicore")) - implementation(project(":mvicore")) + implementation(libs.kotlin.stdlib) } diff --git a/mvicore-demo/mvicore-demo-feature2/build.gradle.kts b/mvicore-demo/mvicore-demo-feature2/build.gradle.kts index d365e339..4974fb24 100644 --- a/mvicore-demo/mvicore-demo-feature2/build.gradle.kts +++ b/mvicore-demo/mvicore-demo-feature2/build.gradle.kts @@ -28,13 +28,10 @@ android { } dependencies { - implementation(libs.kotlin.stdlib) - implementation(libs.androidx.appcompat) - - implementation(libs.rxjava2) - implementation(libs.rxandroid) + api(libs.rxjava2) + api(project(":mvicore")) + api(project(":mvicore-demo:mvicore-demo-catapi")) - implementation(project(":mvicore")) implementation(project(":mvicore-android")) - implementation(project(":mvicore-demo:mvicore-demo-catapi")) + implementation(libs.kotlin.stdlib) } diff --git a/mvicore-diff/build.gradle.kts b/mvicore-diff/build.gradle.kts index aa04a12a..18468780 100644 --- a/mvicore-diff/build.gradle.kts +++ b/mvicore-diff/build.gradle.kts @@ -18,7 +18,6 @@ tasks.withType { dependencies { implementation(libs.kotlin.stdlib) - testImplementation(libs.junit5) - testImplementation(libs.junit.params) - testImplementation(libs.junit.platform.launcher) + testRuntimeOnly(libs.junit5.engine) + testImplementation(libs.junit5.api) } diff --git a/mvicore-diff/src/test/java/com/badoo/mvicore/ModelWatcherTest.kt b/mvicore-diff/src/test/java/com/badoo/mvicore/ModelWatcherTest.kt index 88c31ae0..bcdfa488 100644 --- a/mvicore-diff/src/test/java/com/badoo/mvicore/ModelWatcherTest.kt +++ b/mvicore-diff/src/test/java/com/badoo/mvicore/ModelWatcherTest.kt @@ -103,7 +103,7 @@ class ModelWatcherTest { } @Test - fun `invokes callback with combined diffStrategy using "or"`() { + fun `invokes callback with combined diffStrategy using 'or'`() { val results = testWatcher( listOf( Model(list = listOf(""), int = 1), @@ -120,7 +120,7 @@ class ModelWatcherTest { } @Test - fun `invokes callback with combined diffStrategy using "and"`() { + fun `invokes callback with combined diffStrategy using 'and'`() { val results = testWatcher( listOf( Model(list = listOf(""), int = 1), diff --git a/mvicore-plugin/common/build.gradle.kts b/mvicore-plugin/common/build.gradle.kts index 5666dda7..c5ebc566 100644 --- a/mvicore-plugin/common/build.gradle.kts +++ b/mvicore-plugin/common/build.gradle.kts @@ -12,6 +12,7 @@ java { base.archivesBaseName = "mvicore-plugin-common" dependencies { - implementation(libs.gson) + api(libs.gson) + implementation(libs.kotlin.stdlib) } diff --git a/mvicore-plugin/idea/build.gradle.kts b/mvicore-plugin/idea/build.gradle.kts index 632fc08b..908c8816 100644 --- a/mvicore-plugin/idea/build.gradle.kts +++ b/mvicore-plugin/idea/build.gradle.kts @@ -35,9 +35,10 @@ tasks { } dependencies { - implementation(libs.rxjava2) + api(project(":mvicore-plugin:common")) + api(libs.gson) + api(libs.rxjava2) + implementation(libs.rxkotlin) - implementation(libs.gson) - implementation(project(":mvicore-plugin:common")) implementation(libs.kotlin.stdlib) } diff --git a/mvicore-plugin/middleware/build.gradle.kts b/mvicore-plugin/middleware/build.gradle.kts index 5ce7d3b0..df635d3a 100644 --- a/mvicore-plugin/middleware/build.gradle.kts +++ b/mvicore-plugin/middleware/build.gradle.kts @@ -14,10 +14,11 @@ java { base.archivesBaseName = "mvicore-plugin-middleware" dependencies { - implementation(libs.rxjava2) - implementation(libs.rxkotlin) - implementation(libs.gson) - implementation(project(":mvicore")) - implementation(project(":mvicore-plugin:common")) + api(project(":binder")) + api(project(":mvicore-plugin:common")) + api(libs.rxjava2) + api(libs.gson) + implementation(libs.kotlin.stdlib) + implementation(libs.rxkotlin) } diff --git a/mvicore/build.gradle.kts b/mvicore/build.gradle.kts index 6215d074..56b68d3f 100644 --- a/mvicore/build.gradle.kts +++ b/mvicore/build.gradle.kts @@ -17,12 +17,12 @@ tasks.withType { dependencies { api(project(":binder")) - implementation(libs.rxjava2) + api(libs.rxjava2) implementation(libs.rxkotlin) implementation(libs.kotlin.stdlib) - testImplementation(libs.junit5) - testImplementation(libs.junit.params) - testImplementation(libs.junit.platform.launcher) + testRuntimeOnly(libs.junit5.engine) + testImplementation(libs.junit5.api) + testImplementation(libs.junit5.params) testImplementation(libs.mockito.kotlin) }