Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Gradle:将所有测试依赖项复制到zip文件_Gradle_Dependency Management - Fatal编程技术网

Gradle:将所有测试依赖项复制到zip文件

Gradle:将所有测试依赖项复制到zip文件,gradle,dependency-management,Gradle,Dependency Management,我对gradle很陌生,所以也许我问的问题很简单 我正在寻找一种解决方案,将testCompile范围内的所有依赖项放入zip文件。我检查了,但这似乎只适用于运行时依赖项。我还检查了第16.8章,但这也不起作用 当我通过configurations.testCompile.allArtifacts.files访问时,我的zip文件总是空的。当我通过configurations.testCompile.allDependencies访问时,我可以看到所有的DEP,但我缺少依赖项的路径 我很难相信,

我对gradle很陌生,所以也许我问的问题很简单

我正在寻找一种解决方案,将testCompile范围内的所有依赖项放入zip文件。我检查了,但这似乎只适用于运行时依赖项。我还检查了第16.8章,但这也不起作用

当我通过
configurations.testCompile.allArtifacts.files
访问时,我的zip文件总是空的。当我通过
configurations.testCompile.allDependencies
访问时,我可以看到所有的DEP,但我缺少依赖项的路径

我很难相信,我是唯一一个有过这种问题的人,因为我没有找到任何解决办法

感谢您的帮助

这对我很有用:

示例任务:

task zip2(dependsOn: 'testCompile', type: Zip) {
    from configurations.testCompile.allArtifacts.files
    from configurations.testCompile
    archiveName project.name + "_test_"+ project.version
}
然后运行:

gradle test zip2
Zip文件将在以下位置生成:

build\distributions

谢谢,这对我也有用。我的原始代码是相同的,但不是configurations.testCompile中的。它有什么用?我不明白。它创建了一个zip,这很好,但是没有应用命名。名称为alwayss project.name+“-”+project.version。即使设置basename属性也不会给gradlesorry留下深刻印象,我的错应该是“archiveName”,我已经更新了我的答案,如果您满意,请选择我的答案您可能想在任务中添加一个
dependsOn:['testCompile']
,因为它需要事先运行testCompile。