Defer calculation of compile classpath until required.
Adam Murdoch [Fri, 7 Sep 2012 02:28:25 +0000 (12:28 +1000)]
The other projects in the build may not have been configured
when the tasks for the current project are being added.

Also added a workaround for the task dependency information
going missing when the compile classpath is calculated.

Change-Id: Ica2042d70aa31ce8794e49960fb1c8fb5c9d9c0d

gradle/src/main/groovy/com/android/build/gradle/AndroidBasePlugin.groovy

index aa886ef..6ad3271 100644 (file)
@@ -295,13 +295,16 @@ abstract class AndroidBasePlugin {
 
         // if the test is for a full app, the tested runtimeClasspath is added to the classpath for
         // compilation only, not for packaging
-        variant.packagedClasspath = project.files(config.compileClasspath)
+        variant.packagedClasspath = project.files({config.compileClasspath})
         if (testedVariant != null &&
                 testedVariant.config.type != VariantConfiguration.Type.LIBRARY) {
             compileTask.classpath = variant.packagedClasspath + testedVariant.runtimeClasspath
         } else {
             compileTask.classpath = variant.packagedClasspath
         }
+        // TODO - dependency information for the compile classpath is being lost.
+        // Add a temporary approximation
+        compileTask.dependsOn project.configurations.compile.buildDependencies
 
         compileTask.conventionMapping.destinationDir = {
             project.file("$project.buildDir/classes/$variant.dirName")