453395dc74f59fe251591e69fc174c389461e960
[policy/models.git] / models-sim / packages / models-simulator-docker / pom.xml
1 <!--
2   ============LICENSE_START=======================================================
3    Copyright (C) 2020 Bell Canada.
4    Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
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.models.sim</groupId>
27         <artifactId>models-sim-packages</artifactId>
28         <version>2.6.3-SNAPSHOT</version>
29     </parent>
30
31     <artifactId>models-simulator-docker</artifactId>
32     <packaging>pom</packaging>
33
34     <name>${project.artifactId}</name>
35     <description>The module for creating docker images of Simulators 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>nexus3.onap.org:10001</docker.pull.registry>
45         <docker.push.registry>nexus3.onap.org:10003</docker.push.registry>
46         <maven.build.timestamp.format>yyyyMMdd'T'HHmm</maven.build.timestamp.format>
47         <!-- There is no code in this sub-module, only holds interfaces. So skip sonar. -->
48         <sonar.skip>true</sonar.skip>
49     </properties>
50
51     <build>
52         <finalName>${project.artifactId}-${project.version}</finalName>
53         <plugins>
54             <plugin>
55                 <groupId>org.codehaus.groovy.maven</groupId>
56                 <artifactId>gmaven-plugin</artifactId>
57                 <version>1.0</version>
58                 <executions>
59                     <execution>
60                         <phase>validate</phase>
61                         <goals>
62                             <goal>execute</goal>
63                         </goals>
64                         <configuration>
65                             <source>
66                                 println 'Project version: ' + project.properties['dist.project.version']
67                                 if (project.properties['dist.project.version'] != null) {
68                                     def versionArray = project.properties['dist.project.version'].split('-')
69                                     def minMaxVersionArray = versionArray[0].tokenize('.')
70                                     if (project.properties['dist.project.version'].endsWith("-SNAPSHOT")) {
71                                         project.properties['project.docker.latest.minmax.tag.version'] =
72                                           minMaxVersionArray[0] + "." + minMaxVersionArray[1] + "-SNAPSHOT-latest"
73                                     } else {
74                                         project.properties['project.docker.latest.minmax.tag.version'] =
75                                           minMaxVersionArray[0] + "." + minMaxVersionArray[1] + "-STAGING-latest"
76                                     }
77                                     println 'New tag for docker: ' + project.properties['project.docker.latest.minmax.tag.version']
78                                 }
79                             </source>
80                         </configuration>
81                     </execution>
82                 </executions>
83             </plugin>
84
85             <plugin>
86                 <groupId>io.fabric8</groupId>
87                 <artifactId>docker-maven-plugin</artifactId>
88
89                 <configuration>
90                     <verbose>true</verbose>
91                     <apiVersion>1.23</apiVersion>
92                     <pullRegistry>${docker.pull.registry}</pullRegistry>
93                     <pushRegistry>${docker.push.registry}</pushRegistry>
94
95                     <images>
96                         <image>
97                             <name>onap/policy-models-simulator</name>
98                             <build>
99                                 <cleanup>try</cleanup>
100                                 <dockerFile>Dockerfile</dockerFile>
101                                 <tags>
102                                     <tag>${project.version}</tag>
103                                     <tag>${project.version}-${maven.build.timestamp}</tag>
104                                     <tag>${project.docker.latest.minmax.tag.version}</tag>
105                                 </tags>
106                                 <assembly>
107                                     <inline>
108                                         <dependencySets>
109                                             <dependencySet>
110                                                 <includes>
111                                                     <include>org.onap.policy.models.sim:models-simulator-tarball</include>
112                                                 </includes>
113                                                 <outputDirectory>/lib</outputDirectory>
114                                                 <outputFileNameMapping>models-simulator.tar.gz</outputFileNameMapping>
115                                             </dependencySet>
116                                         </dependencySets>
117                                     </inline>
118                                 </assembly>
119                             </build>
120                         </image>
121                     </images>
122                 </configuration>
123
124                 <executions>
125                     <execution>
126                         <id>clean-images</id>
127                         <phase>pre-clean</phase>
128                         <goals>
129                             <goal>remove</goal>
130                         </goals>
131                         <configuration>
132                             <removeAll>true</removeAll>
133                         </configuration>
134                     </execution>
135
136                     <execution>
137                         <id>generate-images</id>
138                         <phase>generate-sources</phase>
139                         <goals>
140                             <goal>build</goal>
141                         </goals>
142                     </execution>
143
144                     <execution>
145                         <id>push-images</id>
146                         <phase>deploy</phase>
147                         <goals>
148                             <goal>build</goal>
149                             <goal>push</goal>
150                         </goals>
151                         <configuration>
152                             <image>onap/policy-models-simulator</image>
153                         </configuration>
154                     </execution>
155                 </executions>
156             </plugin>
157
158             <plugin>
159                 <groupId>org.apache.maven.plugins</groupId>
160                 <artifactId>maven-deploy-plugin</artifactId>
161                 <configuration>
162                     <skip>true</skip>
163                 </configuration>
164             </plugin>
165         </plugins>
166     </build>
167
168     <dependencies>
169         <dependency>
170             <groupId>org.onap.policy.models.sim</groupId>
171             <artifactId>models-simulator-tarball</artifactId>
172             <version>${project.version}</version>
173             <classifier>tarball</classifier>
174             <type>tar.gz</type>
175         </dependency>
176     </dependencies>
177 </project>