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.66k stars 116 forks source link

synthesizeDependenciesMain is failing with exception when having a file collection with an absolute file on windows as dependency #1164

Closed Vampire closed 2 months ago

Vampire commented 2 months ago

Build scan link https://scans.gradle.com/s/2tj64rxgo5xsm

Plugin version 1.31.0

Gradle version 8.7

JDK version 11

Describe the bug If you have

as a dependency, then the graph-compile-nodes.json has the absolute path as identifier. Following that, the synthesizeDependenciesMain task fails with FileNotFoundException because it tries to create the file build\reports\dependency-analysis\main\dependencies\C__\full\path\to\bar\baz.json where the intermediate C__\full\path\to\bar directories are not present which makes it fail.

To Reproduce

plugins {
    application
    id("com.autonomousapps.dependency-analysis") version "1.31.0"
}

dependencies {
    compileOnly(files(file("bar/baz")))
}

Be on Windows and run

./gradlew synthesizeDependenciesMain

Expected behavior No exception, everything working.

Additional context Generally, it is of course not a good idea to use files or fileTree as dependencies, but sometimes you do not have a real choice. The reproducer is a highly condensed MCVE after trying to figure out what exactly makes it break for 2 days. In the real project the com.klinec.gradle.javacard plugin is applied which adds such a dependency automatically and you cannot prevent it to do so.