Put dependencies and their versions into one place.

Support library modules were hardcoding versions of each library
each each build.gradle file. This change moves all these to
buildSrc/dependencies.gradle so we can update the version in the
future with a single file change.

Test: ./gradlew clean assemble assembleAndroidTest still works.
Change-Id: I4238c1182c095ae80d1d6dbb751f71c0ddfe191f
diff --git a/build.gradle b/build.gradle
index 68cc5a0..cea6a64 100644
--- a/build.gradle
+++ b/build.gradle
@@ -19,18 +19,21 @@
 import groovy.io.FileType
 
 buildscript {
+    apply from: 'buildSrc/dependencies.gradle'
+
     repositories {
         maven { url '../../prebuilts/gradle-plugin' }
         maven { url '../../prebuilts/tools/common/m2/repository' }
         maven { url '../../prebuilts/tools/common/m2/internal' }
-        maven { url "../../prebuilts/maven_repo/android" }
+        maven { url '../../prebuilts/maven_repo/android' }
     }
     dependencies {
-        // Keep gradle plugin version in sync with ub_supportlib-master manifest.
-        classpath 'com.android.tools.build:gradle:2.2.4'
+        classpath libs.gradle
     }
 }
 
+apply from: 'buildSrc/dependencies.gradle'
+
 repositories {
     maven { url '../../prebuilts/tools/common/m2/repository' }
 }
@@ -43,8 +46,8 @@
 dependencies {
     doclava project(':doclava')
     jdiff project(':jdiff')
-    jdiff 'xerces:xmlParserAPIs:2.6.2'
-    jdiff 'xerces:xercesImpl:2.6.2'
+    jdiff libs.xml_parser_apis
+    jdiff libs.xerces_impl
 }
 
 // Version code components.
@@ -53,10 +56,6 @@
 // This number gets incremented for each public release.
 ext.extraVersion = 41
 
-// Dependency versions.
-ext.testRunnerVersion = '0.6-alpha'
-ext.espressoVersion = '2.3-alpha'
-
 // Enforce the use of prebuilt dependencies in all sub-projects. This is
 // required for the doclava dependency.
 ext.usePrebuilts = "true"
diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle
index 0fc5a1e..ae9582a 100644
--- a/buildSrc/build.gradle
+++ b/buildSrc/build.gradle
@@ -1,12 +1,13 @@
 apply plugin: 'groovy'
 
+apply from: "dependencies.gradle"
+
 repositories {
     maven { url '../../../prebuilts/gradle-plugin' }
     maven { url '../../../prebuilts/tools/common/m2/repository' }
     maven { url '../../../prebuilts/tools/common/m2/internal' }
-    maven { url "../../../prebuilts/maven_repo/android" }
+    maven { url '../../../prebuilts/maven_repo/android' }
 }
 dependencies {
-    // Keep gradle plugin version in sync with ub_supportlib-master manifest.
-    compile 'com.android.tools.build:gradle:2.2.4'
+    compile libs.gradle
 }
