1 <?xml version="1.0" encoding="UTF-8"?>
3 ~ Copyright © 2020 Bell Canada
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
9 ~ http://www.apache.org/licenses/LICENSE-2.0
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.
18 <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">
19 <modelVersion>4.0.0</modelVersion>
22 <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
23 <artifactId>cba-parent</artifactId>
24 <version>1.0.0-SNAPSHOT</version>
27 <artifactId>test-blueprint-kotlin-parent</artifactId>
28 <version>1.0.0-SNAPSHOT</version>
29 <packaging>pom</packaging>
31 <name>CBA - Test Kotlin scripts</name>
32 <description>CBA - Test Kotlin scripts</description>
36 <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
37 <artifactId>execution-service</artifactId>
40 <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
41 <artifactId>resource-resolution</artifactId>
44 <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
45 <artifactId>netconf-executor</artifactId>
48 <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
49 <artifactId>cli-executor</artifactId>
52 <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
53 <artifactId>message-prioritizaion</artifactId>
56 <groupId>org.jetbrains.kotlin</groupId>
57 <artifactId>kotlin-stdlib</artifactId>
60 <groupId>org.jetbrains.kotlin</groupId>
61 <artifactId>kotlin-test-junit</artifactId>
65 <groupId>org.jetbrains.kotlinx</groupId>
66 <artifactId>kotlinx-coroutines-test</artifactId>
71 <groupId>junit</groupId>
72 <artifactId>junit</artifactId>
73 <version>4.12</version>
77 <groupId>io.mockk</groupId>
78 <artifactId>mockk</artifactId>
79 <version>1.10.0</version>
83 <groupId>com.squareup.okhttp3</groupId>
84 <artifactId>okhttp</artifactId>
85 <version>3.14.0</version>
90 <sourceDirectory>${project.basedir}/Scripts/kotlin</sourceDirectory>
91 <testSourceDirectory>${project.basedir}/Tests/kotlin</testSourceDirectory>
94 <directory>${project.basedir}/Environments</directory>
99 <artifactId>maven-antrun-plugin</artifactId>
102 <id>validate-kotlin</id>
103 <phase>validate</phase>
105 <target name="ktlint">
106 <java taskname="ktlint" dir="${project.basedir}" fork="true" failonerror="true" classname="com.pinterest.ktlint.Main" classpathref="maven.plugin.classpath">
107 <arg value="Scripts/kotlin/**/*.kt"/>
110 <skip>${format.skipValidate}</skip>
117 <!-- Built-in formatter So that you wouldn't have to fix all style violations by hand.-->
118 <id>format-kotlin</id>
119 <phase>process-sources</phase>
121 <target name="ktlint">
122 <java taskname="ktlint" dir="${project.basedir}" fork="true" failonerror="true" classname="com.pinterest.ktlint.Main" classpathref="maven.plugin.classpath">
124 <arg value="Scripts/kotlin/**/*.kt"/>
127 <skip>${format.skipExecute}</skip>
136 <groupId>org.jacoco</groupId>
137 <artifactId>jacoco-maven-plugin</artifactId>
140 <id>pre-unit-test</id>
144 <id>default-prepare-agent</id>
148 <id>post-unit-test</id>
152 <id>default-report</id>
156 <id>pre-integration-test</id>
160 <id>post-integration-test</id>
164 <id>default-check</id>
170 <groupId>org.apache.maven.plugins</groupId>
171 <artifactId>maven-failsafe-plugin</artifactId>
178 <id>integration-tests</id>
184 <groupId>org.jetbrains.kotlin</groupId>
185 <artifactId>kotlin-maven-plugin</artifactId>
186 <version>${kotlin.maven.version}</version>
190 <phase>compile</phase>
196 <sourceDir>${project.basedir}/Scripts/kotlin</sourceDir>
201 <id>test-compile</id>
202 <phase>test-compile</phase>
204 <goal>test-compile</goal>
208 <sourceDir>${project.basedir}/Tests/kotlin</sourceDir>
215 <artifactId>maven-surefire-plugin</artifactId>
218 <id>default-test</id>
227 <groupId>org.apache.maven.plugins</groupId>
228 <artifactId>maven-site-plugin</artifactId>
231 <id>attach-descriptor</id>
237 <artifactId>maven-checkstyle-plugin</artifactId>
240 <id>check-license</id>
250 <artifactId>maven-assembly-plugin</artifactId>
253 <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
254 <artifactId>cba-assembly-descriptor</artifactId>
255 <version>1.0.0-SNAPSHOT</version>
260 <id>make-assembly</id>
261 <phase>package</phase>
267 <descriptorRef>cba_zip</descriptorRef>
282 <groupId>org.codehaus.gmaven</groupId>
283 <artifactId>groovy-maven-plugin</artifactId>
286 <groupId>com.squareup.okhttp3</groupId>
287 <artifactId>okhttp</artifactId>
288 <version>3.14.0</version>
291 <groupId>commons-io</groupId>
292 <artifactId>commons-io</artifactId>
293 <version>${commons-io-version}</version>
299 <phase>install</phase>
305 import okhttp3.Credentials
306 import okhttp3.MediaType
307 import okhttp3.MultipartBody
308 import okhttp3.OkHttpClient
309 import okhttp3.Request
310 import okhttp3.RequestBody
311 import org.apache.commons.io.IOUtils
315 target = "${basedir.absolutePath}/target"
316 userName = throwIfPropMissing('cds.username')
317 password = throwIfPropMissing('cds.password')
318 protocol = properties['cds.protocol'] ?: 'http'
319 host = properties['cds.host'] ?: 'localhost'
320 port = properties['cds.port'] ?: '8081'
322 def cba = "${project.artifact.artifactId}-${project.artifact.version}-cba.zip"
323 def enrichedCba = "${project.artifact.artifactId}-${project.artifact.version}-enriched-cba.zip"
324 def enrichEndpoint = properties['cds.enrich.endpoint'] ?: 'api/v1/blueprint-model/enrich'
325 def publishEndpoint = properties['cds.publish.endpoint'] ?: 'api/v1/blueprint-model/publish'
327 def throwIfPropMissing(prop) {
328 value = properties[prop]
329 if (!value || "".equals(value)) {
330 throw new RuntimeException("Property missing: $prop")
335 def buildRequest(endpoint, fileName) {
336 body = new MultipartBody.Builder()
337 .setType(MultipartBody.FORM)
338 .addFormDataPart("file",
340 RequestBody.create(MediaType.parse('application/zip'), new File(target, fileName)))
343 return new Request.Builder()
344 .url("$protocol://$host:$port/$endpoint")
345 .addHeader('Authorization', Credentials.basic(userName, password))
350 def logAndThrow(msg) {
352 log.error(response.body().string())
354 throw new RuntimeException(msg)
359 def client = new OkHttpClient()
361 response = client.newCall(buildRequest(enrichEndpoint, cba)).execute()
362 if (!response || !response.isSuccessful()) {
363 logAndThrow("Failed to enrich CBA")
367 response.body().byteStream(),
368 new FileOutputStream(new File(target, enrichedCba))
370 log.info("Created enriched cba: $enrichedCba")
372 response = client.newCall(buildRequest(publishEndpoint, enrichedCba)).execute()
373 if (!response || !response.isSuccessful()) {
374 logAndThrow("Failed to publish CBA")
377 log.info("CBA Deployed")
378 log.info(response.body().string())