Test resources inclusion

I’ve found that topic: http://forums.gradle.org/gradle/topics/resources_from_src_main_resources_not_included_for_test and adding the snippet from one before last post causes that resources are added and tests are working fine but building android APK fails due to duplicate classes. Can sourceSets be altered conditionally (only for test) or maybe there is a better way to include resources in tests?

This is mentioned snippet.

sourceSets {
    main {
       output.resourcesDir = "build/classes/main"
     }
  }