Save external dependencies to lib folder to build offline

Thanks Cronjé, according your input i adjust my script, seems to work…

apply plugin: 'java'
  def developmentMode = true // TODO: pass as gradle argument...
def lib = "/tmp/lib"
def compileLib = "/tmp/lib/compile"
def runtimeLib = "/tmp/lib/runtime"
def testCompileLib = "/tmp/lib/testCompile"
def testRuntimLib = "/tmp/lib/testRuntime"
  repositories {
 mavenCentral()
}
  dependencies {
 if(!developmentMode){
  compile fileTree( dir: compileLib )
  runtime fileTree( dir: runtimeLib )
  testCompile fileTree( dir: testCompileLib)
  testRuntime fileTree( dir: testRuntimLib )
 }
 else {
  compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.3.5'
  testCompile group: 'junit', name: 'junit', version: '4.1'
 }
}
  task deleteLib(type: Delete) {
  onlyIf {developmentMode}
 delete lib
}
  task copyCompileToLib(type: Copy) {
 outputs.upToDateWhen {false}
 onlyIf {developmentMode}
 from configurations.compile.files
 into compileLib
}
  task copyRuntimeToLib(type: Copy) {
 outputs.upToDateWhen {false}
 onlyIf {developmentMode}
 from configurations.runtime.files
 into runtimeLib
}
  task copyTestCompileToLib(type: Copy) {
 outputs.upToDateWhen {false}
 onlyIf {developmentMode}
 from configurations.testCompile.files
 into testCompileLib
}
  task copyTestRuntimeToLib(type: Copy) {
 outputs.upToDateWhen {false}
 onlyIf {developmentMode}
    from configurations.testRuntime.files
 into testRuntimLib
}
  task copyToLib() {
 onlyIf {developmentMode}
 dependsOn copyCompileToLib, copyRuntimeToLib, copyTestCompileToLib, copyTestRuntimeToLib;
}
  copyCompileToLib.dependsOn deleteLib
copyRuntimeToLib.dependsOn deleteLib
copyTestCompileToLib.dependsOn deleteLib
copyTestRuntimeToLib.dependsOn deleteLib
compileJava.dependsOn copyToLib

…but, the build is not declarative and readable anymore…according to my understanding, this logic should be mapped to a gradle plugin…i will learn how to write a plugin and post my solution. :slight_smile: