How redefine the directory where generated JAR files (libsDirName)?

I have multi-project buld. I need all my jar be in one directory: build/New_libs What is correct definitions for that? That one created the jar under proj1/proj2/foo1/build/libs/

//settings.gradle:
//----------------------------
include 'foo1', 'foo2'
project(":foo1").projectDir = new File (settingsDir, "proj1/proj2")
      //build.gradle
//---------------------------
  subprojects {
 apply plugin: 'java'
 rootProject.libsDirName = '${rootProject}.build.New_libs'
 println "rootProject.libsDirName = ${libsDirName}"
}

Thank you very much for your help!

‘libsDirName’ is relative to the project’s base directory, and thus cannot be used for this purpose. You’ll want something like:

subprojects {
    apply plugin: 'java'
    tasks.withType(Jar) {
        destinationDir = file("$rootDir/build/New_libs")
    }
}

Thank you! It’s help!

If I redefine the destination dir, the task clean doesn’t ‘know’ the new location. As result, the generated jar not cleaned by clean task. What is best solution for it? Can I partial override task? Or just create my new clean task?

By default, the ‘clean’ task deletes the ‘build’ directory, but it can be reconfigured as needed (see the ‘Delete’ task type in the Gradle Build Language Reference). Another option is to keep separate output directories and add another task that copies Jars into a common directory.

Please don’t ask the same question twice (http://forums.gradle.org/gradle/topics/is_it_possible_to_partial_override_clean_task). Thanks.