Introduce jacoco-maven-plugin
[cps.git] / cps-parent / pom.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <project xmlns="http://maven.apache.org/POM/4.0.0"
3          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5     <parent>
6         <groupId>org.onap.oparent</groupId>
7         <artifactId>oparent</artifactId>
8         <version>3.1.0</version>
9         <relativePath/>
10     </parent>
11     <modelVersion>4.0.0</modelVersion>
12
13     <groupId>org.onap.cps</groupId>
14     <artifactId>cps-parent</artifactId>
15     <version>0.0.1-SNAPSHOT</version>
16     <packaging>pom</packaging>
17
18     <properties>
19         <app>org.onap.cps.Application</app>
20         <base.image>openjdk:11-jre-slim</base.image>
21         <java.version>11</java.version>
22         <jacoco-maven-plugin.version>0.8.6</jacoco-maven-plugin.version>
23         <jib-maven-plugin.version>2.6.0</jib-maven-plugin.version>
24         <minimum-coverage>0.15</minimum-coverage>
25         <nexusproxy>https://nexus.onap.org</nexusproxy>
26         <onap.nexus.url>https://nexus.onap.org</onap.nexus.url>
27         <oparent.version>3.1.0</oparent.version>
28         <releaseNexusPath>/content/repositories/releases/</releaseNexusPath>
29         <repository.name>nexus3.onap.org:10001/onap/cps-service</repository.name>
30         <spring-boot-maven-plugin.version>2.3.3.RELEASE</spring-boot-maven-plugin.version>
31         <swagger-codegen-maven-plugin.version>3.0.18</swagger-codegen-maven-plugin.version>
32         <snapshotNexusPath>/content/repositories/snapshots/</snapshotNexusPath>
33         <stagingNexusPath>/content/repositories/staging/</stagingNexusPath>
34         <tag.version>${project.version}</tag.version>
35     </properties>
36
37     <distributionManagement>
38         <repository>
39             <id>ecomp-releases</id>
40             <name>ECOMP Release Repository</name>
41             <url>${nexusproxy}${releaseNexusPath}</url>
42         </repository>
43         <snapshotRepository>
44             <id>ecomp-snapshots</id>
45             <name>ECOMP Snapshot Repository</name>
46             <url>${nexusproxy}${snapshotNexusPath}</url>
47         </snapshotRepository>
48     </distributionManagement>
49
50     <profiles>
51         <profile>
52             <id>docker</id>
53             <activation>
54                 <activeByDefault>false</activeByDefault>
55             </activation>
56             <build>
57                 <pluginManagement>
58                     <plugins>
59                         <plugin>
60                             <groupId>com.google.cloud.tools</groupId>
61                             <artifactId>jib-maven-plugin</artifactId>
62                             <version>${jib-maven-plugin.version}</version>
63                             <configuration>
64                                 <container>
65                                     <mainClass>${app}</mainClass>
66                                     <creationTime>USE_CURRENT_TIMESTAMP</creationTime>
67                                 </container>
68                                 <from>
69                                     <image>${base.image}</image>
70                                 </from>
71                                 <to>
72                                     <image>${repository.name}</image>
73                                     <tags>
74                                         <tag>${tag.version}</tag>
75                                     </tags>
76                                 </to>
77                             </configuration>
78                             <executions>
79                                 <execution>
80                                     <phase>package</phase>
81                                     <id>build</id>
82                                     <goals>
83                                         <goal>dockerBuild</goal>
84                                     </goals>
85                                 </execution>
86                                 <execution>
87                                     <phase>deploy</phase>
88                                     <id>buildAndPush</id>
89                                     <goals>
90                                         <goal>build</goal>
91                                     </goals>
92                                 </execution>
93                             </executions>
94                         </plugin>
95                     </plugins>
96                 </pluginManagement>
97             </build>
98         </profile>
99     </profiles>
100
101     <dependencyManagement>
102         <dependencies>
103             <dependency>
104                 <groupId>org.onap.cps</groupId>
105                 <artifactId>cps-dependencies</artifactId>
106                 <version>${project.version}</version>
107                 <type>pom</type>
108                 <scope>import</scope>
109             </dependency>
110             <dependency>
111                 <groupId>org.onap.cps</groupId>
112                 <artifactId>cps-bom</artifactId>
113                 <version>${project.version}</version>
114                 <type>pom</type>
115                 <scope>import</scope>
116             </dependency>
117         </dependencies>
118     </dependencyManagement>
119
120     <build>
121         <resources>
122             <resource>
123                 <directory>src/main/resources</directory>
124                 <filtering>true</filtering>
125             </resource>
126             <resource>
127                 <directory>target/generated-sources/license</directory>
128                 <includes>
129                     <include>third-party-licenses.txt</include>
130                 </includes>
131             </resource>
132             <resource>
133                 <directory>target/generated-resources/licenses</directory>
134                 <includes>
135                     <include>*.*</include>
136                 </includes>
137                 <targetPath>third-party-licenses</targetPath>
138             </resource>
139         </resources>
140         <pluginManagement>
141             <plugins>
142                 <plugin>
143                     <groupId>org.springframework.boot</groupId>
144                     <artifactId>spring-boot-maven-plugin</artifactId>
145                     <version>${spring-boot-maven-plugin.version}</version>
146                     <executions>
147                         <execution>
148                             <goals>
149                                 <goal>build-info</goal>
150                                 <goal>repackage</goal>
151                             </goals>
152                         </execution>
153                     </executions>
154                 </plugin>
155                 <!-- Swagger code generation. -->
156                 <plugin>
157                     <groupId>io.swagger.codegen.v3</groupId>
158                     <artifactId>swagger-codegen-maven-plugin</artifactId>
159                     <version>${swagger-codegen-maven-plugin.version}</version>
160                     <executions>
161                         <execution>
162                             <goals>
163                                 <goal>generate</goal>
164                             </goals>
165                             <configuration>
166                                 <inputSpec>${project.basedir}/docs/api/swagger/openapi.yml</inputSpec>
167                                 <invokerPackage>org.onap.cps.rest.controller</invokerPackage>
168                                 <modelPackage>org.onap.cps.rest.model</modelPackage>
169                                 <apiPackage>org.onap.cps.rest.api</apiPackage>
170                                 <language>spring</language>
171                                 <generateSupportingFiles>false</generateSupportingFiles>
172                                 <configOptions>
173                                     <sourceFolder>src/gen/java</sourceFolder>
174                                     <dateLibrary>java11</dateLibrary>
175                                     <interfaceOnly>true</interfaceOnly>
176                                     <useTags>true</useTags>
177                                 </configOptions>
178                             </configuration>
179                         </execution>
180                     </executions>
181                 </plugin>
182                 <plugin>
183                     <groupId>com.google.cloud.tools</groupId>
184                     <artifactId>jib-maven-plugin</artifactId>
185                     <version>${jib-maven-plugin.version}</version>
186                     <configuration>
187                         <container>
188                             <mainClass>${app}</mainClass>
189                             <creationTime>USE_CURRENT_TIMESTAMP</creationTime>
190                         </container>
191                         <from>
192                             <image>${base.image}</image>
193                         </from>
194                         <to>
195                             <image>${repository.name}</image>
196                             <tags>
197                                 <tag>${tag.version}</tag>
198                             </tags>
199                         </to>
200                     </configuration>
201                 </plugin>
202             </plugins>
203         </pluginManagement>
204         <plugins>
205             <plugin>
206                 <groupId>org.apache.maven.plugins</groupId>
207                 <artifactId>maven-compiler-plugin</artifactId>
208                 <configuration>
209                     <source>${java.version}</source>
210                     <target>${java.version}</target>
211                 </configuration>
212             </plugin>
213             <plugin>
214                 <groupId>org.apache.maven.plugins</groupId>
215                 <artifactId>maven-checkstyle-plugin</artifactId>
216                 <executions>
217                     <execution>
218                         <id>onap-java-style</id>
219                         <goals>
220                             <goal>check</goal>
221                         </goals>
222                         <phase>process-sources</phase>
223                         <configuration>
224                             <configLocation>onap-checkstyle/onap-java-style.xml</configLocation>
225                             <sourceDirectories>${project.build.sourceDirectory}</sourceDirectories>
226                             <includeResources>true</includeResources>
227                             <includeTestSourceDirectory>true</includeTestSourceDirectory>
228                             <includeTestResources>true</includeTestResources>
229                             <consoleOutput>false</consoleOutput>
230                             <violationSeverity>warning</violationSeverity>
231                             <failOnViolation>true</failOnViolation>
232                         </configuration>
233                     </execution>
234                 </executions>
235                 <dependencies>
236                     <dependency>
237                         <groupId>org.onap.oparent</groupId>
238                         <artifactId>checkstyle</artifactId>
239                         <version>${oparent.version}</version>
240                     </dependency>
241                 </dependencies>
242             </plugin>
243             <!-- Mandatory plugins for using Spock -->
244             <plugin>
245                 <!-- The gmavenplus plugin is used to compile Groovy code.
246                     To learn more about this plugin, visit https://github.com/groovy/GMavenPlus/wiki -->
247                 <groupId>org.codehaus.gmavenplus</groupId>
248                 <artifactId>gmavenplus-plugin</artifactId>
249                 <version>1.9.0</version>
250                 <executions>
251                     <execution>
252                         <goals>
253                             <goal>compileTests</goal>
254                         </goals>
255                     </execution>
256                 </executions>
257             </plugin>
258             <!-- Required because names of spec classes don't match default
259                 Surefire patterns (`*Test` etc.) -->
260             <plugin>
261                 <groupId>org.apache.maven.plugins</groupId>
262                 <artifactId>maven-surefire-plugin</artifactId>
263                 <version>3.0.0-M5</version>
264                 <configuration>
265                     <argLine>@{argLine}</argLine>
266                     <useFile>false</useFile>
267                     <includes>
268                         <include>**/*Spec.java</include>
269                         <include>**/*Test.java</include> <!-- Just in case of having also "normal" JUnit tests -->
270                     </includes>
271                 </configuration>
272             </plugin>
273             <plugin>
274                 <groupId>org.jacoco</groupId>
275                 <artifactId>jacoco-maven-plugin</artifactId>
276                 <version>${jacoco-maven-plugin.version}</version>
277                 <executions>
278                     <execution>
279                         <id>default-prepare-agent</id>
280                         <goals>
281                             <goal>prepare-agent</goal>
282                         </goals>
283                     </execution>
284                     <execution>
285                         <id>coverage-check</id>
286                         <goals>
287                             <goal>check</goal>
288                         </goals>
289                         <configuration>
290                             <rules>
291                                 <rule>
292                                     <element>BUNDLE</element>
293                                     <limits>
294                                         <limit>
295                                             <counter>INSTRUCTION</counter>
296                                             <value>COVEREDRATIO</value>
297                                             <minimum>${minimum-coverage}</minimum>
298                                         </limit>
299                                     </limits>
300                                 </rule>
301                             </rules>
302                         </configuration>
303                     </execution>
304                 </executions>
305             </plugin>
306         </plugins>
307     </build>
308 </project>