Inspired by Dmytro Danylyk post about using sourceSets to have deep project structure in android, i’ve written small gradle plugin to automate this task.

To use it in you project add this to top level build.gradle

buildscript {
    repositories {
        ///...
        maven {
            url uri('http://maven.tunebrains.com/content/repositories/android/')
        }
    }
    dependencies {
        //...
        classpath group: 'com.tunebrains', name: 'sourcesetflattener',
                version: '0.0.1'
    }
}

Apply plugin in project level build.gradle

apply plugin: 'com.tunebrains.sourcesetflattener'

Specify root directory to store screen related resources

flattener{
    root 'res-screen'
}

Sync Project with gradle files, and it will load directory structure to source set automatically.

Also works for multiple flavours.

All source code available on GitHub