Refactoring poms groupId artifactId
[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
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>
20
21     <parent>
22         <groupId>org.onap.ccsdk.cds.components.cba</groupId>
23         <artifactId>blueprint-model</artifactId>
24         <version>1.0.0-SNAPSHOT</version>
25     </parent>
26
27     <artifactId>test-blueprint-kotlin-parent</artifactId>
28     <version>1.0.0-SNAPSHOT</version>
29     <packaging>pom</packaging>
30
31     <name>Components Model Catalog - Blueprints Model - Test Kotlin Parent</name>
32
33     <dependencies>
34         <dependency>
35             <groupId>org.onap.ccsdk.cds.blueprintsprocessor.modules</groupId>
36             <artifactId>execution-service</artifactId>
37         </dependency>
38         <dependency>
39             <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
40             <artifactId>resource-resolution</artifactId>
41         </dependency>
42         <dependency>
43             <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
44             <artifactId>netconf-executor</artifactId>
45         </dependency>
46         <dependency>
47             <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
48             <artifactId>cli-executor</artifactId>
49         </dependency>
50         <dependency>
51             <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
52             <artifactId>message-prioritizaion</artifactId>
53         </dependency>
54         <dependency>
55             <groupId>org.jetbrains.kotlin</groupId>
56             <artifactId>kotlin-test-junit</artifactId>
57             <scope>test</scope>
58         </dependency>
59         <dependency>
60             <groupId>org.jetbrains.kotlinx</groupId>
61             <artifactId>kotlinx-coroutines-test</artifactId>
62             <scope>test</scope>
63         </dependency>
64         <dependency>
65             <groupId>junit</groupId>
66             <artifactId>junit</artifactId>
67             <version>4.12</version>
68             <scope>test</scope>
69         </dependency>
70         <dependency>
71             <groupId>io.mockk</groupId>
72             <artifactId>mockk</artifactId>
73             <version>1.10.0</version>
74             <scope>test</scope>
75         </dependency>
76         <dependency>
77             <groupId>com.squareup.okhttp3</groupId>
78             <artifactId>okhttp</artifactId>
79             <version>3.14.0</version>
80         </dependency>
81     </dependencies>
82
83     <build>
84         <sourceDirectory>${project.basedir}/Scripts/kotlin</sourceDirectory>
85         <testSourceDirectory>${project.basedir}/Tests/kotlin</testSourceDirectory>
86         <resources>
87             <resource>
88                 <directory>${project.basedir}/Environments</directory>
89             </resource>
90         </resources>
91         <plugins>
92             <plugin>
93                 <artifactId>maven-antrun-plugin</artifactId>
94                 <executions>
95                     <execution>
96                         <id>validate-kotlin</id>
97                         <phase>validate</phase>
98                         <configuration>
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"/>
102                                 </java>
103                             </target>
104                             <skip>${format.skipValidate}</skip>
105                         </configuration>
106                         <goals>
107                             <goal>run</goal>
108                         </goals>
109                     </execution>
110                     <execution>
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>
114                         <configuration>
115                             <target name="ktlint">
116                                 <java taskname="ktlint" dir="${project.basedir}" fork="true" failonerror="true" classname="com.pinterest.ktlint.Main" classpathref="maven.plugin.classpath">
117                                     <arg value="-F"/>
118                                     <arg value="Scripts/kotlin/**/*.kt"/>
119                                 </java>
120                             </target>
121                             <skip>${format.skipExecute}</skip>
122                         </configuration>
123                         <goals>
124                             <goal>run</goal>
125                         </goals>
126                     </execution>
127                 </executions>
128             </plugin>
129             <plugin>
130                 <groupId>org.jacoco</groupId>
131                 <artifactId>jacoco-maven-plugin</artifactId>
132                 <executions>
133                     <execution>
134                         <id>pre-unit-test</id>
135                         <phase>none</phase>
136                     </execution>
137                     <execution>
138                         <id>default-prepare-agent</id>
139                         <phase>none</phase>
140                     </execution>
141                     <execution>
142                         <id>post-unit-test</id>
143                         <phase>none</phase>
144                     </execution>
145                     <execution>
146                         <id>default-report</id>
147                         <phase>none</phase>
148                     </execution>
149                     <execution>
150                         <id>pre-integration-test</id>
151                         <phase>none</phase>
152                     </execution>
153                     <execution>
154                         <id>post-integration-test</id>
155                         <phase>none</phase>
156                     </execution>
157                     <execution>
158                         <id>default-check</id>
159                         <phase>none</phase>
160                     </execution>
161                 </executions>
162             </plugin>
163             <plugin>
164                 <groupId>org.jetbrains.kotlin</groupId>
165                 <artifactId>kotlin-maven-plugin</artifactId>
166                 <executions>
167                     <execution>
168                         <id>compile</id>
169                         <phase>compile</phase>
170                         <goals>
171                             <goal>compile</goal>
172                         </goals>
173                         <configuration>
174                             <sourceDirs>
175                                 <sourceDir>${project.basedir}/Scripts/kotlin</sourceDir>
176                             </sourceDirs>
177                         </configuration>
178                     </execution>
179                     <execution>
180                         <id>test-compile</id>
181                         <phase>test-compile</phase>
182                         <goals>
183                             <goal>test-compile</goal>
184                         </goals>
185                         <configuration>
186                             <sourceDirs>
187                                 <sourceDir>${project.basedir}/Tests/kotlin</sourceDir>
188                             </sourceDirs>
189                         </configuration>
190                     </execution>
191                 </executions>
192             </plugin>
193             <plugin>
194                 <groupId>org.apache.maven.plugins</groupId>
195                 <artifactId>maven-site-plugin</artifactId>
196                 <executions>
197                     <execution>
198                         <id>attach-descriptor</id>
199                         <phase>none</phase>
200                     </execution>
201                 </executions>
202             </plugin>
203             <plugin>
204                 <artifactId>maven-checkstyle-plugin</artifactId>
205                 <executions>
206                     <execution>
207                         <id>check-license</id>
208                         <phase>none</phase>
209                     </execution>
210                     <execution>
211                         <id>check-style</id>
212                         <phase>none</phase>
213                     </execution>
214                 </executions>
215             </plugin>
216             <plugin>
217                 <artifactId>maven-assembly-plugin</artifactId>
218                 <dependencies>
219                     <dependency>
220                         <groupId>org.onap.ccsdk.cds.components.cba</groupId>
221                         <artifactId>cba-assembly-descriptor</artifactId>
222                         <version>${ccsdk.cds.version}</version>
223                         <exclusions>
224                             <exclusion>
225                                 <groupId>*</groupId>
226                                 <artifactId>*</artifactId>
227                             </exclusion>
228                         </exclusions>
229                     </dependency>
230                 </dependencies>
231                 <executions>
232                     <execution>
233                         <id>make-assembly</id>
234                         <phase>package</phase>
235                         <goals>
236                             <goal>single</goal>
237                         </goals>
238                         <configuration>
239                             <descriptorRefs>
240                                 <descriptorRef>cba_zip</descriptorRef>
241                             </descriptorRefs>
242                         </configuration>
243                     </execution>
244                 </executions>
245             </plugin>
246         </plugins>
247     </build>
248
249     <profiles>
250         <profile>
251             <id>deploy-cba</id>
252             <build>
253                 <plugins>
254                     <plugin>
255                         <groupId>org.codehaus.gmaven</groupId>
256                         <artifactId>groovy-maven-plugin</artifactId>
257                         <dependencies>
258                             <dependency>
259                                 <groupId>com.squareup.okhttp3</groupId>
260                                 <artifactId>okhttp</artifactId>
261                                 <version>3.14.0</version>
262                             </dependency>
263                             <dependency>
264                                 <groupId>commons-io</groupId>
265                                 <artifactId>commons-io</artifactId>
266                                 <version>${commons-io-version}</version>
267                             </dependency>
268                         </dependencies>
269                         <executions>
270                             <execution>
271                                 <id>deploy-cba</id>
272                                 <phase>install</phase>
273                                 <goals>
274                                     <goal>execute</goal>
275                                 </goals>
276                                 <configuration>
277                                     <source>
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
285
286                                         import java.io.File
287
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'
294
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'
299
300                                         def throwIfPropMissing(prop) {
301                                         value = properties[prop]
302                                         if (!value || "".equals(value)) {
303                                         throw new RuntimeException("Property missing: $prop")
304                                         }
305                                         return value
306                                         }
307
308                                         def buildRequest(endpoint, fileName) {
309                                         body = new MultipartBody.Builder()
310                                         .setType(MultipartBody.FORM)
311                                         .addFormDataPart("file",
312                                         fileName,
313                                         RequestBody.create(MediaType.parse('application/zip'), new File(target, fileName)))
314                                         .build()
315
316                                         return new Request.Builder()
317                                         .url("$protocol://$host:$port/$endpoint")
318                                         .addHeader('Authorization', Credentials.basic(userName, password))
319                                         .post(body)
320                                         .build()
321                                         }
322
323                                         def logAndThrow(msg) {
324                                         if(response) {
325                                         log.error(response.body().string())
326                                         }
327                                         throw new RuntimeException(msg)
328                                         }
329
330                                         response = null
331                                         try {
332                                         def client = new OkHttpClient()
333
334                                         response = client.newCall(buildRequest(enrichEndpoint, cba)).execute()
335                                         if (!response || !response.isSuccessful()) {
336                                         logAndThrow("Failed to enrich CBA")
337                                         }
338
339                                         IOUtils.copy(
340                                         response.body().byteStream(),
341                                         new FileOutputStream(new File(target, enrichedCba))
342                                         )
343                                         log.info("Created enriched cba: $enrichedCba")
344
345                                         response = client.newCall(buildRequest(publishEndpoint, enrichedCba)).execute()
346                                         if (!response || !response.isSuccessful()) {
347                                         logAndThrow("Failed to publish CBA")
348                                         }
349
350                                         log.info("CBA Deployed")
351                                         log.info(response.body().string())
352                                         } finally {
353                                         if (response) {
354                                         response.close()
355                                         }
356                                         }
357                                     </source>
358                                 </configuration>
359                             </execution>
360                         </executions>
361                     </plugin>
362                 </plugins>
363             </build>
364         </profile>
365     </profiles>
366 </project>