6

我对 gradle 完全陌生。我将以下 build.gradle 放在一起,以了解如何从 flatDir 存储库中提取依赖项。“localrepo”目录包含两个文件“a.txt”和“b.txt”,仅此而已。当我运行“gradle dependencies”时,我遇到了失败:

:dependencies

------------------------------------------------------------
Root project
------------------------------------------------------------

copytest
+--- :a.txt: FAILED
\--- :b.txt: FAILED

BUILD SUCCESSFUL

Total time: 5.506 secs

为什么?

这是我的 build.gradle:

configurations {
  copytest
}

repositories {
  flatDir name: 'localRepository', dirs: 'localrepo'
}

dependencies {
  copytest ':a.txt'
  copytest ':b.txt'
}

task copyTask(type: Copy) {
  from configurations.copytest
  into 'result'
}
4

1 回答 1

14

repo使用flatDir简单的启发式方法将依赖项的模块名称转换为要搜索的文件名。如果您指定:a.txt,Gradle 将搜索a.txt.jar,或者,如果您已project.version设置,也会搜索a.txt-theVersion.jar。要将任意文件添加到配置中,而不是声明存储flatDir库,您可以使用copytest files("some/path").

于 2013-09-26T08:26:04.403 回答