Control docker build with profile
[ccsdk/cds.git] / ms / controllerblueprints / distribution / pom.xml
1 <?xml version="1.0" encoding="UTF-8"?>\r
2 <!--\r
3   ~  Copyright © 2017-2018 AT&T Intellectual Property.\r
4   ~\r
5   ~  Licensed under the Apache License, Version 2.0 (the "License");\r
6   ~  you may not use this file except in compliance with the License.\r
7   ~  You may obtain a copy of the License at\r
8   ~\r
9   ~      http://www.apache.org/licenses/LICENSE-2.0\r
10   ~\r
11   ~  Unless required by applicable law or agreed to in writing, software\r
12   ~  distributed under the License is distributed on an "AS IS" BASIS,\r
13   ~  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
14   ~  See the License for the specific language governing permissions and\r
15   ~  limitations under the License.\r
16   -->\r
17 \r
18 <project\r
19         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"\r
20         xmlns="http://maven.apache.org/POM/4.0.0"\r
21         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
22     <modelVersion>4.0.0</modelVersion>\r
23     <parent>\r
24         <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>\r
25         <artifactId>parent</artifactId>\r
26         <version>0.3.0-SNAPSHOT</version>\r
27         <relativePath>../parent</relativePath>\r
28     </parent>\r
29     <artifactId>distribution</artifactId>\r
30     <packaging>pom</packaging>\r
31     <name>Controller Blueprints Distribution</name>\r
32     <properties>\r
33         <assembly.id>maven</assembly.id>\r
34         <name.space>org.onap.ccsdk.apps</name.space>     <!-- <name.space>${namespace}</name.space> -->\r
35         <serviceArtifactName>controllerblueprints</serviceArtifactName>\r
36         <image.name>onap/ccsdk-controllerblueprints</image.name>\r
37                 <docker.buildArg.https_proxy>${https_proxy}</docker.buildArg.https_proxy>\r
38                 <docker.push.phase>deploy</docker.push.phase>\r
39                 <docker.verbose>true</docker.verbose>\r
40         </properties>\r
41 \r
42     <dependencies>\r
43         <dependency>\r
44             <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>\r
45             <artifactId>application</artifactId>\r
46         </dependency>\r
47     </dependencies>\r
48     <build>\r
49         <plugins>\r
50             <plugin>\r
51                 <artifactId>maven-resources-plugin</artifactId>\r
52                 <version>2.6</version>\r
53                 <executions>\r
54                     <execution>\r
55                         <id>copy-dockerfile</id>\r
56                         <goals>\r
57                             <goal>copy-resources</goal>\r
58                         </goals><!-- here the phase you need -->\r
59                         <phase>validate</phase>\r
60                         <configuration>\r
61                             <outputDirectory>${basedir}/target/docker-stage</outputDirectory>\r
62                             <resources>\r
63                                 <resource>\r
64                                     <directory>src/main/docker</directory>\r
65                                     <includes>\r
66                                         <include>*</include>\r
67                                     </includes>\r
68                                     <filtering>true</filtering>\r
69                                 </resource>\r
70                             </resources>\r
71                         </configuration>\r
72                     </execution>\r
73                 </executions>\r
74             </plugin>\r
75             <plugin>\r
76                 <groupId>org.apache.maven.plugins</groupId>\r
77                 <artifactId>maven-antrun-plugin</artifactId>\r
78                 <executions>\r
79                     <execution>\r
80                         <id>ant-test</id>\r
81                         <phase>package</phase>\r
82                         <configuration>\r
83                             <tasks>\r
84                                 <fixcrlf srcdir="${basedir}" eol="unix"\r
85                                          includes="**/*.sh, **/*.source"/>\r
86                             </tasks>\r
87                         </configuration>\r
88                         <goals>\r
89                             <goal>run</goal>\r
90                         </goals>\r
91                     </execution>\r
92                 </executions>\r
93             </plugin>\r
94             <plugin>\r
95                 <!--build the final artifact for docker deployment -->\r
96                 <artifactId>maven-assembly-plugin</artifactId>\r
97                 <version>3.0.0</version>\r
98                 <configuration>\r
99                     <!-- <skipAssembly>${skip.assembly}</skipAssembly>-->\r
100                     <outputDirectory>${basedir}/target/docker-stage</outputDirectory>\r
101                     <descriptors>\r
102                         <descriptor>src/main/docker/distribution.xml</descriptor>\r
103                     </descriptors>\r
104                     <tarLongFileMode>posix</tarLongFileMode>\r
105                 </configuration>\r
106                 <executions>\r
107                     <execution>\r
108                         <id>${assembly.id}</id>\r
109                         <phase>package</phase>\r
110                         <goals>\r
111                             <goal>single</goal>\r
112                         </goals>\r
113                     </execution>\r
114                 </executions>\r
115             </plugin>\r
116             <plugin>\r
117                 <groupId>org.codehaus.groovy.maven</groupId>\r
118                 <artifactId>gmaven-plugin</artifactId>\r
119                 <version>1.0</version>\r
120                 <executions>\r
121                     <execution>\r
122                         <phase>validate</phase>\r
123                         <goals>\r
124                             <goal>execute</goal>\r
125                         </goals>\r
126                         <configuration>\r
127                             <source>\r
128                                 println project.properties['ccsdk.project.version'];\r
129                                 def versionArray;\r
130                                 if (project.properties['ccsdk.project.version'] != null ) {\r
131                                     versionArray = project.properties['ccsdk.project.version'].split('\\.');\r
132                                 }\r
133 \r
134                                 if (project.properties['ccsdk.project.version'].endsWith("-SNAPSHOT"))\r
135                                 {\r
136                                     project.properties['project.docker.latesttag.version']=versionArray[0] + '.' + versionArray[1] + "-STAGING-latest";\r
137                                 } else {\r
138                                     project.properties['project.docker.latesttag.version']=versionArray[0]+'.' + versionArray[1]+"-STAGING-latest";\r
139                                 }\r
140 \r
141                                 println 'New Tag for docker:' + project.properties['project.docker.latesttag.version'];\r
142                             </source>\r
143                         </configuration>\r
144                     </execution>\r
145                 </executions>\r
146             </plugin>\r
147 \r
148         </plugins>\r
149     </build>\r
150 \r
151         <profiles>\r
152                 <profile>\r
153                         <id>docker</id>\r
154                         <build>\r
155                                 <plugins>\r
156                                         <plugin>\r
157                                                 <groupId>io.fabric8</groupId>\r
158                                                 <artifactId>docker-maven-plugin</artifactId>\r
159                                                 <version>0.26.1</version>\r
160                                                 <inherited>false</inherited>\r
161                                                 <configuration>\r
162                                                         <images>\r
163                                                                 <image>\r
164                                                                         <name>${image.name}</name>\r
165                                                                         <build>\r
166                                                                                 <cleanup>try</cleanup>\r
167                                                                                 <dockerFileDir>${basedir}/target/docker-stage</dockerFileDir>\r
168                                                                                 <tags>\r
169                                                                                         <tag>${project.version}</tag>\r
170                                                                                         <tag>${project.version}-STAGING-${maven.build.timestamp}</tag>\r
171                                                                                         <tag>${project.docker.latesttag.version}</tag>\r
172                                                                                 </tags>\r
173                                                                         </build>\r
174                                                                 </image>\r
175                                                         </images>\r
176                                                         <verbose>true</verbose>\r
177                                                 </configuration>\r
178                                                 <executions>\r
179                                                         <execution>\r
180                                                                 <id>push-images</id>\r
181                                                                 <phase>${docker.build.phase}</phase>\r
182                                                                 <goals>\r
183                                                                         <goal>build</goal>\r
184                                                                         <goal>push</goal>\r
185                                                                 </goals>\r
186                                                         </execution>\r
187                                                 </executions>\r
188                                         </plugin>\r
189                                 </plugins>\r
190                         </build>\r
191                 </profile>\r
192 \r
193         </profiles>\r
194 </project>\r
195 \r