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.components.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>Components Model Catalog - Blueprints Model - Test Kotlin Parent</name>
35 <groupId>org.onap.ccsdk.cds.blueprintsprocessor.modules</groupId>
36 <artifactId>execution-service</artifactId>
39 <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
40 <artifactId>resource-resolution</artifactId>
43 <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
44 <artifactId>netconf-executor</artifactId>
47 <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
48 <artifactId>cli-executor</artifactId>
51 <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
52 <artifactId>message-prioritizaion</artifactId>
55 <groupId>org.jetbrains.kotlin</groupId>
56 <artifactId>kotlin-test-junit</artifactId>
60 <groupId>org.jetbrains.kotlinx</groupId>
61 <artifactId>kotlinx-coroutines-test</artifactId>
65 <groupId>junit</groupId>
66 <artifactId>junit</artifactId>
67 <version>4.12</version>
71 <groupId>io.mockk</groupId>
72 <artifactId>mockk</artifactId>
73 <version>1.10.0</version>
77 <groupId>com.squareup.okhttp3</groupId>
78 <artifactId>okhttp</artifactId>
79 <version>3.14.0</version>
84 <sourceDirectory>${project.basedir}/Scripts/kotlin</sourceDirectory>
85 <testSourceDirectory>${project.basedir}/Tests/kotlin</testSourceDirectory>
88 <directory>${project.basedir}/Environments</directory>
93 <artifactId>maven-antrun-plugin</artifactId>
96 <id>validate-kotlin</id>
97 <phase>validate</phase>
99 <target name="ktlint">
100 <java taskname="ktlint" dir="${project.basedir}" fork="true" failonerror="true" classname="com.pinterest.ktlint.Main" classpathref="maven.plugin.classpath">
101 <arg value="Scripts/kotlin/**/*.kt"/>
104 <skip>${format.skipValidate}</skip>
111 <!-- Built-in formatter So that you wouldn't have to fix all style violations by hand.-->
112 <id>format-kotlin</id>
113 <phase>process-sources</phase>
115 <target name="ktlint">
116 <java taskname="ktlint" dir="${project.basedir}" fork="true" failonerror="true" classname="com.pinterest.ktlint.Main" classpathref="maven.plugin.classpath">
118 <arg value="Scripts/kotlin/**/*.kt"/>
121 <skip>${format.skipExecute}</skip>
130 <groupId>org.jacoco</groupId>
131 <artifactId>jacoco-maven-plugin</artifactId>
134 <id>pre-unit-test</id>
138 <id>default-prepare-agent</id>
142 <id>post-unit-test</id>
146 <id>default-report</id>
150 <id>pre-integration-test</id>
154 <id>post-integration-test</id>
158 <id>default-check</id>
164 <groupId>org.jetbrains.kotlin</groupId>
165 <artifactId>kotlin-maven-plugin</artifactId>
169 <phase>compile</phase>
175 <sourceDir>${project.basedir}/Scripts/kotlin</sourceDir>
180 <id>test-compile</id>
181 <phase>test-compile</phase>
183 <goal>test-compile</goal>
187 <sourceDir>${project.basedir}/Tests/kotlin</sourceDir>
194 <groupId>org.apache.maven.plugins</groupId>
195 <artifactId>maven-site-plugin</artifactId>
198 <id>attach-descriptor</id>
204 <artifactId>maven-checkstyle-plugin</artifactId>
207 <id>check-license</id>
217 <artifactId>maven-assembly-plugin</artifactId>
220 <groupId>org.onap.ccsdk.cds.components.cba</groupId>
221 <artifactId>cba-assembly-descriptor</artifactId>
222 <version>${ccsdk.cds.version}</version>
226 <artifactId>*</artifactId>
233 <id>make-assembly</id>
234 <phase>package</phase>
240 <descriptorRef>cba_zip</descriptorRef>
255 <groupId>org.codehaus.gmaven</groupId>
256 <artifactId>groovy-maven-plugin</artifactId>
259 <groupId>com.squareup.okhttp3</groupId>
260 <artifactId>okhttp</artifactId>
261 <version>3.14.0</version>
264 <groupId>commons-io</groupId>
265 <artifactId>commons-io</artifactId>
266 <version>${commons-io-version}</version>
272 <phase>install</phase>
278 import okhttp3.Credentials
279 import okhttp3.MediaType
280 import okhttp3.MultipartBody
281 import okhttp3.OkHttpClient
282 import okhttp3.Request
283 import okhttp3.RequestBody
284 import org.apache.commons.io.IOUtils
288 target = "${basedir.absolutePath}/target"
289 userName = throwIfPropMissing('cds.username')
290 password = throwIfPropMissing('cds.password')
291 protocol = properties['cds.protocol'] ?: 'http'
292 host = properties['cds.host'] ?: 'localhost'
293 port = properties['cds.port'] ?: '8081'
295 def cba = "${project.artifact.artifactId}-${project.artifact.version}-cba.zip"
296 def enrichedCba = "${project.artifact.artifactId}-${project.artifact.version}-enriched-cba.zip"
297 def enrichEndpoint = properties['cds.enrich.endpoint'] ?: 'api/v1/blueprint-model/enrich'
298 def publishEndpoint = properties['cds.publish.endpoint'] ?: 'api/v1/blueprint-model/publish'
300 def throwIfPropMissing(prop) {
301 value = properties[prop]
302 if (!value || "".equals(value)) {
303 throw new RuntimeException("Property missing: $prop")
308 def buildRequest(endpoint, fileName) {
309 body = new MultipartBody.Builder()
310 .setType(MultipartBody.FORM)
311 .addFormDataPart("file",
313 RequestBody.create(MediaType.parse('application/zip'), new File(target, fileName)))
316 return new Request.Builder()
317 .url("$protocol://$host:$port/$endpoint")
318 .addHeader('Authorization', Credentials.basic(userName, password))
323 def logAndThrow(msg) {
325 log.error(response.body().string())
327 throw new RuntimeException(msg)
332 def client = new OkHttpClient()
334 response = client.newCall(buildRequest(enrichEndpoint, cba)).execute()
335 if (!response || !response.isSuccessful()) {
336 logAndThrow("Failed to enrich CBA")
340 response.body().byteStream(),
341 new FileOutputStream(new File(target, enrichedCba))
343 log.info("Created enriched cba: $enrichedCba")
345 response = client.newCall(buildRequest(publishEndpoint, enrichedCba)).execute()
346 if (!response || !response.isSuccessful()) {
347 logAndThrow("Failed to publish CBA")
350 log.info("CBA Deployed")
351 log.info(response.body().string())