How to choose only some dependencies to copy to a folder?

Hello,

I have some projects and I want for each project to create a folder with it’s dependencies but ONLY this project dependencies. The thing is that most of my projects depend on another project so if I do:

task copyToLib(type: Copy) {
    from configurations.runtime
    into "$buildDir/output/lib"

}

This will copy ALL the dependencies, because of my build.gradle:

 build.gradle:
    dependencies {
        compile project('Commons')
        compile group:'com.rabbitmq', name:'amqp-client', version:'3.5.4'
        compile group:'org.twitter4j', name:'twitter4j-core', version:'[3.0,)'
    }

In this case, it will also copy dependencies from project Commons but I don’t want these, only the others. Any ideas?

Thanks

Hi Eric,

create a configuration block like this:

configurations { 
    localDeps
}

in the dependencies block, update it to:

dependencies {
    compile project('Commons')
    localDeps group:'com.rabbitmq', name:'amqp-client', version:'3.5.4'
    localDeps group:'org.twitter4j', name:'twitter4j-core', version:'[3.0,)'
    compile configurations.localDeps
}

change the Copy task to:

task copyToLib(type: Copy) {
    from configurations.localDeps
    into "$buildDir/output/lib"
}

If you don’t want all the dependencies of localDeps, update the configurations block to:

configurations { 
    localDeps
    localDeps.transitive = false
}
1 Like

Thank you very much Edson! This solved the problem.

Cheers