autonomousapps / dependency-analysis-gradle-plugin

Gradle plugin for JVM projects written in Java, Kotlin, Groovy, or Scala; and Android projects written in Java or Kotlin. Provides advice for managing dependencies and other applied plugins
Apache License 2.0
1.79k stars 117 forks source link

Support Kotlin multiplatform #228

Open martinbonnin opened 4 years ago

martinbonnin commented 4 years ago

Running the buildHealth task on apollo-android returns useful information but it looks like the plugin has some difficulties coping with multiplatform projects. For an exemple:

$ ./gradlew clean :apollo-normalized-cache-sqlite:aggregateAdvice

> Task :apollo-normalized-cache-sqlite:aggregateAdvice
Unused dependencies which should be removed:
- null(project(":apollo-api"))

Transitively used dependencies that should be declared directly as indicated:
- null(project(":apollo-api"))
- api("org.jetbrains.kotlin:kotlin-stdlib:1.3.72")
- api(project(":apollo-normalized-cache-api"))
- api("androidx.sqlite:sqlite:2.1.0")
- api("com.squareup.sqldelight:runtime-jvm:1.3.0")

This can be reproduced with the dependency-analysis branch

autonomousapps commented 4 years ago

Resolved with https://github.com/autonomousapps/dependency-analysis-android-gradle-plugin/pull/249.

martinbonnin commented 4 years ago

Can we reopen this one? With latest main, multiplatform projects are skipped with No main source set. No analysis performed.

Also, multiplatform publication have a "common" publication that is used as a pointer to the individual platform publications and using them triggers false positives, even if using them in non-multiplatform projects:

For an exemple:

   api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9")

Will be trigger:

Transitively used dependencies that should be declared directly as indicated:
- api("org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.3.9")

Even though it's mostly correct to only include the "common" publication and let gradle decide the implementation.

This can be reproduced with the use-dependency-analysis branch of apollo-android: https://github.com/apollographql/apollo-android/tree/use-dependency-analysis

I can provide a more minimal exemple if it helps.

autonomousapps commented 4 years ago

I think it will require a focused effort to support kotlin multiplatform, rather than trying to fix seeming bugs in an ad hoc manner. I will reopen this ticket with that in mind.

dmitriy1morozov commented 1 year ago

Hello. Are there any updates on supporting KMM projects? It is a highly anticipated feature by our team. Thank you.