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.cba</groupId>
23 <artifactId>blueprint-model</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-test-junit</artifactId>
61 <groupId>org.jetbrains.kotlinx</groupId>
62 <artifactId>kotlinx-coroutines-test</artifactId>
67 <groupId>junit</groupId>
68 <artifactId>junit</artifactId>
69 <version>4.12</version>
73 <groupId>io.mockk</groupId>
74 <artifactId>mockk</artifactId>
75 <version>1.10.0</version>
79 <groupId>com.squareup.okhttp3</groupId>
80 <artifactId>okhttp</artifactId>
81 <version>3.14.0</version>
86 <sourceDirectory>${project.basedir}/Scripts/kotlin</sourceDirectory>
87 <testSourceDirectory>${project.basedir}/Tests/kotlin</testSourceDirectory>
90 <directory>${project.basedir}/Environments</directory>
95 <artifactId>maven-antrun-plugin</artifactId>
98 <id>validate-kotlin</id>
99 <phase>validate</phase>
101 <target name="ktlint">
102 <java taskname="ktlint" dir="${project.basedir}" fork="true" failonerror="true" classname="com.pinterest.ktlint.Main" classpathref="maven.plugin.classpath">
103 <arg value="Scripts/kotlin/**/*.kt"/>
106 <skip>${format.skipValidate}</skip>
113 <!-- Built-in formatter So that you wouldn't have to fix all style violations by hand.-->
114 <id>format-kotlin</id>
115 <phase>process-sources</phase>
117 <target name="ktlint">
118 <java taskname="ktlint" dir="${project.basedir}" fork="true" failonerror="true" classname="com.pinterest.ktlint.Main" classpathref="maven.plugin.classpath">
120 <arg value="Scripts/kotlin/**/*.kt"/>
123 <skip>${format.skipExecute}</skip>
132 <groupId>org.jacoco</groupId>
133 <artifactId>jacoco-maven-plugin</artifactId>
136 <id>pre-unit-test</id>
140 <id>default-prepare-agent</id>
144 <id>post-unit-test</id>
148 <id>default-report</id>
152 <id>pre-integration-test</id>
156 <id>post-integration-test</id>
160 <id>default-check</id>
166 <groupId>org.apache.maven.plugins</groupId>
167 <artifactId>maven-failsafe-plugin</artifactId>
174 <id>integration-tests</id>
180 <groupId>org.jetbrains.kotlin</groupId>
181 <artifactId>kotlin-maven-plugin</artifactId>
182 <version>${kotlin.maven.version}</version>
186 <phase>compile</phase>
192 <sourceDir>${project.basedir}/Scripts/kotlin</sourceDir>
197 <id>test-compile</id>
198 <phase>test-compile</phase>
200 <goal>test-compile</goal>
204 <sourceDir>${project.basedir}/Tests/kotlin</sourceDir>
211 <artifactId>maven-surefire-plugin</artifactId>
214 <id>default-test</id>
223 <groupId>org.apache.maven.plugins</groupId>
224 <artifactId>maven-site-plugin</artifactId>
227 <id>attach-descriptor</id>
233 <artifactId>maven-checkstyle-plugin</artifactId>
236 <id>check-license</id>
246 <artifactId>maven-assembly-plugin</artifactId>
249 <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
250 <artifactId>cba-assembly-descriptor</artifactId>
251 <version>1.0.0-SNAPSHOT</version>
255 <artifactId>*</artifactId>
262 <id>make-assembly</id>
263 <phase>package</phase>
269 <descriptorRef>cba_zip</descriptorRef>
284 <groupId>org.codehaus.gmaven</groupId>
285 <artifactId>groovy-maven-plugin</artifactId>
288 <groupId>com.squareup.okhttp3</groupId>
289 <artifactId>okhttp</artifactId>
290 <version>3.14.0</version>
293 <groupId>commons-io</groupId>
294 <artifactId>commons-io</artifactId>
295 <version>${commons-io-version}</version>
301 <phase>install</phase>
307 import okhttp3.Credentials
308 import okhttp3.MediaType
309 import okhttp3.MultipartBody
310 import okhttp3.OkHttpClient
311 import okhttp3.Request
312 import okhttp3.RequestBody
313 import org.apache.commons.io.IOUtils
317 target = "${basedir.absolutePath}/target"
318 userName = throwIfPropMissing('cds.username')
319 password = throwIfPropMissing('cds.password')
320 protocol = properties['cds.protocol'] ?: 'http'
321 host = properties['cds.host'] ?: 'localhost'
322 port = properties['cds.port'] ?: '8081'
324 def cba = "${project.artifact.artifactId}-${project.artifact.version}-cba.zip"
325 def enrichedCba = "${project.artifact.artifactId}-${project.artifact.version}-enriched-cba.zip"
326 def enrichEndpoint = properties['cds.enrich.endpoint'] ?: 'api/v1/blueprint-model/enrich'
327 def publishEndpoint = properties['cds.publish.endpoint'] ?: 'api/v1/blueprint-model/publish'
329 def throwIfPropMissing(prop) {
330 value = properties[prop]
331 if (!value || "".equals(value)) {
332 throw new RuntimeException("Property missing: $prop")
337 def buildRequest(endpoint, fileName) {
338 body = new MultipartBody.Builder()
339 .setType(MultipartBody.FORM)
340 .addFormDataPart("file",
342 RequestBody.create(MediaType.parse('application/zip'), new File(target, fileName)))
345 return new Request.Builder()
346 .url("$protocol://$host:$port/$endpoint")
347 .addHeader('Authorization', Credentials.basic(userName, password))
352 def logAndThrow(msg) {
354 log.error(response.body().string())
356 throw new RuntimeException(msg)
361 def client = new OkHttpClient()
363 response = client.newCall(buildRequest(enrichEndpoint, cba)).execute()
364 if (!response || !response.isSuccessful()) {
365 logAndThrow("Failed to enrich CBA")
369 response.body().byteStream(),
370 new FileOutputStream(new File(target, enrichedCba))
372 log.info("Created enriched cba: $enrichedCba")
374 response = client.newCall(buildRequest(publishEndpoint, enrichedCba)).execute()
375 if (!response || !response.isSuccessful()) {
376 logAndThrow("Failed to publish CBA")
379 log.info("CBA Deployed")
380 log.info(response.body().string())