How do you programmatically access the android sourceSets output directory?

How do you programmatically access the android sourceSets output directory?

With a non-android project, you’d run ‘sourceSets.main.output.classesDir’, but on Android, if you run that, you get the error ‘Could not find property ‘main’ on source set main.’ Further inspection shows that the AndroidSourceSets are different objects with a different API. I looked at the source, and the comments of ‘getJava’ mention “Returns the Java source which is to be compiled by the Java compiler into the class output directory.” (see https://android.googlesource.com/platform/tools/base/+/b71fc0911866e76e447ddc9f0197bc6a5eba0e6e/build-system/gradle/src/main/groovy/com/android/build/gradle/api/AndroidSourceSet.groovy). However, I don’t see anywhere to access this output directory. I need to access this programmatically because as explained in this post: http://forums.gradle.org/gradle/topics/eclipse_plugin_did_not_configure_default_output_directory_to_build, the output directory can be different in different cases.

Thank you for your help.