diff --git a/buildSrc/dependencies.gradle b/buildSrc/dependencies.gradle
new file mode 100644
index 0000000..ba08b5f
--- /dev/null
+++ b/buildSrc/dependencies.gradle
@@ -0,0 +1,20 @@
+// Add ext.libs for library versions
+def libs = [:]
+
+// Testing dependencies
+libs.mockito_core = 'org.mockito:mockito-core:1.9.5'
+libs.dexmaker = 'com.google.dexmaker:dexmaker:1.2'
+libs.dexmaker_mockito = 'com.google.dexmaker:dexmaker-mockito:1.2'
+libs.junit = 'junit:junit:4.12'
+libs.test_runner = 'com.android.support.test:runner:0.6-alpha'
+libs.espresso_core = 'com.android.support.test.espresso:espresso-core:2.3-alpha'
+libs.espresso_contrib = 'com.android.support.test.espresso:espresso-contrib:2.3-alpha'
+
+// Keep gradle plugin version in sync with ub_supportlib-master manifest.
+libs.gradle = 'com.android.tools.build:gradle:2.2.4'
+
+// Other dependencies
+libs.xml_parser_apis = 'xerces:xmlParserAPIs:2.6.2'
+libs.xerces_impl = 'xerces:xercesImpl:2.6.2'
+
+rootProject.ext['libs'] = libs
diff --git a/compat/build.gradle b/compat/build.gradle
index d5e6aee..68b4d42 100644
--- a/compat/build.gradle
+++ b/compat/build.gradle
@@ -3,16 +3,16 @@
 
 dependencies {
     compile project(':support-annotations')
-    androidTestCompile ("com.android.support.test:runner:${project.rootProject.ext.testRunnerVersion}") {
+
+    androidTestCompile (libs.test_runner) {
         exclude module: 'support-annotations'
     }
-    androidTestCompile ("com.android.support.test.espresso:espresso-core:${project.rootProject.ext.espressoVersion}") {
+    androidTestCompile (libs.espresso_core) {
         exclude module: 'support-annotations'
     }
-    androidTestCompile 'org.mockito:mockito-core:1.9.5'
-    androidTestCompile 'com.google.dexmaker:dexmaker:1.2'
-    androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'
-    testCompile 'junit:junit:4.12'
+    androidTestCompile libs.mockito_core
+    androidTestCompile libs.dexmaker
+    androidTestCompile libs.dexmaker_mockito
 }
 
 android {
diff --git a/core-ui/build.gradle b/core-ui/build.gradle
index 1b888a1..92b8650 100644
--- a/core-ui/build.gradle
+++ b/core-ui/build.gradle
@@ -4,16 +4,16 @@
 dependencies {
     compile project(':support-annotations')
     compile project(':support-compat')
-    androidTestCompile ("com.android.support.test:runner:${project.rootProject.ext.testRunnerVersion}") {
+
+    androidTestCompile (libs.test_runner) {
         exclude module: 'support-annotations'
     }
-    androidTestCompile ("com.android.support.test.espresso:espresso-core:${project.rootProject.ext.espressoVersion}") {
+    androidTestCompile (libs.espresso_core) {
         exclude module: 'support-annotations'
     }
-    androidTestCompile 'org.mockito:mockito-core:1.9.5'
-    androidTestCompile 'com.google.dexmaker:dexmaker:1.2'
-    androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'
-    testCompile 'junit:junit:4.12'
+    androidTestCompile libs.mockito_core
+    androidTestCompile libs.dexmaker
+    androidTestCompile libs.dexmaker_mockito
 }
 
 android {
diff --git a/core-utils/build.gradle b/core-utils/build.gradle
index 680d91e..23e400b 100644
--- a/core-utils/build.gradle
+++ b/core-utils/build.gradle
@@ -4,16 +4,16 @@
 dependencies {
     compile project(':support-annotations')
     compile project(':support-compat')
-    androidTestCompile ("com.android.support.test:runner:${project.rootProject.ext.testRunnerVersion}") {
+
+    androidTestCompile (libs.test_runner) {
         exclude module: 'support-annotations'
     }
-    androidTestCompile ("com.android.support.test.espresso:espresso-core:${project.rootProject.ext.espressoVersion}") {
+    androidTestCompile (libs.espresso_core) {
         exclude module: 'support-annotations'
     }
-    androidTestCompile 'org.mockito:mockito-core:1.9.5'
-    androidTestCompile 'com.google.dexmaker:dexmaker:1.2'
-    androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'
-    testCompile 'junit:junit:4.12'
+    androidTestCompile libs.mockito_core
+    androidTestCompile libs.dexmaker
+    androidTestCompile libs.dexmaker_mockito
 }
 
 android {
diff --git a/customtabs/build.gradle b/customtabs/build.gradle
index 0fcf7e8..56340c0 100644
--- a/customtabs/build.gradle
+++ b/customtabs/build.gradle
@@ -5,13 +5,9 @@
     compile project(':support-compat')
     compile project(':support-annotations')
 
-    androidTestCompile ("com.android.support.test:runner:${project.rootProject.ext.testRunnerVersion}") {
+    androidTestCompile (libs.test_runner) {
         exclude module: 'support-annotations'
     }
-    androidTestCompile ("com.android.support.test.espresso:espresso-core:${project.rootProject.ext.espressoVersion}") {
-        exclude module: 'support-annotations'
-    }
-    testCompile 'junit:junit:4.12'
 }
 
 android {
diff --git a/design/build.gradle b/design/build.gradle
index 4d9dc01..a8b95f5 100644
--- a/design/build.gradle
+++ b/design/build.gradle
@@ -7,20 +7,21 @@
     compile project(':support-recyclerview-v7')
     compile project(':support-transition')
 
-    androidTestCompile ("com.android.support.test:runner:${project.rootProject.ext.testRunnerVersion}") {
+    androidTestCompile (libs.test_runner) {
         exclude module: 'support-annotations'
     }
-    androidTestCompile ("com.android.support.test.espresso:espresso-core:${project.rootProject.ext.espressoVersion}") {
+    androidTestCompile (libs.espresso_core) {
         exclude module: 'support-annotations'
     }
-    androidTestCompile ("com.android.support.test.espresso:espresso-contrib:${project.rootProject.ext.espressoVersion}") {
+    androidTestCompile (libs.espresso_contrib) {
         exclude group: 'com.android.support'
     }
-    androidTestCompile 'org.mockito:mockito-core:1.9.5'
-    androidTestCompile 'com.google.dexmaker:dexmaker:1.2'
-    androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'
-    testCompile 'junit:junit:4.12'
-    testCompile ("com.android.support.test:runner:${project.rootProject.ext.testRunnerVersion}") {
+    androidTestCompile libs.mockito_core
+    androidTestCompile libs.dexmaker
+    androidTestCompile libs.dexmaker_mockito
+
+    testCompile libs.junit
+    testCompile ("$libs.test_runner") {
         exclude module: 'support-annotations'
     }
 }
diff --git a/fragment/build.gradle b/fragment/build.gradle
index 8b48582..a7c130e 100644
--- a/fragment/build.gradle
+++ b/fragment/build.gradle
@@ -5,16 +5,16 @@
     compile project(':support-compat')
     compile project(':support-core-ui')
     compile project(':support-core-utils')
-    androidTestCompile ("com.android.support.test:runner:${project.rootProject.ext.testRunnerVersion}") {
+
+    androidTestCompile (libs.test_runner) {
         exclude module: 'support-annotations'
     }
-    androidTestCompile ("com.android.support.test.espresso:espresso-core:${project.rootProject.ext.espressoVersion}") {
+    androidTestCompile (libs.espresso_core) {
         exclude module: 'support-annotations'
     }
-    androidTestCompile 'org.mockito:mockito-core:1.9.5'
-    androidTestCompile 'com.google.dexmaker:dexmaker:1.2'
-    androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'
-    testCompile 'junit:junit:4.12'
+    androidTestCompile libs.mockito_core
+    androidTestCompile libs.dexmaker
+    androidTestCompile libs.dexmaker_mockito
 }
 
 android {
diff --git a/graphics/drawable/animated/build.gradle b/graphics/drawable/animated/build.gradle
index 56eafd8..69a30b8 100644
--- a/graphics/drawable/animated/build.gradle
+++ b/graphics/drawable/animated/build.gradle
@@ -3,13 +3,12 @@
 
 dependencies {
     compile project(':support-vector-drawable')
-    androidTestCompile ("com.android.support.test:runner:${project.rootProject.ext.testRunnerVersion}") {
+    androidTestCompile (libs.test_runner) {
         exclude module: 'support-annotations'
     }
-    androidTestCompile ("com.android.support.test.espresso:espresso-core:${project.rootProject.ext.espressoVersion}") {
+    androidTestCompile (libs.espresso_core) {
         exclude module: 'support-annotations'
     }
-    testCompile 'junit:junit:4.12'
 }
 
 android {
diff --git a/graphics/drawable/static/build.gradle b/graphics/drawable/static/build.gradle
index bf342b5..f3eb369 100644
--- a/graphics/drawable/static/build.gradle
+++ b/graphics/drawable/static/build.gradle
@@ -4,13 +4,9 @@
 dependencies {
     compile project(':support-annotations')
     compile project(':support-compat')
-    androidTestCompile ("com.android.support.test:runner:${project.rootProject.ext.testRunnerVersion}") {
+    androidTestCompile (libs.test_runner) {
         exclude module: 'support-annotations'
     }
-    androidTestCompile ("com.android.support.test.espresso:espresso-core:${project.rootProject.ext.espressoVersion}") {
-        exclude module: 'support-annotations'
-    }
-    testCompile 'junit:junit:4.12'
 }
 
 android {
diff --git a/media-compat/build.gradle b/media-compat/build.gradle
index 4044784..2ce0917 100644
--- a/media-compat/build.gradle
+++ b/media-compat/build.gradle
@@ -4,15 +4,16 @@
 dependencies {
     compile project(':support-annotations')
     compile project(':support-compat')
-    androidTestCompile ("com.android.support.test:runner:${project.rootProject.ext.testRunnerVersion}") {
+
+    androidTestCompile (libs.test_runner) {
         exclude module: 'support-annotations'
     }
-    androidTestCompile ("com.android.support.test.espresso:espresso-core:${project.rootProject.ext.espressoVersion}") {
+    androidTestCompile (libs.espresso_core) {
         exclude module: 'support-annotations'
     }
-    androidTestCompile 'org.mockito:mockito-core:1.9.5'
-    androidTestCompile 'com.google.dexmaker:dexmaker:1.2'
-    androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'
+    androidTestCompile libs.mockito_core
+    androidTestCompile libs.dexmaker
+    androidTestCompile libs.dexmaker_mockito
 }
 
 android {
diff --git a/percent/build.gradle b/percent/build.gradle
index 30aa2b8..6673bb9 100644
--- a/percent/build.gradle
+++ b/percent/build.gradle
@@ -4,13 +4,12 @@
 dependencies {
     compile project(':support-compat')
 
-    androidTestCompile ("com.android.support.test:runner:${project.rootProject.ext.testRunnerVersion}") {
+    androidTestCompile (libs.test_runner) {
         exclude module: 'support-annotations'
     }
-    androidTestCompile ("com.android.support.test.espresso:espresso-core:${project.rootProject.ext.espressoVersion}") {
+    androidTestCompile (libs.espresso_core) {
         exclude module: 'support-annotations'
     }
-    testCompile 'junit:junit:4.12'
 }
 
 android {
diff --git a/transition/build.gradle b/transition/build.gradle
index 637efd5..5cfbac8 100644
--- a/transition/build.gradle
+++ b/transition/build.gradle
@@ -6,16 +6,12 @@
     compile project(':support-annotations')
     compile project(':support-v4')
 
-    androidTestCompile ("com.android.support.test:runner:${project.rootProject.ext.testRunnerVersion}") {
+    androidTestCompile (libs.test_runner) {
         exclude module: 'support-annotations'
     }
-    androidTestCompile ("com.android.support.test.espresso:espresso-core:${project.rootProject.ext.espressoVersion}") {
+    androidTestCompile (libs.espresso_core) {
         exclude module: 'support-annotations'
     }
-    androidTestCompile 'org.mockito:mockito-core:1.9.5'
-    androidTestCompile 'com.google.dexmaker:dexmaker:1.2'
-    androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'
-    testCompile 'junit:junit:4.12'
 }
 
 android {
diff --git a/v13/build.gradle b/v13/build.gradle
index 3b3e31c..489f6c7 100644
--- a/v13/build.gradle
+++ b/v13/build.gradle
@@ -5,15 +5,15 @@
     compile project(':support-annotations')
     compile project(':support-v4')
 
-    androidTestCompile ("com.android.support.test:runner:${project.rootProject.ext.testRunnerVersion}") {
+    androidTestCompile (libs.test_runner) {
         exclude module: 'support-annotations'
     }
-    androidTestCompile ("com.android.support.test.espresso:espresso-core:${project.rootProject.ext.espressoVersion}") {
+    androidTestCompile (libs.espresso_core) {
         exclude module: 'support-annotations'
     }
-    androidTestCompile "org.mockito:mockito-core:1.9.5"
-    androidTestCompile "com.google.dexmaker:dexmaker:1.2"
-    androidTestCompile "com.google.dexmaker:dexmaker-mockito:1.2"
+    androidTestCompile libs.mockito_core
+    androidTestCompile libs.dexmaker
+    androidTestCompile libs.dexmaker_mockito
 }
 
 android {
diff --git a/v17/leanback/build.gradle b/v17/leanback/build.gradle
index 8eb4636..4235b76 100644
--- a/v17/leanback/build.gradle
+++ b/v17/leanback/build.gradle
@@ -7,16 +7,16 @@
     compile project(':support-media-compat')
     compile project(':support-fragment')
     compile project(':support-recyclerview-v7')
-    androidTestCompile ("com.android.support.test:runner:${project.rootProject.ext.testRunnerVersion}") {
+
+    androidTestCompile (libs.test_runner) {
         exclude module: 'support-annotations'
     }
-    androidTestCompile ("com.android.support.test.espresso:espresso-core:${project.rootProject.ext.espressoVersion}") {
+    androidTestCompile (libs.espresso_core) {
         exclude module: 'support-annotations'
     }
-    testCompile 'junit:junit:4.12'
-    androidTestCompile "org.mockito:mockito-core:1.9.5"
-    androidTestCompile "com.google.dexmaker:dexmaker:1.2"
-    androidTestCompile "com.google.dexmaker:dexmaker-mockito:1.2"
+    androidTestCompile libs.mockito_core
+    androidTestCompile libs.dexmaker
+    androidTestCompile libs.dexmaker_mockito
 }
 
 android {
diff --git a/v7/appcompat/build.gradle b/v7/appcompat/build.gradle
index b571334..c8c35c20 100644
--- a/v7/appcompat/build.gradle
+++ b/v7/appcompat/build.gradle
@@ -7,16 +7,15 @@
     compile project(':support-vector-drawable')
     compile project(':support-animated-vector-drawable')
 
-    androidTestCompile ("com.android.support.test:runner:${project.rootProject.ext.testRunnerVersion}") {
+    androidTestCompile (libs.test_runner) {
         exclude module: 'support-annotations'
     }
-    androidTestCompile ("com.android.support.test.espresso:espresso-core:${project.rootProject.ext.espressoVersion}") {
+    androidTestCompile (libs.espresso_core) {
         exclude module: 'support-annotations'
     }
-    androidTestCompile 'org.mockito:mockito-core:1.9.5'
-    androidTestCompile 'com.google.dexmaker:dexmaker:1.2'
-    androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'
-    testCompile 'junit:junit:4.12'
+    androidTestCompile libs.mockito_core
+    androidTestCompile libs.dexmaker
+    androidTestCompile libs.dexmaker_mockito
 }
 
 android {
diff --git a/v7/gridlayout/build.gradle b/v7/gridlayout/build.gradle
index b2fea02..ebce457 100644
--- a/v7/gridlayout/build.gradle
+++ b/v7/gridlayout/build.gradle
@@ -5,13 +5,12 @@
     compile project(':support-compat')
     compile project(':support-core-ui')
 
-    androidTestCompile ("com.android.support.test:runner:${project.rootProject.ext.testRunnerVersion}") {
+    androidTestCompile (libs.test_runner) {
         exclude module: 'support-annotations'
     }
-    androidTestCompile ("com.android.support.test.espresso:espresso-core:${project.rootProject.ext.espressoVersion}") {
+    androidTestCompile (libs.espresso_core) {
         exclude module: 'support-annotations'
     }
-    testCompile 'junit:junit:4.12'
 }
 
 android {
diff --git a/v7/mediarouter/build.gradle b/v7/mediarouter/build.gradle
index 936496a..a824d42 100644
--- a/v7/mediarouter/build.gradle
+++ b/v7/mediarouter/build.gradle
@@ -5,8 +5,7 @@
     compile project(":support-appcompat-v7")
     compile project(":support-palette-v7")
 
-    androidTestCompile ("com.android.support.test:runner:${project.rootProject.ext.testRunnerVersion}")
-    testCompile 'junit:junit:4.12'
+    androidTestCompile libs.test_runner
 }
 
 android {
diff --git a/v7/palette/build.gradle b/v7/palette/build.gradle
index be16341..e6da4c7 100644
--- a/v7/palette/build.gradle
+++ b/v7/palette/build.gradle
@@ -5,10 +5,9 @@
     compile project(':support-compat')
     compile project(':support-core-utils')
 
-    androidTestCompile ("com.android.support.test:runner:${project.rootProject.ext.testRunnerVersion}") {
+    androidTestCompile (libs.test_runner) {
         exclude module: 'support-annotations'
     }
-    testCompile 'junit:junit:4.12'
 }
 
 android {
diff --git a/v7/preference/build.gradle b/v7/preference/build.gradle
index 0acb240..ea7f159b 100644
--- a/v7/preference/build.gradle
+++ b/v7/preference/build.gradle
@@ -22,13 +22,12 @@
     compile project(':support-appcompat-v7')
     compile project(':support-recyclerview-v7')
 
-    androidTestCompile ("com.android.support.test:runner:${project.rootProject.ext.testRunnerVersion}") {
+    androidTestCompile (libs.test_runner) {
         exclude module: 'support-annotations'
     }
-    androidTestCompile ("com.android.support.test.espresso:espresso-core:${project.rootProject.ext.espressoVersion}") {
+    androidTestCompile (libs.espresso_core) {
         exclude module: 'support-annotations'
     }
-    testCompile 'junit:junit:4.12'
 }
 
 android {
diff --git a/v7/recyclerview/build.gradle b/v7/recyclerview/build.gradle
index 0ab61c9..23990af 100644
--- a/v7/recyclerview/build.gradle
+++ b/v7/recyclerview/build.gradle
@@ -5,20 +5,22 @@
     compile project(':support-annotations')
     compile project(':support-compat')
     compile project(':support-core-ui')
-    androidTestCompile ("com.android.support.test:runner:${project.rootProject.ext.testRunnerVersion}") {
+
+    androidTestCompile (libs.test_runner) {
         exclude module: 'support-annotations'
     }
-    androidTestCompile ("com.android.support.test.espresso:espresso-core:${project.rootProject.ext.espressoVersion}") {
+    androidTestCompile (libs.espresso_core) {
         exclude module: 'support-annotations'
     }
-    testCompile 'junit:junit:4.12'
-    testCompile "org.mockito:mockito-core:1.9.5"
-    testCompile ("com.android.support.test:runner:${project.rootProject.ext.testRunnerVersion}") {
+    androidTestCompile libs.mockito_core
+    androidTestCompile libs.dexmaker
+    androidTestCompile libs.dexmaker_mockito
+
+    testCompile libs.junit
+    testCompile libs.mockito_core
+    testCompile ("$libs.test_runner") {
         exclude module: 'support-annotations'
     }
-    androidTestCompile "org.mockito:mockito-core:1.9.5"
-    androidTestCompile "com.google.dexmaker:dexmaker:1.2"
-    androidTestCompile "com.google.dexmaker:dexmaker-mockito:1.2"
 }
 
 android {
diff --git a/wearable/build.gradle b/wearable/build.gradle
index 2102c4f..ddd04e8 100644
--- a/wearable/build.gradle
+++ b/wearable/build.gradle
@@ -4,20 +4,13 @@
 dependencies {
     compile project(':support-annotations')
     compile project(':support-core-ui')
-    androidTestCompile ("com.android.support.test:runner:${project.rootProject.ext.testRunnerVersion}") {
+
+    androidTestCompile (libs.test_runner) {
         exclude module: 'support-annotations'
     }
-    androidTestCompile ("com.android.support.test.espresso:espresso-core:${project.rootProject.ext.espressoVersion}") {
+    androidTestCompile (libs.espresso_core) {
         exclude module: 'support-annotations'
     }
-    testCompile 'junit:junit:4.12'
-    testCompile "org.mockito:mockito-core:1.9.5"
-    testCompile ("com.android.support.test:runner:${project.rootProject.ext.testRunnerVersion}") {
-        exclude module: 'support-annotations'
-    }
-    androidTestCompile "org.mockito:mockito-core:1.9.5"
-    androidTestCompile "com.google.dexmaker:dexmaker:1.2"
-    androidTestCompile "com.google.dexmaker:dexmaker-mockito:1.2"
 }
 
 android {