320f3cb893bf725b78feb2bc2eb65ec055a406f7
[dcaegen2/analytics/tca.git] / dcae-analytics-cdap-plugins / pom.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3   ~ ===============================LICENSE_START======================================
4   ~  dcae-analytics
5   ~ ================================================================================
6   ~    Copyright © 2017 AT&T Intellectual Property. All rights reserved.
7   ~ ================================================================================
8   ~  Licensed under the Apache License, Version 2.0 (the "License");
9   ~  you may not use this file except in compliance with the License.
10   ~   You may obtain a copy of the License at
11   ~
12   ~          http://www.apache.org/licenses/LICENSE-2.0
13   ~
14   ~  Unless required by applicable law or agreed to in writing, software
15   ~  distributed under the License is distributed on an "AS IS" BASIS,
16   ~  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17   ~  See the License for the specific language governing permissions and
18   ~  limitations under the License.
19   ~  ============================LICENSE_END===========================================
20   -->
21
22 <project xmlns="http://maven.apache.org/POM/4.0.0"
23          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
24          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
25
26     <modelVersion>4.0.0</modelVersion>
27
28     <parent>
29         <artifactId>dcae-analytics</artifactId>
30         <groupId>org.onap.dcaegen2.analytics.tca</groupId>
31         <version>2.2.1-SNAPSHOT</version>
32     </parent>
33
34     <artifactId>dcae-analytics-cdap-plugins</artifactId>
35     <packaging>jar</packaging>
36
37     <!-- THIS MODULE CONTAINS CDAP CODE FOR PLUGINS -->
38     <name>DCAE Analytics CDAP Plugins</name>
39     <description>DCAE Analytics CDAP Plugins to build CDAP Pipelines</description>
40
41     <properties>
42         <main.basedir>${project.parent.basedir}</main.basedir>
43         <main.basedir.plugins>${project.basedir}</main.basedir.plugins>
44         <widgets.dir>widgets</widgets.dir>
45         <docs.dir>docs</docs.dir>
46         <app.parents>
47             system:cdap-etl-batch[4.0.0,4.2.0-SNAPSHOT),system:cdap-etl-realtime[4.0.0,4.2.0-SNAPSHOT),system:cdap-data-pipeline[4.0.0,4.2.0-SNAPSHOT),system:cdap-data-streams[4.0.0,4.2.0-SNAPSHOT)
48         </app.parents>
49     </properties>
50
51     <dependencies>
52
53         <!-- DCAE DEPENDENCIES -->
54         <dependency>
55             <groupId>org.onap.dcaegen2.analytics.tca</groupId>
56             <artifactId>dcae-analytics-cdap-common</artifactId>
57             <version>${project.parent.version}</version>
58         </dependency>
59
60         <dependency>
61             <groupId>org.onap.dcaegen2.analytics.tca</groupId>
62             <artifactId>dcae-analytics-tca</artifactId>
63             <version>${project.parent.version}</version>
64         </dependency>
65
66
67         <!-- CDAP -->
68         <dependency>
69             <groupId>co.cask.cdap</groupId>
70             <artifactId>cdap-api</artifactId>
71         </dependency>
72
73         <dependency>
74             <groupId>co.cask.cdap</groupId>
75             <artifactId>cdap-etl-api</artifactId>
76         </dependency>
77
78         <dependency>
79             <groupId>co.cask.cdap</groupId>
80             <artifactId>cdap-etl-api-spark</artifactId>
81         </dependency>
82
83         <dependency>
84             <groupId>co.cask.cdap</groupId>
85             <artifactId>cdap-etl-realtime</artifactId>
86         </dependency>
87
88         <dependency>
89             <groupId>co.cask.cdap</groupId>
90             <artifactId>cdap-data-pipeline</artifactId>
91         </dependency>
92
93         <dependency>
94             <groupId>co.cask.cdap</groupId>
95             <artifactId>cdap-data-streams</artifactId>
96         </dependency>
97
98         <dependency>
99             <groupId>org.apache.spark</groupId>
100             <artifactId>spark-streaming_2.10</artifactId>
101         </dependency>
102
103         <!-- CASK -->
104         <dependency>
105             <groupId>co.cask.http</groupId>
106             <artifactId>netty-http</artifactId>
107         </dependency>
108         <dependency>
109             <groupId>co.cask.common</groupId>
110             <artifactId>common-http</artifactId>
111         </dependency>
112
113         <!-- HADOOP -->
114         <dependency>
115             <groupId>org.apache.hadoop</groupId>
116             <artifactId>hadoop-mapreduce-client-core</artifactId>
117         </dependency>
118         <dependency>
119             <groupId>org.apache.hadoop</groupId>
120             <artifactId>hadoop-common</artifactId>
121         </dependency>
122
123         <!-- SPARK -->
124         <dependency>
125             <groupId>org.apache.spark</groupId>
126             <artifactId>spark-core_2.10</artifactId>
127         </dependency>
128
129         <!-- LOGGING -->
130         <dependency>
131             <groupId>org.slf4j</groupId>
132             <artifactId>slf4j-api</artifactId>
133         </dependency>
134
135         <dependency>
136             <groupId>ch.qos.logback</groupId>
137             <artifactId>logback-core</artifactId>
138         </dependency>
139
140         <dependency>
141             <groupId>ch.qos.logback</groupId>
142             <artifactId>logback-classic</artifactId>
143         </dependency>
144
145         <!-- FIND BUGS -->
146         <dependency>
147             <groupId>com.google.code.findbugs</groupId>
148             <artifactId>jsr305</artifactId>
149             <version>${findbugs.jsr305.version}</version>
150             <scope>provided</scope>
151         </dependency>
152
153         <dependency>
154             <groupId>com.google.code.findbugs</groupId>
155             <artifactId>annotations</artifactId>
156             <version>${findbugs.annotations.version}</version>
157             <scope>provided</scope>
158         </dependency>
159
160         <!-- TEST DEPENDENCIES -->
161         <dependency>
162             <groupId>org.onap.dcaegen2.analytics.tca</groupId>
163             <artifactId>dcae-analytics-test</artifactId>
164             <version>${project.parent.version}</version>
165             <scope>test</scope>
166         </dependency>
167
168         <dependency>
169             <groupId>co.cask.cdap</groupId>
170             <artifactId>hydrator-test</artifactId>
171         </dependency>
172
173         <dependency>
174             <groupId>co.cask.cdap</groupId>
175             <artifactId>cdap-unit-test</artifactId>
176             <exclusions>
177                 <exclusion>
178                     <artifactId>org.apache.httpcomponents</artifactId>
179                     <groupId>httpcore</groupId>
180                 </exclusion>
181             </exclusions>
182         </dependency>
183
184     </dependencies>
185
186
187     <build>
188         <plugins>
189
190             <plugin>
191                 <groupId>org.apache.felix</groupId>
192                 <artifactId>maven-bundle-plugin</artifactId>
193                 <configuration>
194                     <instructions>
195                         <!-- List of packages that are scanned for plugins -->
196                         <_exportcontents>
197                             org.onap.dcae.apod.analytics.dmaap.domain.response.*,
198                             org.onap.dcae.apod.analytics.dmaap.domain.config.*;
199                             org.onap.dcae.apod.analytics.dmaap.service.subscriber.*;
200                             org.onap.dcae.apod.analytics.dmaap.service.*;
201                             org.onap.dcae.apod.analytics.cdap.common.settings.*;
202                             org.onap.dcae.apod.analytics.cdap.plugins.common.*;
203                             org.onap.dcae.apod.analytics.cdap.plugins.batch.sink.dmaap.*;
204                             org.onap.dcae.apod.analytics.cdap.plugins.domain.config.dmaap.*;
205                             org.onap.dcae.apod.analytics.cdap.plugins.domain.config.filter.*;
206                             org.onap.dcae.apod.analytics.cdap.plugins.domain.config.tca.*;
207                             org.onap.dcae.apod.analytics.cdap.plugins.sparkcompute.tca.*;
208                             org.onap.dcae.apod.analytics.cdap.plugins.streaming.dmaap.*;
209                             org.onap.dcae.apod.analytics.cdap.plugins.transform.filter.*;
210                             com.google.common.base.*;
211                             com.google.inject.*;
212                             org.apache.http.*;
213                             org.aopalliance.*;
214                             javax.inject.*;
215                             org.apache.commons.*
216                         </_exportcontents>
217                     </instructions>
218                 </configuration>
219             </plugin>
220
221
222             <plugin>
223                 <groupId>org.apache.maven.plugins</groupId>
224                 <artifactId>maven-antrun-plugin</artifactId>
225                 <executions>
226                     <!-- Create the config file for artifact which can be used to deploy the artifact.
227                          Sets the parents field to system:cdap-etl-batch and system:cdap-etl-realtime with whatever
228                          version range is set in the app.parents property.
229                          also sets a widget and doc property for each file contained in the widgets and docs directories. -->
230                     <execution>
231                         <id>create-artifact-config</id>
232                         <phase>prepare-package</phase>
233                         <configuration>
234                             <target>
235                                 <script language="javascript"> <![CDATA[
236                   // for some reason, project.basedir evaluates to null if we just get the property here.
237                   // so we set main.basedir to project.basedir in the pom properties, then main.basedir is used here
238                   // where it evaluates correctly for whatever reason
239                   var baseDir = project.getProperty("main.basedir.plugins");
240                   var targetDir = project.getProperty("project.build.directory");
241                   var artifactId = project.getProperty("project.artifactId");
242                   var version = project.getProperty("project.version");
243
244                   var cfgFile = new java.io.File(targetDir, artifactId + "-" + version + ".json");
245                   if (!cfgFile.exists()) {
246                     cfgFile.createNewFile();
247                   }
248
249                   var parents = project.getProperty("app.parents").split(",");
250                   var config = {
251                     "parents": [ ],
252                     "properties": {}
253                   }
254                   for (i = 0; i < parents.length; i+=2) {
255                     // because name1[lo,hi],name2[lo,hi] gets split into "name1[lo", "hi]", "name2[lo", "hi]"
256                     // so we have to combine them again
257                     config.parents.push(parents[i] + "," + parents[i+1]);
258                   }
259
260                   // look in widgets directory for widget config for each plugin
261                   var widgetsDir = new java.io.File(baseDir, project.getProperty("widgets.dir"));
262                   if (widgetsDir.isDirectory()) {
263                     var widgetsFiles = widgetsDir.listFiles();
264                     for (i = 0; i < widgetsFiles.length; i++) {
265                       var widgetsFile = widgetsFiles[i];
266                       if (widgetsFile.isFile()) {
267                         var propertyName = "widgets." + widgetsFile.getName();
268                         // if the filename ends with .json
269                         if (propertyName.indexOf(".json", propertyName.length - 5) !== -1) {
270                           // strip the .json
271                           propertyName = propertyName.slice(0, -5);
272                           var contents = new java.lang.String(java.nio.file.Files.readAllBytes(widgetsFile.toPath()), java.nio.charset.StandardCharsets.UTF_8);
273                           var contentsAsJson = JSON.parse(contents);
274                           config.properties[propertyName] = JSON.stringify(contentsAsJson);
275                         }
276                       }
277                     }
278                   }
279
280                   // look in the docs directory for docs for each plugin
281                   var docsDir = new java.io.File(baseDir, project.getProperty("docs.dir"));
282                   if (docsDir.isDirectory()) {
283                     var docFiles = docsDir.listFiles();
284                     for (i = 0; i < docFiles.length; i++) {
285                       var docFile = docFiles[i];
286                       if (docFile.isFile()) {
287                         var propertyName = "doc." + docFile.getName();
288                         // if the filename ends with .md
289                         if (propertyName.indexOf(".md", propertyName.length - 3) !== -1) {
290                           // strip the extension
291                           propertyName = propertyName.slice(0, -3);
292                           var contents = new java.lang.String(java.nio.file.Files.readAllBytes(docFile.toPath()), java.nio.charset.StandardCharsets.UTF_8);
293                           config.properties[propertyName] = contents + "";
294                         }
295                       }
296                     }
297                   }
298
299                   var fw = new java.io.BufferedWriter(new java.io.FileWriter(cfgFile.getAbsoluteFile()));
300                   fw.write(JSON.stringify(config, null, 2));
301                   fw.close();
302                 ]]></script>
303                             </target>
304                         </configuration>
305                         <goals>
306                             <goal>run</goal>
307                         </goals>
308                     </execution>
309                 </executions>
310             </plugin>
311
312         </plugins>
313     </build>
314
315
316 </project>