Fix: Run both sonar and clm scans in parallel
[ccsdk/cds.git] / components / model-catalog / blueprint-model / test-blueprint-kotlin-parent / pom.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3   ~ Copyright © 2020 Bell Canada
4   ~
5   ~ Licensed under the Apache License, Version 2.0 (the "License");
6   ~ you may not use this file except in compliance with the License.
7   ~ You may obtain a copy of the License at
8   ~
9   ~     http://www.apache.org/licenses/LICENSE-2.0
10   ~
11   ~ Unless required by applicable law or agreed to in writing, software
12   ~ distributed under the License is distributed on an "AS IS" BASIS,
13   ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   ~ See the License for the specific language governing permissions and
15   ~ limitations under the License.
16   -->
17 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
18     <modelVersion>4.0.0</modelVersion>
19
20     <parent>
21         <groupId>org.onap.ccsdk.cds.components.cba</groupId>
22         <artifactId>blueprint-model</artifactId>
23         <version>1.6.0-SNAPSHOT</version>
24     </parent>
25
26     <artifactId>test-blueprint-kotlin-parent</artifactId>
27     <packaging>pom</packaging>
28
29     <name>Components Model Catalog - Blueprints Model - Test Kotlin Parent</name>
30
31     <dependencies>
32         <dependency>
33             <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
34             <artifactId>blueprintsprocessor-application</artifactId>
35             <version>${project.parent.version}</version>
36         </dependency>
37         <dependency>
38             <groupId>org.springframework.boot</groupId>
39             <artifactId>spring-boot-starter-test</artifactId>
40             <scope>test</scope>
41         </dependency>
42         <dependency>
43             <groupId>org.junit.vintage</groupId>
44             <artifactId>junit-vintage-engine</artifactId>
45             <scope>test</scope>
46         </dependency>
47         <dependency>
48             <groupId>org.onap.ccsdk.cds.blueprintsprocessor.modules</groupId>
49             <artifactId>execution-service</artifactId>
50         </dependency>
51         <dependency>
52             <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
53             <artifactId>resource-resolution</artifactId>
54         </dependency>
55         <dependency>
56             <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
57             <artifactId>netconf-executor</artifactId>
58         </dependency>
59         <dependency>
60             <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
61             <artifactId>restconf-executor</artifactId>
62         </dependency>
63         <dependency>
64             <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
65             <artifactId>cli-executor</artifactId>
66         </dependency>
67         <dependency>
68             <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
69             <artifactId>message-prioritization</artifactId>
70         </dependency>
71         <dependency>
72             <groupId>org.jetbrains.kotlin</groupId>
73             <artifactId>kotlin-test-junit</artifactId>
74             <scope>test</scope>
75         </dependency>
76         <dependency>
77             <groupId>org.jetbrains.kotlinx</groupId>
78             <artifactId>kotlinx-coroutines-test</artifactId>
79             <scope>test</scope>
80         </dependency>
81         <dependency>
82             <groupId>junit</groupId>
83             <artifactId>junit</artifactId>
84             <version>4.13.1</version>
85             <scope>test</scope>
86         </dependency>
87         <dependency>
88             <groupId>io.mockk</groupId>
89             <artifactId>mockk</artifactId>
90             <version>1.10.0</version>
91             <scope>test</scope>
92         </dependency>
93         <dependency>
94             <groupId>com.squareup.okhttp3</groupId>
95             <artifactId>okhttp</artifactId>
96             <version>4.10.0</version>
97         </dependency>
98     </dependencies>
99
100     <build>
101         <sourceDirectory>${project.basedir}/Scripts/kotlin</sourceDirectory>
102         <testSourceDirectory>${project.basedir}/Tests/kotlin</testSourceDirectory>
103         <resources>
104             <resource>
105                 <directory>${project.basedir}/Environments</directory>
106             </resource>
107         </resources>
108         <testResources>
109             <testResource>
110                 <directory>${project.basedir}/Tests/resources</directory>
111             </testResource>
112         </testResources>
113         <plugins>
114             <plugin>
115                 <groupId>org.jacoco</groupId>
116                 <artifactId>jacoco-maven-plugin</artifactId>
117                 <executions>
118                     <execution>
119                         <id>pre-unit-test</id>
120                         <phase>none</phase>
121                     </execution>
122                     <execution>
123                         <id>default-prepare-agent</id>
124                         <phase>none</phase>
125                     </execution>
126                     <execution>
127                         <id>post-unit-test</id>
128                         <phase>none</phase>
129                     </execution>
130                     <execution>
131                         <id>default-report</id>
132                         <phase>none</phase>
133                     </execution>
134                     <execution>
135                         <id>pre-integration-test</id>
136                         <phase>none</phase>
137                     </execution>
138                     <execution>
139                         <id>post-integration-test</id>
140                         <phase>none</phase>
141                     </execution>
142                     <execution>
143                         <id>default-check</id>
144                         <phase>none</phase>
145                     </execution>
146                 </executions>
147             </plugin>
148             <plugin>
149                 <groupId>org.jetbrains.kotlin</groupId>
150                 <artifactId>kotlin-maven-plugin</artifactId>
151                 <executions>
152                     <execution>
153                         <id>compile</id>
154                         <phase>compile</phase>
155                         <goals>
156                             <goal>compile</goal>
157                         </goals>
158                         <configuration>
159                             <sourceDirs>
160                                 <sourceDir>${project.basedir}/Scripts/kotlin</sourceDir>
161                             </sourceDirs>
162                         </configuration>
163                     </execution>
164                     <execution>
165                         <id>test-compile</id>
166                         <phase>test-compile</phase>
167                         <goals>
168                             <goal>test-compile</goal>
169                         </goals>
170                         <configuration>
171                             <sourceDirs>
172                                 <sourceDir>${project.basedir}/Tests/kotlin</sourceDir>
173                             </sourceDirs>
174                         </configuration>
175                     </execution>
176                 </executions>
177             </plugin>
178             <plugin>
179                 <groupId>org.apache.maven.plugins</groupId>
180                 <artifactId>maven-site-plugin</artifactId>
181                 <executions>
182                     <execution>
183                         <id>attach-descriptor</id>
184                         <phase>none</phase>
185                     </execution>
186                 </executions>
187             </plugin>
188             <plugin>
189                 <artifactId>maven-checkstyle-plugin</artifactId>
190                 <executions>
191                     <execution>
192                         <id>check-license</id>
193                         <phase>none</phase>
194                     </execution>
195                     <execution>
196                         <id>check-style</id>
197                         <phase>none</phase>
198                     </execution>
199                 </executions>
200             </plugin>
201             <plugin>
202                 <artifactId>maven-assembly-plugin</artifactId>
203                 <dependencies>
204                     <dependency>
205                         <groupId>org.onap.ccsdk.cds.components.cba</groupId>
206                         <artifactId>cba-assembly-descriptor</artifactId>
207                         <version>${ccsdk.cds.version}</version>
208                         <exclusions>
209                             <exclusion>
210                                 <groupId>*</groupId>
211                                 <artifactId>*</artifactId>
212                             </exclusion>
213                         </exclusions>
214                     </dependency>
215                 </dependencies>
216                 <executions>
217                     <execution>
218                         <id>make-assembly</id>
219                         <phase>package</phase>
220                         <goals>
221                             <goal>single</goal>
222                         </goals>
223                         <configuration>
224                             <descriptorRefs>
225                                 <descriptorRef>cba_zip</descriptorRef>
226                             </descriptorRefs>
227                         </configuration>
228                     </execution>
229                 </executions>
230             </plugin>
231             <plugin>
232                 <groupId>org.apache.maven.plugins</groupId>
233                 <artifactId>maven-failsafe-plugin</artifactId>
234                 <executions>
235                     <execution>
236                         <id>default</id>
237                         <phase>none</phase>
238                     </execution>
239                     <execution>
240                         <id>integration-tests</id>
241                         <phase>none</phase>
242                     </execution>
243                 </executions>
244             </plugin>
245             <plugin>
246                 <artifactId>maven-surefire-plugin</artifactId>
247                 <version>${maven-surefire-plugin.version}</version>
248                 <executions>
249                     <execution>
250                         <id>default-test</id>
251                         <phase>test</phase>
252                         <configuration>
253                             <!-- Sets the VM argument line used when unit tests are run. -->
254                             <argLine>-Xmx1024m </argLine>
255                             <reuseForks>false</reuseForks>
256                             <forkCount>1</forkCount>
257                         </configuration>
258                         <goals>
259                             <goal>test</goal>
260                         </goals>
261                     </execution>
262                 </executions>
263             </plugin>
264             <plugin>
265                 <artifactId>maven-resources-plugin</artifactId>
266                 <version>2.6</version>
267                 <executions>
268                     <execution>
269                         <id>copy-test-resources</id>
270                         <goals>
271                             <goal>testResources</goal>
272                         </goals>
273                         <phase>process-test-resources</phase>
274                     </execution>
275                 </executions>
276             </plugin>
277         </plugins>
278     </build>
279
280     <profiles>
281         <profile>
282             <id>deploy-cba</id>
283             <build>
284                 <plugins>
285                     <plugin>
286                         <groupId>org.codehaus.gmaven</groupId>
287                         <artifactId>groovy-maven-plugin</artifactId>
288                         <dependencies>
289                             <dependency>
290                                 <groupId>com.squareup.okhttp3</groupId>
291                                 <artifactId>okhttp</artifactId>
292                                 <version>4.10.0</version>
293                             </dependency>
294                             <dependency>
295                                 <groupId>commons-io</groupId>
296                                 <artifactId>commons-io</artifactId>
297                                 <version>${commons-io-version}</version>
298                             </dependency>
299                         </dependencies>
300                         <executions>
301                             <execution>
302                                 <id>deploy-cba</id>
303                                 <phase>install</phase>
304                                 <goals>
305                                     <goal>execute</goal>
306                                 </goals>
307                                 <configuration>
308                                     <source>
309                                         import okhttp3.Credentials
310                                         import okhttp3.MediaType
311                                         import okhttp3.MultipartBody
312                                         import okhttp3.OkHttpClient
313                                         import okhttp3.Request
314                                         import okhttp3.RequestBody
315                                         import org.apache.commons.io.IOUtils
316
317                                         import java.io.File
318
319                                         target = "${basedir.absolutePath}/target"
320                                         userName = throwIfPropMissing('cds.username')
321                                         password = throwIfPropMissing('cds.password')
322                                         protocol = properties['cds.protocol'] ?: 'http'
323                                         host = properties['cds.host'] ?: 'localhost'
324                                         port = properties['cds.port'] ?: '8081'
325
326                                         def cba = "${project.artifact.artifactId}-${project.artifact.version}-cba.zip"
327                                         def enrichedCba = "${project.artifact.artifactId}-${project.artifact.version}-enriched-cba.zip"
328                                         def enrichEndpoint = properties['cds.enrich.endpoint'] ?: 'api/v1/blueprint-model/enrich'
329                                         def publishEndpoint = properties['cds.publish.endpoint'] ?: 'api/v1/blueprint-model/publish'
330
331                                         def throwIfPropMissing(prop) {
332                                             value = properties[prop]
333                                             if (!value || "".equals(value)) {
334                                                 throw new RuntimeException("Property missing: $prop")
335                                             }
336                                             return value
337                                         }
338
339                                         def buildRequest(endpoint, fileName) {
340                                             body = new MultipartBody.Builder()
341                                                     .setType(MultipartBody.FORM)
342                                                     .addFormDataPart("file",
343                                                             fileName,
344                                                             RequestBody.create(MediaType.parse('application/zip'), new File(target, fileName)))
345                                                     .build()
346
347                                             return new Request.Builder()
348                                                     .url("$protocol://$host:$port/$endpoint")
349                                                     .addHeader('Authorization', Credentials.basic(userName, password))
350                                                     .post(body)
351                                                     .build()
352                                         }
353
354                                         def logAndThrow(msg) {
355                                             if(response) {
356                                                 log.error(response.body().string())
357                                             }
358                                             throw new RuntimeException(msg)
359                                         }
360
361                                         response = null
362                                         try {
363                                             def client = new OkHttpClient()
364
365                                             response = client.newCall(buildRequest(enrichEndpoint, cba)).execute()
366                                             if (!response || !response.isSuccessful()) {
367                                                 logAndThrow("Failed to enrich CBA")
368                                             }
369
370                                             IOUtils.copy(
371                                                     response.body().byteStream(),
372                                                     new FileOutputStream(new File(target, enrichedCba))
373                                             )
374                                             log.info("Created enriched cba: $enrichedCba")
375
376                                             response = client.newCall(buildRequest(publishEndpoint, enrichedCba)).execute()
377                                             if (!response || !response.isSuccessful()) {
378                                                 logAndThrow("Failed to publish CBA")
379                                             }
380
381                                             log.info("CBA Deployed")
382                                             log.info(response.body().string())
383                                         } finally {
384                                             if (response) {
385                                                 response.close()
386                                             }
387                                         }
388                                     </source>
389                                 </configuration>
390                             </execution>
391                         </executions>
392                     </plugin>
393                 </plugins>
394             </build>
395         </profile>
396     </profiles>
397 </project>