Merge "Test: Gradle fetch task to fetch/install cord-tester dependencies before buildImages phase."
diff --git a/build.gradle b/build.gradle
index 46acf1f..ad078ef 100644
--- a/build.gradle
+++ b/build.gradle
@@ -25,14 +25,40 @@
     cordTesterPath = project.hasProperty('cordTesterPath') ? project.getProperty('cordTesterPath') : './src/test/setup'
 
     dockerPath = project.hasProperty('dockerPath') ? project.getProperty('dockerPath') : '/usr/bin'
+
+    cordTesterAptDeps = [ 'python', 'python-dev', 'python-pip', 'python-setuptools' ]
+
+    cordTesterPipDeps = [ 'scapy', 'nose', 'monotonic', 'configObj', 'docker-py', 'pyyaml', 'nsenter', 'pyroute2', 'netaddr', 'scapy-ssl_tls' ]
 }
 
 // ~~~~~~~~~~~~~~~~~~~ Global tasks ~~~~~~~~~~~~~~~~~~~~~~~
 
+task aptFetch() {
+    // fetch the dependencies for cord tester
+    cordTesterAptDeps.each {
+        String pkg ->
+        exec {
+            executable 'apt-get'
+            args "install", "-y", pkg
+        }
+    }
+}
+
+task pipFetch() {
+    // fetch the dependencies for cord tester
+    dependsOn aptFetch
+    cordTesterPipDeps.each {
+        String pkg ->
+        exec {
+            executable 'pip'
+            args "install", "-U", pkg
+        }
+    }
+}
+
 // To be used to fetch upstream binaries, clone repos, etc.
 task fetch (type: Exec) {
-    // this is where we fetch upstream artifacts that we do not need internet for the build phase"
-    // ...
+    dependsOn pipFetch
     commandLine "$cordTesterPath/onos_pull.sh", 'latest'
 }
 
@@ -48,4 +74,3 @@
 task publish {
     println "$targetTag"
 }
-