OCI image spec labels for models-simulator
[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    Modifications Copyright (C) 2022 Nordix Foundation.
6   ================================================================================
7   Licensed under the Apache License, Version 2.0 (the "License");
8   you may not use this file except in compliance with the License.
9   You may obtain a copy of the License at
10
11        http://www.apache.org/licenses/LICENSE-2.0
12
13   Unless required by applicable law or agreed to in writing, software
14   distributed under the License is distributed on an "AS IS" BASIS,
15   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   See the License for the specific language governing permissions and
17   limitations under the License.
18
19   SPDX-License-Identifier: Apache-2.0
20   ============LICENSE_END=========================================================
21 -->
22
23 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
24   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
25     <modelVersion>4.0.0</modelVersion>
26     <parent>
27         <groupId>org.onap.policy.models.sim</groupId>
28         <artifactId>models-sim-packages</artifactId>
29         <version>2.7.0-SNAPSHOT</version>
30     </parent>
31
32     <artifactId>models-simulator-docker</artifactId>
33     <packaging>pom</packaging>
34
35     <name>${project.artifactId}</name>
36     <description>The module for creating docker images of Simulators component.</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         <docker.pull.registry>nexus3.onap.org:10001</docker.pull.registry>
46         <docker.push.registry>nexus3.onap.org:10003</docker.push.registry>
47         <maven.build.timestamp.format>yyyyMMdd'T'HHmm</maven.build.timestamp.format>
48         <!-- There is no code in this sub-module, only holds interfaces. So skip sonar. -->
49         <sonar.skip>true</sonar.skip>
50     </properties>
51
52     <build>
53         <finalName>${project.artifactId}-${project.version}</finalName>
54         <plugins>
55             <plugin>
56                 <groupId>org.codehaus.groovy.maven</groupId>
57                 <artifactId>gmaven-plugin</artifactId>
58                 <version>1.0</version>
59                 <executions>
60                     <execution>
61                         <phase>validate</phase>
62                         <goals>
63                             <goal>execute</goal>
64                         </goals>
65                         <configuration>
66                             <source>
67                                 println 'Project version: ' + project.properties['dist.project.version']
68                                 if (project.properties['dist.project.version'] != null) {
69                                     def versionArray = project.properties['dist.project.version'].split('-')
70                                     def minMaxVersionArray = versionArray[0].tokenize('.')
71                                     if (project.properties['dist.project.version'].endsWith("-SNAPSHOT")) {
72                                         project.properties['project.docker.latest.minmax.tag.version'] =
73                                           minMaxVersionArray[0] + "." + minMaxVersionArray[1] + "-SNAPSHOT-latest"
74                                     } else {
75                                         project.properties['project.docker.latest.minmax.tag.version'] =
76                                           minMaxVersionArray[0] + "." + minMaxVersionArray[1] + "-STAGING-latest"
77                                     }
78                                     println 'New tag for docker: ' + project.properties['project.docker.latest.minmax.tag.version']
79                                 }
80                             </source>
81                         </configuration>
82                     </execution>
83                 </executions>
84             </plugin>
85
86             <plugin>
87                 <groupId>io.github.git-commit-id</groupId>
88                 <artifactId>git-commit-id-maven-plugin</artifactId>
89                 <version>5.0.0</version>
90                 <executions>
91                     <execution>
92                         <id>get-the-git-infos</id>
93                         <goals>
94                             <goal>revision</goal>
95                         </goals>
96                         <phase>initialize</phase>
97                     </execution>
98                 </executions>
99                 <configuration>
100                     <skipPoms>false</skipPoms>
101                     <generateGitPropertiesFile>true</generateGitPropertiesFile>
102                     <includeOnlyProperties>
103                         <includeOnlyProperty>^git.build.(time|version)$</includeOnlyProperty>
104                         <includeOnlyProperty>^git.commit.id.abbrev$</includeOnlyProperty>
105                     </includeOnlyProperties>
106                     <commitIdGenerationMode>full</commitIdGenerationMode>
107                 </configuration>
108             </plugin>
109
110             <plugin>
111                 <groupId>io.fabric8</groupId>
112                 <artifactId>docker-maven-plugin</artifactId>
113
114                 <configuration>
115                     <verbose>true</verbose>
116                     <apiVersion>1.23</apiVersion>
117                     <pullRegistry>${docker.pull.registry}</pullRegistry>
118                     <pushRegistry>${docker.push.registry}</pushRegistry>
119
120                     <images>
121                         <image>
122                             <name>onap/policy-models-simulator</name>
123                             <build>
124                                 <cleanup>try</cleanup>
125                                 <dockerFile>${dockerFile}</dockerFile>
126                                 <tags>
127                                     <tag>${project.version}</tag>
128                                     <tag>${project.version}-${maven.build.timestamp}</tag>
129                                     <tag>${project.docker.latest.minmax.tag.version}</tag>
130                                 </tags>
131                                 <assembly>
132                                     <inline>
133                                         <dependencySets>
134                                             <dependencySet>
135                                                 <includes>
136                                                     <include>org.onap.policy.models.sim:models-simulator-tarball</include>
137                                                 </includes>
138                                                 <outputDirectory>/lib</outputDirectory>
139                                                 <outputFileNameMapping>models-simulator.tar.gz</outputFileNameMapping>
140                                             </dependencySet>
141                                         </dependencySets>
142                                     </inline>
143                                 </assembly>
144                             </build>
145                         </image>
146                     </images>
147                 </configuration>
148
149                 <executions>
150                     <execution>
151                         <id>clean-images</id>
152                         <phase>pre-clean</phase>
153                         <goals>
154                             <goal>remove</goal>
155                         </goals>
156                         <configuration>
157                             <removeAll>true</removeAll>
158                         </configuration>
159                     </execution>
160
161                     <execution>
162                         <id>generate-images</id>
163                         <phase>generate-sources</phase>
164                         <goals>
165                             <goal>build</goal>
166                         </goals>
167                     </execution>
168
169                     <execution>
170                         <id>push-images</id>
171                         <phase>deploy</phase>
172                         <goals>
173                             <goal>build</goal>
174                             <goal>push</goal>
175                         </goals>
176                         <configuration>
177                             <image>onap/policy-models-simulator</image>
178                         </configuration>
179                     </execution>
180                 </executions>
181             </plugin>
182
183             <plugin>
184                 <groupId>org.apache.maven.plugins</groupId>
185                 <artifactId>maven-deploy-plugin</artifactId>
186                 <configuration>
187                     <skip>true</skip>
188                 </configuration>
189             </plugin>
190         </plugins>
191     </build>
192
193     <dependencies>
194         <dependency>
195             <groupId>org.onap.policy.models.sim</groupId>
196             <artifactId>models-simulator-tarball</artifactId>
197             <version>${project.version}</version>
198             <classifier>tarball</classifier>
199             <type>tar.gz</type>
200         </dependency>
201     </dependencies>
202 </project>