Background
Whenever you need any dependency in your gradle script, gradle will download it it's cache and use it. By default you should see this cache in .gradle folder under your user directory.
For me it is
- C:\Users\athakur\.gradle\caches
- how to pinpoint exact location of the downloaded dependency jars and
- how to copy these jars to some custom directory you might want the dependencies in
Gradle script to show downloaded jars location
Note : Whenever you execute some gradle task using gradle taskName then gradle will by default try finding the task in a file named build.gradle in current directory.
Put the following code in build.gradle file -
apply plugin: 'java' repositories{ mavenCentral() } dependencies{ compile 'com.google.guava:guava:12.0' } task showMeCache << { configurations.compile.each { println it } }
and run the following command
- gradle showMeCache
Now let's see how we can copy these jar's into some custom directory of your choice.
Gradle script to copy downloaded jars to custom location
Again append the following code to build.gradle file we created while printing the downloaded jar files location.task copyDepJars(type: Copy) { from configurations.compile into 'C:\\Users\\athakur\\Desktop\\lib' }
Now run following command
- gradle copyDepJars
To know more about copy task in gradle refer - Copy - Gradle DSL Version 2.4
No comments:
Post a Comment