Merge "pom.xml changes"
[policy/pap.git] / packages / policy-pap-docker / pom.xml
1 <!--
2   ============LICENSE_START=======================================================
3    Copyright (C) 2019 Nordix Foundation.
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     <modelVersion>4.0.0</modelVersion>
25     <parent>
26         <groupId>org.onap.policy.pap</groupId>
27         <artifactId>pap-packages</artifactId>
28         <version>2.2.0-SNAPSHOT</version>
29     </parent>
30
31     <artifactId>policy-pap-docker</artifactId>
32     <packaging>pom</packaging>
33
34     <name>${project.artifactId}</name>
35     <description>The module for creating docker images of PAP component.</description>
36
37     <properties>
38         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
39         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
40         <dist.project.version>${project.version}</dist.project.version>
41         <docker.skip>false</docker.skip>
42         <docker.skip.build>false</docker.skip.build>
43         <docker.skip.push>false</docker.skip.push>
44         <docker.pull.registry>docker.io</docker.pull.registry>
45         <docker.push.registry>docker.io</docker.push.registry>
46         <maven.build.timestamp.format>yyyyMMdd'T'HHmm</maven.build.timestamp.format>
47     </properties>
48
49     <build>
50         <finalName>${project.artifactId}-${project.version}</finalName>
51         <plugins>
52             <plugin>
53                 <groupId>org.codehaus.groovy.maven</groupId>
54                 <artifactId>gmaven-plugin</artifactId>
55                 <version>1.0</version>
56                 <executions>
57                     <execution>
58                         <phase>pre-clean</phase>
59                         <goals>
60                             <goal>execute</goal>
61                         </goals>
62                         <configuration>
63                             <source>
64                                 println 'Project version: ' + project.properties['dist.project.version'];
65                                 def versionArray;
66                                 if ( project.properties['dist.project.version'] != null ) {
67                                     versionArray = project.properties['dist.project.version'].split('-');
68                                 }
69
70                                 if ( project.properties['dist.project.version'].endsWith("-SNAPSHOT") ) {
71                                     project.properties['project.docker.latesttag.version']=versionArray[0] + "-SNAPSHOT-latest";
72                                 } else {
73                                     project.properties['project.docker.latesttag.version']=versionArray[0] + "-STAGING-latest";
74                                 }
75
76                                 println 'New tag for docker: ' + project.properties['project.docker.latesttag.version'];
77
78                                 println 'The arch is: ' + System.properties['os.arch'];
79                                 if ( "aarch64".equals(System.properties['os.arch']) ) {
80                                     project.properties['project.docker.arch'] = "arm64";
81                                 } else {
82                                     project.properties['project.docker.arch'] = System.properties['os.arch'];
83                                 }
84                                 println 'Using arch for docker: ' + project.properties['project.docker.arch'];
85                             </source>
86                         </configuration>
87                     </execution>
88                 </executions>
89             </plugin>
90
91             <plugin>
92                 <groupId>io.fabric8</groupId>
93                 <artifactId>docker-maven-plugin</artifactId>
94
95                 <configuration>
96                     <verbose>true</verbose>
97                     <apiVersion>1.23</apiVersion>
98                     <pullRegistry>${docker.pull.registry}</pullRegistry>
99                     <pushRegistry>${docker.push.registry}</pushRegistry>
100
101                     <images>
102                         <image>
103                             <name>onap/policy-pap:latest-${project.docker.arch}</name>
104                             <build>
105                                 <cleanup>try</cleanup>
106                                 <dockerFile>Dockerfile</dockerFile>
107                                 <tags>
108                                     <tag>${project.version}-${project.docker.arch}</tag>
109                                     <tag>${project.docker.latesttag.version}-${project.docker.arch}</tag>
110                                 </tags>
111                                 <assembly>
112                                     <inline>
113                                         <dependencySets>
114                                             <dependencySet>
115                                                 <includes>
116                                                     <include>org.onap.policy.pap:policy-pap-tarball</include>
117                                                 </includes>
118                                                 <outputDirectory>/lib</outputDirectory>
119                                                 <outputFileNameMapping>policy-pap.tar.gz</outputFileNameMapping>
120                                             </dependencySet>
121                                         </dependencySets>
122                                     </inline>
123                                 </assembly>
124                             </build>
125                         </image>
126                     </images>
127                 </configuration>
128
129                 <executions>
130                     <execution>
131                         <id>clean-images</id>
132                         <phase>pre-clean</phase>
133                         <goals>
134                             <goal>remove</goal>
135                         </goals>
136                         <configuration>
137                             <removeAll>true</removeAll>
138                         </configuration>
139                     </execution>
140
141                     <execution>
142                         <id>generate-images</id>
143                         <phase>generate-sources</phase>
144                         <goals>
145                             <goal>build</goal>
146                         </goals>
147                     </execution>
148
149                     <execution>
150                         <id>push-images</id>
151                         <phase>deploy</phase>
152                         <goals>
153                             <goal>build</goal>
154                             <goal>push</goal>
155                         </goals>
156                         <configuration>
157                             <image>onap/policy-pap</image>
158                         </configuration>
159                     </execution>
160                 </executions>
161             </plugin>
162
163             <plugin>
164                 <groupId>org.apache.maven.plugins</groupId>
165                 <artifactId>maven-deploy-plugin</artifactId>
166                 <configuration>
167                     <skip>true</skip>
168                 </configuration>
169             </plugin>
170         </plugins>
171     </build>
172
173     <dependencies>
174         <dependency>
175             <groupId>org.onap.policy.pap</groupId>
176             <artifactId>policy-pap-tarball</artifactId>
177             <version>${project.version}</version>
178             <classifier>tarball</classifier>
179             <type>tar.gz</type>
180         </dependency>
181     </dependencies>
182 </project>