I want to get the dependencies programmatically within Gradle in an Android project.
I tried (in both project as well as module level gradle.build):
task dumpDependencies {
doLast {
def resolved = configurations.compileClasspath.resolvedConfiguration
println "Files: $resolved.files"
}
}
But I get this error:
> Could not get unknown property 'compileClasspath' for configuration container of type org.gradle.api.internal.artifacts.configurations.DefaultConfigurationContainer.
I am using Gradle version 7.5
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
What am I missing?
The
compileClasspathconfiguration is provided by thejavaplugin, see more at https://docs.gradle.org/current/userguide/java_plugin.html#sec:java_plugin_and_dependency_management.So to access the
compileClasspathconfiguration, plugin Java declaration is requiredFor Android projects, which by default use
kotlinplugin instead, there are nocompileClasspathconfigurations. I could think of this alternative solution: