Build CLI using Gradle

issue #185: introduce playbook for generating and deploying the CLI tarball

issue #185 don't deploy consul on ansible host

issue #187 add old Dockerfile for now. will be removed later.

issue #185 fix travis test

Signed-off-by: Hoang Anh Le <hoang@de.ibm.com>
diff --git a/tools/cli/.gitignore b/tools/cli/.gitignore
index 18ff1e1..0904ca7 100755
--- a/tools/cli/.gitignore
+++ b/tools/cli/.gitignore
@@ -1,2 +1,3 @@
 default.props
-
+build
+.project
\ No newline at end of file
diff --git a/tools/cli/.project b/tools/cli/.project
deleted file mode 100644
index 3636b7b..0000000
--- a/tools/cli/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-	<name>cli</name>
-	<comment></comment>
-	<projects>
-	</projects>
-	<buildSpec>
-		<buildCommand>
-			<name>org.python.pydev.PyDevBuilder</name>
-			<arguments>
-			</arguments>
-		</buildCommand>
-	</buildSpec>
-	<natures>
-		<nature>org.python.pydev.pythonNature</nature>
-	</natures>
-</projectDescription>
diff --git a/tools/cli/Dockerfile b/tools/cli/Dockerfile
new file mode 100644
index 0000000..53ba65a
--- /dev/null
+++ b/tools/cli/Dockerfile
@@ -0,0 +1,12 @@
+FROM ubuntu:14.04
+
+ENV DEBIAN_FRONTEND noninteractive
+
+RUN apt-get update --fix-missing && \
+  apt-get -y dist-upgrade && \
+  apt-get -y install python2.7 && \
+  apt-get -y install python-distribute python-pip && \
+  apt-get clean
+
+ADD build/tmp /cli
+CMD cd /cli && python setup.py sdist
\ No newline at end of file
diff --git a/tools/cli/build.gradle b/tools/cli/build.gradle
new file mode 100644
index 0000000..4bf5876
--- /dev/null
+++ b/tools/cli/build.gradle
@@ -0,0 +1,53 @@
+apply plugin: 'eclipse'
+eclipse {
+    project {
+        natures 'org.python.pydev.pythonNature'
+        buildCommand 'org.python.pydev.PyDevBuilder'
+    }
+}
+
+ext.dockerImageName = 'whisk/cli'
+apply from: '../../docker.gradle'
+
+task clean(type: Delete) {
+    delete 'build'
+}
+
+task removeDistribution(type: Delete) {
+    delete 'build/distributions'
+}
+
+task establishStructure(type: Copy) {
+    into 'build/tmp'
+    from('packagescripts') {
+        include '*.rst', '*.in', 'setup.py'
+    }
+
+    into('openwhisk') {
+        from('.') {
+            include '*.py', 'wsk'
+            rename('^wsk$', 'wsk.py')
+        }
+        from('packagescripts') {
+            include '__init__.py'
+        }
+    }
+}
+distDocker.dependsOn(establishStructure)
+
+task distTar(dependsOn: [removeDistribution, distDocker]) << {
+    run "docker rm -f cli"
+    run "docker run --name cli whisk/cli"
+    run "docker cp cli:/cli/dist/ ${buildDir}/distributions/"
+    run "docker rm -f cli"
+}
+distDocker.finalizedBy(distTar)
+
+def run(cmd) {
+    println("Executing '${cmd}'")
+    def proc = cmd.execute()
+    proc.waitForProcessOutput(System.out, System.err)
+    if(proc.exitValue() != 0) {
+        println("Command '${cmd}' failed with exitCode ${proc.exitValue()}")
+    }
+}