dropbox / dependency-guard

A Gradle plugin that guards against unintentional dependency changes.
Apache License 2.0
406 stars 15 forks source link

Dependency change only on CI though #43

Closed vanniktech closed 2 years ago

vanniktech commented 2 years ago

This is a bit of a weird one. The dependencyTreeDiffReleaseRuntimeClasspath tasks fails for me. However it's only on CI. This issue started happening with these changes (adding the plugin to more modules): https://github.com/vanniktech/Emoji/commit/3fe08a3f16a7c1adaacdfb5107a7e4feba91cef7

This is the CLI output:

> Task :emoji-facebook:dependencyTreeDiffReleaseRuntimeClasspath FAILED
See the report at: file:///home/runner/work/Emoji/Emoji/emoji-facebook/build/tmp/dependency-guard/releaseRuntimeClasspath.tree.txt
***** DEPENDENCY CHANGE DETECTED *****
-+--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.0
-|    +--- org.jetbrains.kotlin:kotlin-stdlib:1.7.0
-|    |    \--- org.jetbrains:annotations:13.0
-|    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.0
-|         \--- org.jetbrains.kotlin:kotlin-stdlib:1.7.0 (*)
 +--- project :emoji
-|    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.0 (*)
+|    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.0
+|         +--- org.jetbrains.kotlin:kotlin-stdlib:1.7.0
+|         |    \--- org.jetbrains:annotations:13.0
+|         \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.0
+|              \--- org.jetbrains.kotlin:kotlin-stdlib:1.7.0 (*)
+\--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.0 (*)

Running the task locally just works for me:

Screen Shot 2022-07-01 at 00 33 47

Could it be that dependencies are differently sorted on that particular machine and the tree diffing gets confused?

handstandsam commented 2 years ago

I did see this and looked into it last week. It's been super busy and I wasn't able to dig in deep. Were you able to figure out a way around this?

vanniktech commented 2 years ago

Nope.

handstandsam commented 2 years ago

The tree is written by the official Gradle :dependencies task https://github.com/dropbox/dependency-guard/blob/d5f24207d66f77ed11ac9ad6013348aae556a908/dependency-guard/src/main/kotlin/com/dropbox/gradle/plugins/dependencyguard/internal/tree/DependencyTreeDiffTask.kt#L7

I just set the outputFile variable they expose, then read in that file and do the comparison https://github.com/dropbox/dependency-guard/blob/d5f24207d66f77ed11ac9ad6013348aae556a908/dependency-guard/src/main/kotlin/com/dropbox/gradle/plugins/dependencyguard/internal/tree/DependencyTreeDiffTask.kt#L39

I don't "sort" at all. I am using a copy/paste of Jake's dependency-tree-diff library (because it's not available as a JAR)

Orig: https://github.com/JakeWharton/dependency-tree-diff/blob/b19d1bef011ae02864b9cb70fa9992de7ebb9039/src/main/kotlin/com/jakewharton/gradle/dependencies/treeDiff.kt#L7-L18

Copy: https://github.com/dropbox/dependency-guard/blob/main/dependency-guard/src/main/kotlin/com/dropbox/gradle/plugins/dependencyguard/internal/utils/JWDependencyTreeDiff.kt


So, I'm stumped. Maybe it could be an incompatibility between the :dependencies file output between versions of Gradle? 🤷 .

I'm going to close as "Can't reproduce", but thank you for reporting. Happy to reopen if we can find an easy way to repro/debug.