use url resource for docker-tag -- docker

use groovy url resource from docker repo
to identify the tag for docker

With this change, the "SNAPSHOT-latest" docker
tag will change from "2.3.0-SNAPSHOT-latest"
to "2.3-SNAPSHOT-latest" for jdk/jre alpine base
image as well as db_migrator docker.

Also fix a bug in println groovy script.

Issue-ID: POLICY-3378
Change-Id: I72bd15e2535f688629ee5f1a823409d8fe83cdb1
Signed-off-by: Taka Cho <takamune.cho@att.com>
diff --git a/policy-db-migrator/pom.xml b/policy-db-migrator/pom.xml
index 709f817..dd3a32c 100644
--- a/policy-db-migrator/pom.xml
+++ b/policy-db-migrator/pom.xml
@@ -48,9 +48,9 @@
         <finalName>${project.artifactId}-${project.version}</finalName>
         <plugins>
             <plugin>
-                <groupId>org.codehaus.groovy.maven</groupId>
-                <artifactId>gmaven-plugin</artifactId>
-                <version>1.0</version>
+                <groupId>org.codehaus.gmaven</groupId>
+                <artifactId>groovy-maven-plugin</artifactId>
+                <version>2.1.1</version>
                 <executions>
                     <execution>
                         <phase>validate</phase>
@@ -58,21 +58,7 @@
                             <goal>execute</goal>
                         </goals>
                         <configuration>
-                            <source>
-                                println 'Project version: ' + project.properties['dist.project.version'];
-                                def versionArray;
-                                if ( project.properties['dist.project.version'] != null ) {
-                                    versionArray = project.properties['dist.project.version'].split('-');
-                                }
-
-                                if ( project.properties['dist.project.version'].endsWith("-SNAPSHOT") ) {
-                                    project.properties['project.docker.latesttag.version']=versionArray[0] + "-SNAPSHOT-latest";
-                                } else {
-                                    project.properties['project.docker.latesttag.version']=versionArray[0] + "-STAGING-latest";
-                                }
-
-                                println 'New tag for docker: ' + project.properties['project.docker.latesttag.version'];
-                            </source>
+                            <source>https://github.com/onap/policy-docker/raw/master/utils/groovy/docker-tag.groovy</source>
                         </configuration>
                     </execution>
                 </executions>
@@ -95,7 +81,7 @@
                                 <tags>
                                     <tag>${project.version}</tag>
                                     <tag>${project.version}-${maven.build.timestamp}</tag>
-                                    <tag>${project.docker.latesttag.version}</tag>
+                                    <tag>${project.docker.latest.minmax.tag.version}</tag>
                                 </tags>
                             </build>
                         </image>
diff --git a/policy-jdk/alpine/pom.xml b/policy-jdk/alpine/pom.xml
index c89cd7d..a4a3a10 100644
--- a/policy-jdk/alpine/pom.xml
+++ b/policy-jdk/alpine/pom.xml
@@ -43,9 +43,9 @@
         <finalName>${project.artifactId}-${project.version}</finalName>
         <plugins>
             <plugin>
-                <groupId>org.codehaus.groovy.maven</groupId>
-                <artifactId>gmaven-plugin</artifactId>
-                <version>1.0</version>
+                <groupId>org.codehaus.gmaven</groupId>
+                <artifactId>groovy-maven-plugin</artifactId>
+                <version>2.1.1</version>
                 <executions>
                     <execution>
                         <phase>validate</phase>
@@ -53,21 +53,7 @@
                             <goal>execute</goal>
                         </goals>
                         <configuration>
-                            <source>
-                                println 'Project version: ' + project.properties['dist.project.version'];
-                                def versionArray;
-                                if ( project.properties['dist.project.version'] != null ) {
-                                    versionArray = project.properties['dist.project.version'].split('-');
-                                }
-
-                                if ( project.properties['dist.project.version'].endsWith("-SNAPSHOT") ) {
-                                    project.properties['project.docker.latesttag.version']=versionArray[0] + "-SNAPSHOT-latest";
-                                } else {
-                                    project.properties['project.docker.latesttag.version']=versionArray[0] + "-STAGING-latest";
-                                }
-
-                                println 'New tag for docker: ' + project.properties['project.docker.latesttag.version'];
-                            </source>
+                            <source>https://github.com/onap/policy-docker/raw/master/utils/groovy/docker-tag.groovy</source>
                         </configuration>
                     </execution>
                 </executions>
@@ -90,7 +76,7 @@
                                 <tags>
                                     <tag>${project.version}</tag>
                                     <tag>${project.version}-${maven.build.timestamp}</tag>
-                                    <tag>${project.docker.latesttag.version}</tag>
+                                    <tag>${project.docker.latest.minmax.tag.version}</tag>
                                 </tags>
                             </build>
                         </image>
diff --git a/policy-jre/alpine/pom.xml b/policy-jre/alpine/pom.xml
index 2132209..50617c7 100644
--- a/policy-jre/alpine/pom.xml
+++ b/policy-jre/alpine/pom.xml
@@ -43,9 +43,9 @@
         <finalName>${project.artifactId}-${project.version}</finalName>
         <plugins>
             <plugin>
-                <groupId>org.codehaus.groovy.maven</groupId>
-                <artifactId>gmaven-plugin</artifactId>
-                <version>1.0</version>
+                <groupId>org.codehaus.gmaven</groupId>
+                <artifactId>groovy-maven-plugin</artifactId>
+                <version>2.1.1</version>
                 <executions>
                     <execution>
                         <phase>validate</phase>
@@ -53,21 +53,7 @@
                             <goal>execute</goal>
                         </goals>
                         <configuration>
-                            <source>
-                                println 'Project version: ' + project.properties['dist.project.version'];
-                                def versionArray;
-                                if ( project.properties['dist.project.version'] != null ) {
-                                    versionArray = project.properties['dist.project.version'].split('-');
-                                }
-
-                                if ( project.properties['dist.project.version'].endsWith("-SNAPSHOT") ) {
-                                    project.properties['project.docker.latesttag.version']=versionArray[0] + "-SNAPSHOT-latest";
-                                } else {
-                                    project.properties['project.docker.latesttag.version']=versionArray[0] + "-STAGING-latest";
-                                }
-
-                                println 'New tag for docker: ' + project.properties['project.docker.latesttag.version'];
-                            </source>
+                            <source>https://github.com/onap/policy-docker/raw/master/utils/groovy/docker-tag.groovy</source>
                         </configuration>
                     </execution>
                 </executions>
@@ -90,7 +76,7 @@
                                 <tags>
                                     <tag>${project.version}</tag>
                                     <tag>${project.version}-${maven.build.timestamp}</tag>
-                                    <tag>${project.docker.latesttag.version}</tag>
+                                    <tag>${project.docker.latest.minmax.tag.version}</tag>
                                 </tags>
                             </build>
                         </image>
diff --git a/utils/groovy/docker-tag.groovy b/utils/groovy/docker-tag.groovy
index 432deb9..1360974 100644
--- a/utils/groovy/docker-tag.groovy
+++ b/utils/groovy/docker-tag.groovy
@@ -30,5 +30,5 @@
         project.properties['project.docker.latest.minmax.tag.version'] =
              minMaxVersionArray[0] + "." + minMaxVersionArray[1] + "-STAGING-latest"
      }
-     println 'New tag for docker: ' + properties['project.docker.latest.minmax.tag.version']
+     println 'New tag for docker: ' + project.properties['project.docker.latest.minmax.tag.version']
 }