updated to calculate default values for targetRef and targetTag

Change-Id: Id34238cb13c1c36d1b960c1b0c918af828bcd085
diff --git a/build.gradle b/build.gradle
index 8fd06d5..a97ce4b 100644
--- a/build.gradle
+++ b/build.gradle
@@ -37,16 +37,33 @@
 
 ext {
 
+   // Deployment target config file (yaml format); this can be overwritten from the command line
+    // using the -PdeployConfig=<file-path> syntax.
+    deployConfig = project.hasProperty('deployConfig') ? project.getProperty('deployConfig') : './config/default.yml'
+
+    println "Using deployment config: $deployConfig"
+    File configFile = new File(deployConfig)
+    def yaml = new Yaml()
+    config = yaml.load(configFile.newReader())
+
     // Upstream registry to simplify filling out the comps table below
     upstreamReg = project.hasProperty('upstreamReg') ? project.getProperty('upstreamReg') : 'docker.io'
 
     // Target registry to be used to publish docker images needed for deployment
-    targetReg = project.hasProperty('targetReg') ? project.getProperty('targetReg') : 'localhost:5000'
+    targetReg = project.hasProperty('targetReg')
+        ? project.getProperty('targetReg')
+        : config.docker && config.docker.registry
+            ? config.docker.registry
+            : config.seedServer.ip
+                ? config.seedServer.ip + ":5000"
+                : 'localhost:5000'
 
     // The tag used to tag the docker images push to the target registry
-    targetTag = project.hasProperty('targetTag') ? project.getProperty('targetTag') : 'candidate'
-
-    deployConfig = project.hasProperty('deployConfig') ? project.getProperty('deployConfig') : './config/default.yml'
+    targetTag = project.hasProperty('targetTag')
+        ? project.getProperty('targetTag')
+        : config.docker && config.docker.imageVersion
+            ? config.docker.imageVersion
+            : 'candidate'
 }
 
 
@@ -119,11 +136,6 @@
 }
 
 task deploy (type: Exec) {
-        println "Using deployment config: $deployConfig"
-        File configFile = new File(deployConfig)
-        def yaml = new Yaml()
-        def config = yaml.load(configFile.newReader())
-
         executable = "ansible-playbook"
         args = ["-i", config.seedServer.ip + ',']