Merge "Use docker registry properties in policy-api"
[policy/api.git] / packages / policy-api-docker / pom.xml
1 <!--
2   ============LICENSE_START=======================================================
3    Copyright (C) 2019,2021 AT&T Intellectual Property. All rights reserved.
4    Modifications Copyright (C) 2020 Bell Canada.
5   ================================================================================
6   Licensed under the Apache License, Version 2.0 (the "License");
7   you may not use this file except in compliance with the License.
8   You may obtain a copy of the License at
9
10        http://www.apache.org/licenses/LICENSE-2.0
11
12   Unless required by applicable law or agreed to in writing, software
13   distributed under the License is distributed on an "AS IS" BASIS,
14   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   See the License for the specific language governing permissions and
16   limitations under the License.
17
18   SPDX-License-Identifier: Apache-2.0
19   ============LICENSE_END=========================================================
20 -->
21
22 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
23     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
24
25     <modelVersion>4.0.0</modelVersion>
26
27     <parent>
28         <groupId>org.onap.policy.api</groupId>
29         <artifactId>api-packages</artifactId>
30         <version>2.5.0-SNAPSHOT</version>
31     </parent>
32
33     <packaging>pom</packaging>
34     <artifactId>policy-api-docker</artifactId>
35     <name>${project.artifactId}</name>
36     <description>Policy api docker image</description>
37
38     <properties>
39         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
40         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
41         <dist.project.version>${project.version}</dist.project.version>
42         <docker.skip>false</docker.skip>
43         <docker.skip.build>false</docker.skip.build>
44         <docker.skip.push>false</docker.skip.push>
45         <maven.build.timestamp.format>yyyyMMdd'T'HHmm</maven.build.timestamp.format>
46     </properties>
47
48     <build>
49         <finalName>${project.artifactId}-${project.version}</finalName>
50         <plugins>
51             <plugin>
52                 <groupId>org.codehaus.groovy.maven</groupId>
53                 <artifactId>gmaven-plugin</artifactId>
54                 <version>1.0</version>
55                 <executions>
56                     <execution>
57                         <phase>validate</phase>
58                         <goals>
59                             <goal>execute</goal>
60                         </goals>
61                         <configuration>
62                             <source>
63                                 println 'Project version: ' + project.properties['dist.project.version']
64                                 if (project.properties['dist.project.version'] != null) {
65                                     def versionArray = project.properties['dist.project.version'].split('-')
66                                     def minMaxVersionArray = versionArray[0].tokenize('.')
67                                     if (project.properties['dist.project.version'].endsWith("-SNAPSHOT")) {
68                                         project.properties['project.docker.latest.minmax.tag.version'] =
69                                             minMaxVersionArray[0] + "." + minMaxVersionArray[1] + "-SNAPSHOT-latest"
70                                     } else {
71                                         project.properties['project.docker.latest.minmax.tag.version'] =
72                                             minMaxVersionArray[0] + "." + minMaxVersionArray[1] + "-STAGING-latest"
73                                     }
74                                     println 'New tag for docker: ' + project.properties['project.docker.latest.minmax.tag.version']
75                                 }
76                             </source>
77                         </configuration>
78                     </execution>
79                 </executions>
80             </plugin>
81
82             <plugin>
83                 <groupId>io.fabric8</groupId>
84                 <artifactId>docker-maven-plugin</artifactId>
85
86                 <configuration>
87                     <verbose>true</verbose>
88                     <apiVersion>1.23</apiVersion>
89                     <pullRegistry>${docker.pull.registry}</pullRegistry>
90                     <pushRegistry>${docker.push.registry}</pushRegistry>
91
92                     <images>
93                         <image>
94                             <name>onap/policy-api</name>
95                             <build>
96                                 <cleanup>try</cleanup>
97                                 <dockerFile>Dockerfile</dockerFile>
98                                 <tags>
99                                     <tag>${project.version}</tag>
100                                     <tag>${project.version}-${maven.build.timestamp}</tag>
101                                     <tag>${project.docker.latest.minmax.tag.version}</tag>
102                                 </tags>
103                                 <assembly>
104                                     <inline>
105                                         <dependencySets>
106                                             <dependencySet>
107                                                 <includes>
108                                                     <include>org.onap.policy.api:policy-api-tarball</include>
109                                                 </includes>
110                                                 <outputDirectory>/lib</outputDirectory>
111                                                 <outputFileNameMapping>policy-api.tar.gz</outputFileNameMapping>
112                                             </dependencySet>
113                                         </dependencySets>
114                                     </inline>
115                                 </assembly>
116                             </build>
117                         </image>
118                     </images>
119                 </configuration>
120
121                 <executions>
122                     <execution>
123                         <id>clean-images</id>
124                         <phase>pre-clean</phase>
125                         <goals>
126                             <goal>remove</goal>
127                         </goals>
128                         <configuration>
129                             <removeAll>true</removeAll>
130                         </configuration>
131                     </execution>
132
133                     <execution>
134                         <id>generate-images</id>
135                         <phase>generate-sources</phase>
136                         <goals>
137                             <goal>build</goal>
138                         </goals>
139                     </execution>
140
141                     <execution>
142                         <id>push-images</id>
143                         <phase>deploy</phase>
144                         <goals>
145                             <goal>build</goal>
146                             <goal>push</goal>
147                         </goals>
148                         <configuration>
149                             <image>onap/policy-api</image>
150                         </configuration>
151                     </execution>
152                 </executions>
153             </plugin>
154
155             <plugin>
156                 <groupId>org.apache.maven.plugins</groupId>
157                 <artifactId>maven-deploy-plugin</artifactId>
158                 <configuration>
159                     <skip>true</skip>
160                 </configuration>
161             </plugin>
162         </plugins>
163     </build>
164
165     <dependencies>
166         <dependency>
167             <groupId>org.onap.policy.api</groupId>
168             <artifactId>policy-api-tarball</artifactId>
169             <version>${project.version}</version>
170             <classifier>tarball</classifier>
171             <type>tar.gz</type>
172         </dependency>
173     </dependencies>
174 </project>