Gradle:将所有测试依赖项复制到一个zip文件 [英] Gradle : Copy all test dependencies to a zip file

查看:161
本文介绍了Gradle:将所有测试依赖项复制到一个zip文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在寻找解决方案将所有依赖关系放在范围testCompile中到一个zip文件。我查看了 http://forums.gradle.org/gradle/topics/how_do_i_make_a_zip_to_contain_dependency_artifacts ,但这似乎只适用于运行时依赖关系。我还检查了 http://www.gradle.org/docs/current/userguide /working_with_files.html 第16.8章,但这也不起作用。



当我通过访问configurations.testCompile.allArtifacts.files ,我的邮编始终为空。当我通过 configurations.testCompile.allDependencies 访问时,我可以看到所有deps,但我缺少依赖关系的路径。



很难相信我,我是唯一一个遇到这个问题的人,因为我没有找到任何解决方案。



任何帮助表示赞赏!

解决方案

这适用于我:
http://forums.gradle.org/gradle/topics/how_do_i_make_a_zip_to_contain_dependency_artifacts



示例任务:

 任务zip2(dependsOn:'testCompile',类型:Zip){
from configurations.testCompile.allArtifacts.files
from configurations.testCompile
archiveName project.name +_test _+ project.version
}



然后运行:

  gradle test zip2 



Z ip文件将在以下位置生成:

  build \distributions 


I am quite new to gradle, so maybe I am asking something quite easy....

I am looking for a solution to put all dependencies in scope testCompile into a zip file. I checked http://forums.gradle.org/gradle/topics/how_do_i_make_a_zip_to_contain_dependency_artifacts but this seems to work only for runtime dependencies. I also checked http://www.gradle.org/docs/current/userguide/working_with_files.html Chapter 16.8, but that did not work either.

When I access via configurations.testCompile.allArtifacts.files, my zip is always empty. When I acces via configurations.testCompile.allDependencies I can see all deps but I am lacking the path of the dependencies.

It is hard to believe to me, that I am the only one ever had this problems since I did not find any solution.

Any help appreciated!

解决方案

This works for me: http://forums.gradle.org/gradle/topics/how_do_i_make_a_zip_to_contain_dependency_artifacts

Sample task:

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

Then run:

gradle test zip2

Zip file will be generated at:

build\distributions

这篇关于Gradle:将所有测试依赖项复制到一个zip文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