【发布时间】:2016-12-15 21:28:33
【问题描述】:
我正在尝试获取dependencyInsight 或dependencies gradle 任务的--configuration 标志的所有有效值的列表。我将如何使用 Gradle 3.2.1 执行此操作?
【问题讨论】:
标签: gradle
我正在尝试获取dependencyInsight 或dependencies gradle 任务的--configuration 标志的所有有效值的列表。我将如何使用 Gradle 3.2.1 执行此操作?
【问题讨论】:
标签: gradle
你试过了吗:
configurations.each { println it.name }
?
【讨论】:
build.gradle 文件中吗?
gradle app:dependencyInsight --dependency joda-time --configuration compile,而不是gradle dependencyInsight --dependency joda-time --configuration compile。
./gradlew projects --info 列出配置
试试
gradle --console plain dependencies | fgrep ' - '
依赖项任务列出所有配置(以及它们的依赖项),fgrep 只会显示配置名称(以及每个配置的简要说明)。这不是很好,但不需要您将内容放入构建脚本中。
【讨论】:
使用 Gradle 5,使用 --info 选项非常简单。例如:
./gradlew projects --info
现在查看列出所有配置的Configure project 部分。
【讨论】:
--info,并在输出中搜索Creating configuration。
./gradlew projects 任务上添加指向官方(例如 gradle.org)文档的链接吗?
--info 只是将日志记录级别设置为INFO
将此添加到根项目:
allprojects {
repositories {
// ....
}
task printConfigurations {
doLast {task ->
println "Project Name: $project.name configurations:"
configurations.each {
println " $it.name"
}
}
}
}
那么,例如:
$ ./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
【讨论】:
Java插件的所有配置如下:
https://docs.gradle.org/current/userguide/java_plugin.html#sec:java_plugin_and_dependency_management
compile(Deprecated) 编译时间依赖。被取代 实施。
implementation extends compile 仅实现依赖项。
compileOnly 仅编译时依赖,不在运行时使用。
compileClasspath 扩展了 compile、compileOnly、实现 Compile 类路径,编译源码时使用。由任务 compileJava 使用。
annotationProcessor 编译期间使用的注解处理器。
runtime(Deprecated) 扩展了编译运行时依赖项。被取代 通过 runtimeOnly。
runtimeOnly 仅运行时依赖项。
runtimeClasspath 扩展 runtimeOnly、runtime、实现 Runtime 类路径包含实现的元素,以及运行时 只有元素。
testCompile(Deprecated) extends compile 额外的依赖 编译测试。被 testImplementation 取代。
testImplementation 扩展 testCompile,实现 Implementation 仅用于测试的依赖项。
testCompileOnly 仅用于编译测试的附加依赖项,而不是 在运行时使用。
testCompileClasspath 扩展了 testCompile、testCompileOnly、 testImplementation 测试编译类路径,编译测试时使用 来源。由任务 compileTestJava 使用。
testRuntime(Deprecated) 扩展运行时,testCompile 附加 仅用于运行测试的依赖项。被 testRuntimeOnly 取代。
testRuntimeOnly 扩展 runtimeOnly 仅运行时依赖项 运行测试。
testRuntimeClasspath 扩展了 testRuntimeOnly、testRuntime、 testImplementation 用于运行测试的运行时类路径。被任务使用 测试。
存档由该项目产生的工件(例如罐子)。被任务使用 上传档案。
default 扩展 runtimeClasspath 使用的默认配置 项目对这个项目的依赖。包含工件和 此项目在运行时所需的依赖项。
【讨论】:
只需在不带--configuration 标志的情况下运行这些命令,输出的第一行将是可用配置的列表
【讨论】:
--configuration 标志,它会列出所有可能的配置