Bug 1513395 - Ask gradle to download all dependencies. r=nalexander
authorAgi Sferro <agi@mozilla.com>
Fri, 14 Dec 2018 21:37:37 +0000
changeset 450595 468babe629d5d72ab3dd4ce2639586a572df4f3f
parent 450594 31bf1cd657a32a8cc0127966c4b823bb2365de78
child 450596 ed2f754410ed822c5a1e2496a59eb1679346dda5
push id35207
push useraciure@mozilla.com
push dateSat, 15 Dec 2018 02:27:37 +0000
treeherdermozilla-central@d8a944c012a7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander
bugs1513395
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1513395 - Ask gradle to download all dependencies. r=nalexander This adds a task to each project called `downloadDependencies`. This task will go through each configuration and resolve every dependency so that the gradle cache contains a copy of every file needed for building and running tests. This is intended to be used together with our nexus oss database but it can be used locally too. Note: `downloadDependencies` does not download dependencies added a runtime, e.g. by plugins like apilint, checkstyle, findbugs... so we still need to run those tasks to collect their dependencies. Depends on D14516 Differential Revision: https://phabricator.services.mozilla.com/D14622
build.gradle
mobile/android/gradle.configure
--- a/build.gradle
+++ b/build.gradle
@@ -35,16 +35,41 @@ allprojects {
         // For in tree dependencies.
         // TODO: remove this once
         // https://issuetracker.google.com/issues/120951637 is resolved. See
         // also Bug 1514374.
         maven {
             url "file://${gradle.mozconfig.topsrcdir}/mobile/android/gradle/m2repo"
         }
     }
+
+    task downloadDependencies() {
+        description 'Download all dependencies to the Gradle cache'
+        doLast {
+            configurations.each { configuration ->
+                if (configuration.canBeResolved) {
+                    configuration.allDependencies.each { dependency ->
+                        try {
+                            configuration.files(dependency)
+                        } catch(e) {
+                            println("Could not resolve ${configuration.name} -> ${dependency.name}")
+                            println(" > ${e.message}")
+                            if (e.cause) {
+                                println(" >> ${e.cause}")
+                                if (e.cause.cause) {
+                                    println(" >> ${e.cause.cause}")
+                                }
+                            }
+                            println("")
+                        }
+                    }
+                }
+            }
+        }
+    }
 }
 
 buildDir "${topobjdir}/gradle/build"
 
 buildscript {
     repositories {
         gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
             maven {
--- a/mobile/android/gradle.configure
+++ b/mobile/android/gradle.configure
@@ -301,28 +301,30 @@ def gradle_android_install_geckoview_exa
     return [
         'geckoview_example:install{geckoview_example.variant.name}'.format(geckoview_example=build_config.geckoview_example),
         'geckoview_example:install{geckoview_example.variant.name}AndroidTest'.format(geckoview_example=build_config.geckoview_example),
     ]
 
 set_config('GRADLE_ANDROID_INSTALL_GECKOVIEW_EXAMPLE_TASKS', gradle_android_install_geckoview_example_tasks)
 
 
+@dependable
+def gradle_android_dependencies():
+    '''Gradle tasks that download all dependencies.'''
+    # These tasks download most dependencies from each configuration, the
+    # notable exception is dependencies added at runtime by gradle plugins
+    return [
+        'downloadDependencies',
+    ]
+
 @depends(
-    gradle_android_app_tasks,
     gradle_android_api_lint_tasks,
-    gradle_android_test_tasks,
-    gradle_android_lint_tasks,
     gradle_android_checkstyle_tasks,
     gradle_android_findbugs_tasks,
-    gradle_android_archive_geckoview_tasks,
-    gradle_android_generate_sdk_bindings_tasks,
-    gradle_android_generate_generated_jni_wrappers_tasks,
-    gradle_android_generate_fennec_jni_wrappers_tasks,
-    gradle_android_archive_coverage_artifacts_tasks,
+    gradle_android_dependencies,
 )
 @imports(_from='itertools', _import='imap')
 @imports(_from='itertools', _import='chain')
 @imports(_from='itertools', _import='ifilterfalse')
 def gradle_android_dependencies_tasks(*tasks):
     '''Gradle tasks run by |mach android dependencies|.'''
     # The union, plus a bit more, of all of the Gradle tasks
     # invoked by the android-* automation jobs.