I found that the destinationDir property of applicationVariants can be added to the javaCompile.classpath property, which will result in a FileCollection that contains the dependency class classes and compiled classes.
My use case is trying to execute a java executable postcompile:
afterEvaluate { android.applicationVariants.each { variant -> variant.javaCompile.doLast { javaexec { classpath += variant.javaCompile.classpath classpath += files(variant.javaCompile.destinationDir) main = 'com.mydomain.Main' } } } }
Tested on Android Studio 2.1.1 with the launch of 'com.android.tools.build:gradle:2.1.0' and gradle 2.10.
Link: http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Shrinking-Resources
source share