Gradle : Copy all test dependencies to a zip file

北慕城南 提交于 2019-12-07 03:19:49

问题


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!


回答1:


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


来源:https://stackoverflow.com/questions/24572192/gradle-copy-all-test-dependencies-to-a-zip-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!