Configuration.allDependencies should include dependencies from compile files

I have small task that prints for each configuration the dependencies including their version using allDependencies on a configuration. This works great for all compile or test compile dependencies such as:

compile "com.google.guava:guava:22.0"
testCompile "junit:junit:4.12"

Unfortunately, it fails for local dependencies using compile files such as:

compile files("/path/to/jar.jar")

The task does not even list the local dependencies using allDependencies. To retrieve the version information, one would obviously have to specify it first.

Is it possible to set up the local dependencies in such a way that they are listed using allDependencies, and to specify the version info without manually setting up a local repository as described in How to use sources / javadoc of local compile dependency in Eclipse / Buildship?

Here is the task:

task printDependencies {
    project.configurations.each {conf ->
        println conf
        conf.allDependencies.each {dep ->
            println "${dep.name}=${dep.version}"
        }
        println ""
    }
}

If dependencies have to be local, I always prefer to use the flatDir repository over a straight file dependency. It still allows you to avoid the full repository structure that you are asking to avoid, but allows you to specify normal maven coordinates. The file on disk can contain the version number or not, and the group can be omitted from the dependency declaration if you choose (leave the leading colon).

Your example jar would look like this:

repositories {
    flatDir { dirs '/path/to' }
}

dependencies {
    compile 'org:jar:1.0' // (or ':jar:1.0')
}

Thank you for the hint with the flatDir repository! Always learning something new. :slight_smile: