How to download maven dependencies into project local directory and set eclipse classpath?

specify some maven dependencies
=>
use a dependencies block in your build.gradle

when doing a gradle run, pull the dependencies
=> this will be done automatically, if you apply for instance the 'java plugin"

copy those dependencies to project local dir (e.g. libs)
=> you could create a custom task for that
task copyDeps(type: Copy) {
from (configurations.compile+configurations.testCompile) {
include “.jar"
include "
.so”, “*.dll”
}
into rootProject.rootDir.getAbsolutePath()+“/lib”
//rename can be applied on the files if you want to remove the version from the jar for instance
}

config eclipse .project to use local jar in classpath

you want to use the eclipse plugin
‘apply plugin:eclipse’
This nice plugin will do that automatically for you (you don’t even need to copy the dependencies in a custom directory, the .classpath will directly reference the dependencies artifacts from the gradle cache directory)

if possible, all other gradle tasks (e.g. compile, test etc) use project local classpaths
Eclipse classpath is only use for Eclipse (compilation, Junit tests execution within eclipse, …)
Gradle tasks don’t need that. As long as you declare the needed dependencies in a dependencies {} block, Gradle will be OK :slight_smile: