How can I get a list of all configurations for a Gradle project?
With Gradle 5 it's very simple with the --info
option. For example:
./gradlew projects --info
Now look in the Configure project
section which lists all the configurations.
Add this to root project:
allprojects {
repositories {
// ....
}
task printConfigurations {
doLast {task ->
println "Project Name: $project.name configurations:"
configurations.each {
println " $it.name"
}
}
}
}
Then, for example:
$ ./gradlew -q :SubProjA:printConfigurations
Project Name: SubProjA configurations:
-api
-runtime
annotationProcessor
api
apiDependenciesMetadata
apiElements
archives
compile
compileClasspath
compileOnly
compileOnlyDependenciesMetadata
default
implementation
implementationDependenciesMetadata
kotlinCompilerClasspath
kotlinCompilerPluginClasspath
kotlinKlibCommonizerClasspath
kotlinNativeCompilerPluginClasspath
kotlinScriptDef
kotlinScriptDefExtensions
runtime
runtimeClasspath
runtimeElements
runtimeOnly
runtimeOnlyDependenciesMetadata
sourceArtifacts
testAnnotationProcessor
testApi
testApiDependenciesMetadata
testCompile
testCompileClasspath
testCompileOnly
testCompileOnlyDependenciesMetadata
testImplementation
testImplementationDependenciesMetadata
testKotlinScriptDef
testKotlinScriptDefExtensions
testRuntime
testRuntimeClasspath
testRuntimeOnly
testRuntimeOnlyDependenciesMetadata
Try
gradle --console plain dependencies | fgrep ' - '
The dependencies task lists all configurations (along with their dependencies), and the fgrep will just show you the configuration names (along with a brief description of each). It's not great, but doesn't require you to put stuff in your build script.
Have you tried:
configurations.each { println it.name }
?