Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using multiple configurations causes incorrect dependency reporting #444

Open
monae opened this issue Feb 20, 2024 · 0 comments
Open

Using multiple configurations causes incorrect dependency reporting #444

monae opened this issue Feb 20, 2024 · 0 comments

Comments

@monae
Copy link
Contributor

monae commented Feb 20, 2024

Sometimes incorrect items are included in the generated report.
I found that it was caused by using multiple configurations to collect dependencies:
https://github.com/jaredsburrows/gradle-license-plugin/blob/0.9.7/gradle-license-plugin/src/main/kotlin/com/jaredsburrows/license/LicenseReportTask.kt#L174-L181

I don't know why multiple configurations are used, but at least for Android project, I think it is sufficient to use ${variantName}RuntimeClasspath only to collect runtime dependencies included in APK.


Below are the details of the incorrect report that I found.

My Android project has multiple subprojects, and each project uses both implementation(...) and api(...) dependencies.
It seems that the ${variantName}RuntimeClasspath configuration collects both of them while implementation does only the former.
Due to this difference, in each configuration the androidx.annotation:annotation module dependency and its artifacts were resolved as follows.

${variantName}RuntimeClasspath:

androidx.annotation:annotation:1.7.0;jvmRuntimeElements-published
- annotation-jvm-1.7.0.jar (androidx.annotation:annotation-jvm:1.7.0)
- kotlin-stdlib-1.9.22.jar (org.jetbrains.kotlin:kotlin-stdlib:1.9.22)
- annotations-23.0.0.jar (org.jetbrains:annotations:23.0.0)

===

implementation:

androidx.annotation:annotation:1.5.0;runtimeElements
- annotation-1.5.0.jar (androidx.annotation:annotation:1.5.0)
- kotlin-stdlib-1.9.22.jar (org.jetbrains.kotlin:kotlin-stdlib:1.9.22)
- annotations-23.0.0.jar (org.jetbrains:annotations:23.0.0)

All of these artifacts' modules are used to generate report.
Since no modules named androidx.annotation:annotation:1.7.0 in this list, androidx.annotation:annotation:1.5.0 remained without being overwritten.
As a result, the report includes both of the items below, while the latter is not correct.

  • Annotation 1.7.0 (androidx.annotation:annotation-jvm:1.7.0)
  • Android Support Library Annotations 1.5.0 (androidx.annotation:annotation:1.5.0)

The same cause also includes

  • okio 3.6.0 (com.squareup.okio:okio-jvm:3.6.0)
  • Okio 2.9.0 (com.squareup.okio:okio:2.9.0)

When I manually removed "implementation" from configurationList, these errors was resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant