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.jetbrains.kotlin</groupId>
167 <artifactId>kotlin-maven-plugin</artifactId>
171 <phase>compile</phase>
177 <sourceDir>${project.basedir}/Scripts/kotlin</sourceDir>
182 <id>test-compile</id>
183 <phase>test-compile</phase>
185 <goal>test-compile</goal>
189 <sourceDir>${project.basedir}/Tests/kotlin</sourceDir>
196 <groupId>org.apache.maven.plugins</groupId>
197 <artifactId>maven-site-plugin</artifactId>
200 <id>attach-descriptor</id>
206 <artifactId>maven-checkstyle-plugin</artifactId>
209 <id>check-license</id>
219 <artifactId>maven-assembly-plugin</artifactId>
222 <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
223 <artifactId>cba-assembly-descriptor</artifactId>
224 <version>1.0.0-SNAPSHOT</version>
228 <artifactId>*</artifactId>
235 <id>make-assembly</id>
236 <phase>package</phase>
242 <descriptorRef>cba_zip</descriptorRef>
257 <groupId>org.codehaus.gmaven</groupId>
258 <artifactId>groovy-maven-plugin</artifactId>
261 <groupId>com.squareup.okhttp3</groupId>
262 <artifactId>okhttp</artifactId>
263 <version>3.14.0</version>
266 <groupId>commons-io</groupId>
267 <artifactId>commons-io</artifactId>
268 <version>${commons-io-version}</version>
274 <phase>install</phase>
280 import okhttp3.Credentials
281 import okhttp3.MediaType
282 import okhttp3.MultipartBody
283 import okhttp3.OkHttpClient
284 import okhttp3.Request
285 import okhttp3.RequestBody
286 import org.apache.commons.io.IOUtils
290 target = "${basedir.absolutePath}/target"
291 userName = throwIfPropMissing('cds.username')
292 password = throwIfPropMissing('cds.password')
293 protocol = properties['cds.protocol'] ?: 'http'
294 host = properties['cds.host'] ?: 'localhost'
295 port = properties['cds.port'] ?: '8081'
297 def cba = "${project.artifact.artifactId}-${project.artifact.version}-cba.zip"
298 def enrichedCba = "${project.artifact.artifactId}-${project.artifact.version}-enriched-cba.zip"
299 def enrichEndpoint = properties['cds.enrich.endpoint'] ?: 'api/v1/blueprint-model/enrich'
300 def publishEndpoint = properties['cds.publish.endpoint'] ?: 'api/v1/blueprint-model/publish'
302 def throwIfPropMissing(prop) {
303 value = properties[prop]
304 if (!value || "".equals(value)) {
305 throw new RuntimeException("Property missing: $prop")
310 def buildRequest(endpoint, fileName) {
311 body = new MultipartBody.Builder()
312 .setType(MultipartBody.FORM)
313 .addFormDataPart("file",
315 RequestBody.create(MediaType.parse('application/zip'), new File(target, fileName)))
318 return new Request.Builder()
319 .url("$protocol://$host:$port/$endpoint")
320 .addHeader('Authorization', Credentials.basic(userName, password))
325 def logAndThrow(msg) {
327 log.error(response.body().string())
329 throw new RuntimeException(msg)
334 def client = new OkHttpClient()
336 response = client.newCall(buildRequest(enrichEndpoint, cba)).execute()
337 if (!response || !response.isSuccessful()) {
338 logAndThrow("Failed to enrich CBA")
342 response.body().byteStream(),
343 new FileOutputStream(new File(target, enrichedCba))
345 log.info("Created enriched cba: $enrichedCba")
347 response = client.newCall(buildRequest(publishEndpoint, enrichedCba)).execute()
348 if (!response || !response.isSuccessful()) {
349 logAndThrow("Failed to publish CBA")
352 log.info("CBA Deployed")
353 log.info(response.body().string())