shashwatZing shashwatZing - 2 months ago 19
Groovy Question

write a gradle script that saves all the dependency into the ${projectDir}/lib folder

So I have a gradle script which gets all its dependencies from the following repository

repositories {
maven { url 'http://repository.paychex.com:8081/artifactory/repo1-cache' }



ivy { url 'http://repository.paychex.com:8081/artifactory/repo1 cache'
layout 'pattern', {
artifact '[organization]/[module]/[revision]/[type]/[module]-[revision].jar'
}
}
mavenlocal()

}


so when I run a customized gradle task which i wrote as

task showMeCache << {
configurations.compile.each { println it }
}


It will show that my jars are being saved locally on

C:\Users\Administrator.gradle\caches\modules-2\files-2.1***

I want to write a gradle task that will put all the dependencies for a given project into something like a ${projectDir}/lib folder instead of the default location provided by gradle. Any help would be appreciated. Thanks

Answer

You can write a Copy task for that purpose:

task copyLibs(type: Copy) {
    from configurations.compile
    into 'lib'
}

Keep in mind that would still download and use the resolved dependencies from the Gradle cache.

Comments