I used to copy \'compile\' dependencies to a specific folder using this simple gradle task :
task copyLibs(type: Copy) {
from configurations.compile
This probably won't help or have a better way to solve but...
You can put your dependencies in a way that is possible to copy doing the following:
android { ... }
// Add a new configuration to hold your dependencies
configurations {
myConfig
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
// Now you have to repeat adding the dependencies you want to copy in the 'myConfig'
myConfig fileTree(dir: 'libs', include: ['*.jar'])
myConfig 'com.android.support:appcompat-v7:26.1.0'
myConfig 'com.android.support:support-v4:26.1.0'
...
}
task copyLibs(type: Copy) {
// Now you can use 'myConfig' instead of 'implementation' or 'compile'
from configurations.myConfig
into "$project.rootDir/reports/libs/"
}
This also helps if you have a Jar task that stops placing the dependencies in to the jar file because you changed from compile to implementation.
You can use:
from {configurations.myConfig.collect { it.isDirectory() ? it : zipTree(it) }}
Instead of:
from {configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }}