Set correct phases for version and image parsing 58/94358/1
authorJimmy Forsyth <jf2512@att.com>
Tue, 27 Aug 2019 16:31:36 +0000 (12:31 -0400)
committerJimmy Forsyth <jf2512@att.com>
Tue, 27 Aug 2019 16:31:39 +0000 (12:31 -0400)
Issue-ID: AAI-2579
Signed-off-by: Jimmy Forsyth <jf2512@att.com>
Change-Id: Id6163c6788bb41380fc8ac0630f26cb3b5fabfd8

pom.xml

diff --git a/pom.xml b/pom.xml
index 60987b1..848f46c 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -379,129 +379,115 @@ limitations under the License.
             <id>docker</id>
             <build>
                 <plugins>
-
-                    <plugin>
-                        <groupId>io.fabric8</groupId>
-                        <artifactId>docker-maven-plugin</artifactId>
-                        <version>${docker.fabric.version}</version>
+                  <plugin>
+                    <groupId>org.codehaus.mojo</groupId>
+                    <artifactId>build-helper-maven-plugin</artifactId>
+                    <version>3.0.0</version>
+                    <executions>
+                      <execution>
+                        <phase>pre-clean</phase>
+                        <id>parse-version</id>
+                        <goals>
+                          <goal>parse-version</goal>
+                        </goals>
+                      </execution>
+                    </executions>
+                  </plugin>
+                  <plugin>
+                    <groupId>org.codehaus.groovy.maven</groupId>
+                    <artifactId>gmaven-plugin</artifactId>
+                    <version>1.0</version>
+                    <executions>
+                      <execution>
+                        <phase>pre-clean</phase>
+                        <goals>
+                          <goal>execute</goal>
+                        </goals>
                         <configuration>
-                            <verbose>true</verbose>
-                            <apiVersion>1.23</apiVersion>
-                            <images>
-                                <image>
-                                    <name>${docker.push.registry}/${aai.docker.namespace}/${project.artifactId}:%l
-                                    </name>
-                                    <build>
-                                        <filter>@</filter>
-                                        <tags>
-                                            <tag>latest</tag>
-                                            <tag>${project.docker.latesttag.version}</tag>
-                                            <tag>${project.major.version}.${project.minor.version}-STAGING-${maven.build.timestamp}</tag>
-                                        </tags>
-                                        <cleanup>try</cleanup>
-                                        <dockerFileDir>${project.basedir}/src/main/docker</dockerFileDir>
-                                        <assembly>
-                                            <inline>
-                                                <fileSets>
-                                                    <fileSet>
-                                                        <directory>${aai.build.directory}</directory>
-                                                        <outputDirectory>/${project.artifactId}</outputDirectory>
-                                                    </fileSet>
-                                                </fileSets>
-                                            </inline>
-                                        </assembly>
-                                    </build>
-                                </image>
-                            </images>
-                        </configuration>
-                        <executions>
-                            <execution>
-                                <id>clean-images</id>
-                                <phase>pre-clean</phase>
-                                <goals>
-                                    <goal>remove</goal>
-                                </goals>
-                                <configuration>
-                                    <removeAll>true</removeAll>
-                                </configuration>
-                            </execution>
-                            <execution>
-                                <id>generate-images</id>
-                                <phase>package</phase>
-                                <goals>
-                                    <goal>build</goal>
-                                </goals>
-                            </execution>
-                            <execution>
-                                <id>push-images</id>
-                                <phase>deploy</phase>
-                                <goals>
-                                    <goal>push</goal>
-                                </goals>
-                            </execution>
-                        </executions>
-                    </plugin>
-                    <plugin>
-                      <groupId>org.codehaus.mojo</groupId>
-                      <artifactId>build-helper-maven-plugin</artifactId>
-                      <version>3.0.0</version>
-                      <executions>
-                        <execution>
-                          <id>parse-version</id>
-                          <goals>
-                            <goal>parse-version</goal>
-                          </goals>
-                        </execution>
-                      </executions>
-                    </plugin>
-                  </plugins>
-            </build>
-        </profile>
-    </profiles>
-
-    <build>
-        <finalName>${project.artifactId}</finalName>
-       <pluginManagement>
-          <plugins>
+                          <source>
+                            def userAaiBaseImage = session.userProperties['aai.base.image']
+                            def userAaiCommonVersion = session.userProperties['aai.base.image.version']
+                            if (userAaiCommonVersion != null) {
+                               project.properties['aai.base.image.version'] = userAaiCommonVersion
+                            }
+                            if (userAaiBaseImage != null) {
+                               project.properties['aai.base.image'] = userAaiBaseImage
+                            }
+                            log.info 'Base image flavour: ' + project.properties['aai.base.image']
+                            log.info 'Base image version: ' + project.properties['aai.base.image.version']
+                  </source>
+                </configuration>
+              </execution>
+            </executions>
+            </plugin>
             <plugin>
-              <groupId>org.codehaus.groovy.maven</groupId>
-              <artifactId>gmaven-plugin</artifactId>
-              <version>1.0</version>
+              <groupId>io.fabric8</groupId>
+              <artifactId>docker-maven-plugin</artifactId>
+              <version>${docker.fabric.version}</version>
+              <configuration>
+                <verbose>true</verbose>
+                <apiVersion>1.23</apiVersion>
+                <images>
+                  <image>
+                    <name>${docker.push.registry}/${aai.docker.namespace}/${project.artifactId}:%l
+                    </name>
+                    <build>
+                      <filter>@</filter>
+                      <tags>
+                        <tag>latest</tag>
+                        <tag>${parsedVersion.majorVersion}.${parsedVersion.minorVersion}-STAGING-latest</tag>
+                        <tag>${parsedVersion.majorVersion}.${parsedVersion.minorVersion}-STAGING-${maven.build.timestamp}</tag>
+                      </tags>
+                      <cleanup>try</cleanup>
+                      <dockerFileDir>${project.basedir}/src/main/docker</dockerFileDir>
+                      <assembly>
+                        <inline>
+                          <fileSets>
+                            <fileSet>
+                              <directory>${aai.build.directory}</directory>
+                              <outputDirectory>/${project.artifactId}</outputDirectory>
+                            </fileSet>
+                          </fileSets>
+                        </inline>
+                      </assembly>
+                    </build>
+                  </image>
+                </images>
+              </configuration>
               <executions>
-               <execution>
-                  <phase>validate</phase>
+                <execution>
+                  <id>clean-images</id>
+                  <phase>pre-clean</phase>
                   <goals>
-                    <goal>execute</goal>
+                    <goal>remove</goal>
                   </goals>
                   <configuration>
-                    <source>
-                      def userAaiBaseImage = session.userProperties['aai.base.image']
-                      def userAaiCommonVersion = session.userProperties['aai.base.image.version']
-                      if (userAaiCommonVersion != null) {
-                          project.properties['aai.base.image.version'] = userAaiCommonVersion
-                      }
-                      if (userAaiBaseImage != null) {
-                          project.properties['aai.base.image'] = userAaiBaseImage
-                      }
-                      log.info 'Base image flavour: ' + project.properties['aai.base.image']
-                      log.info 'Base image version: ' + project.properties['aai.base.image.version']
-                   
-                      def versionArray;
-                      if (project.properties['aai.base.image.version'] != null) {
-                          versionArray = project.properties['aai.base.image.version'].split('\\.');
-                     }
-                   
-                      project.properties["project.major.version"] = versionArray[0];
-                      project.properties["project.minor.version"] = versionArray[1];
-                      project.properties['project.docker.latesttag.version'] = versionArray[0] + '.' + versionArray[1] + '-STAGING-latest';
-                      println 'New Tag for docker:' + project.properties['project.docker.latesttag.version'];
-                  </source>
-                </configuration>
-              </execution>
-            </executions>
+                    <removeAll>true</removeAll>
+                  </configuration>
+                </execution>
+                <execution>
+                  <id>generate-images</id>
+                  <phase>package</phase>
+                  <goals>
+                    <goal>build</goal>
+                  </goals>
+                </execution>
+                <execution>
+                  <id>push-images</id>
+                  <phase>deploy</phase>
+                  <goals>
+                    <goal>push</goal>
+                  </goals>
+                </execution>
+              </executions>
             </plugin>
           </plugins>
-       </pluginManagement>
+        </build>
+      </profile>
+    </profiles>
+
+    <build>
+        <finalName>${project.artifactId}</finalName>
         <!--
             Using https://code.revelc.net/formatter-maven-plugin/ for Eclipse formatter
             Using https://github.com/diffplug/spotless/tree/master/plugin-maven for import order
@@ -521,6 +507,10 @@ limitations under the License.
                      use mvn formatter:format to rewrite source files
                      use mvn formatter:validate to validate source files -->
             </plugin>
+           <plugin>
+             <groupId>org.codehaus.groovy.maven</groupId>
+             <artifactId>gmaven-plugin</artifactId>
+           </plugin>
             <plugin>
                 <groupId>com.diffplug.spotless</groupId>
                 <artifactId>spotless-maven-plugin</artifactId>