Why does not Gradle 4.9 show my compileOnly file dependency?

I have the following file

plugins {
    id 'java'
}

dependencies {
    compileOnly files('c:\\temp\\jGnash-2.36.1\\lib\\jgnash-plugin-2.36.1.jar')
}

But running dependencies tasks shows no deps under compileOnly section.

Is this a bug? Or does it have some meaning?

The Gradle dependencies task shows a report of resolved module dependencies. By hard-coding a specific file, you are including that specific file in the relevant configuration, but bypassing all of the dependency management capabilities, including display in the dependency report.

It is possible to declare a dependency on the module rather than the underlying file while still resolving to the file on this directory. This would result in the module being shown in the dependency report.

plugins {
    id 'java'
}

repositories {
    flatDir { dirs 'c:\\temp\\jGnash-2.36.1\\lib' }
}

dependencies {
    compileOnly ':jgnash-plugin:2.36.1'
}
1 Like