Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle : Copy all test dependencies to a zip file

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!

like image 898
gorefest Avatar asked Jul 04 '14 10:07

gorefest


1 Answers

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
like image 86
Bill Lin Avatar answered Oct 18 '22 03:10

Bill Lin