Can Gradle handle a build directory structure that does not conform default conventions?

It is very easy with Gradle to adapt to any directory structure. See the Working with source sets section of the Gradle User Guide.


Example with non-standard project directory structure (custom layout):

sourceSets {
    main {
        java {
            srcDir 'sources/main/java'
        }
        outputDir = file("$workDir/client/program")
        // For older version (now deprecated):
        //output.classesDir = "$workDir/client/program"
    }
    test {
        java {
            srcDir 'sources/test/java'
        }
        outputDir = file("$workDir/client/tests")
        // For older versions (now deprecated):
        //output.classesDir = "$workDir/client/tests"
        //output.resourcesDir = "$workDir/client/tests"
    }
    resources {
        srcDirs 'sources/test/res'
    }
}

Try:

sourceSets {
    main {
        java {
            srcDirs = ['src/java']
        }
        resources {
            srcDirs = ['src/resources']
        }
    }
}

or

sourceSets {
    main.java.srcDirs += 'src/java'
    main.resources.srcDirs += 'src/resources'
}