-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpom.xml.javascript
233 lines (214 loc) · 9 KB
/
pom.xml.javascript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
<?xml version="1.0" encoding="UTF-8"?>
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>simple-udds</artifactId>
<name>Simple User Defined Directives</name>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<!-- properties for script build step that creates the config files for the artifacts -->
<widgets.dir>widgets</widgets.dir>
<docs.dir>docs</docs.dir>
<!-- this is here because project.basedir evaluates to null in the script build step -->
<main.basedir>${project.basedir}</main.basedir>
<cdap.version>4.3.1</cdap.version>
<wrangler.version>3.0.1</wrangler.version>
<commons.codec.version>1.10</commons.codec.version>
<junit.version>4.12</junit.version>
</properties>
<distributionManagement>
<repository>
<id>sonatype.release</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
</repository>
<snapshotRepository>
<id>sonatype.snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
<!-- Include the Maven Plugin Repository -->
<pluginRepositories>
<pluginRepository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<!-- Core Dependencies -->
<dependency>
<groupId>co.cask.wrangler</groupId>
<artifactId>wrangler-api</artifactId>
<version>${wrangler.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>co.cask.cdap</groupId>
<artifactId>cdap-api</artifactId>
<version>${cdap.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>co.cask.cdap</groupId>
<artifactId>cdap-etl-api</artifactId>
<version>${cdap.version}</version>
<scope>provided</scope>
</dependency>
<!-- External Dependencies -->
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>${commons.codec.version}</version>
</dependency>
<!-- Testing Dependencies -->
<dependency>
<groupId>co.cask.wrangler</groupId>
<artifactId>wrangler-test</artifactId>
<version>${wrangler.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.7</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Embed-Dependency>*;inline=false;scope=compile</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
<Embed-Directory>lib</Embed-Directory>
<!--Only @Plugin classes in the export packages will be included as plugin-->
<_exportcontents>org.example.directives.*</_exportcontents>
</instructions>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>bundle</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14.1</version>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<!-- Create the config file for artifact which can be used to deploy the artifact.
Sets the parents field to system:cdap-etl-batch and system:cdap-etl-realtime with whatever
version range is set in the etl.versionRange property.
also sets a widget and doc property for each file contained in the widgets and docs directories. -->
<execution>
<id>create-artifact-config</id>
<phase>prepare-package</phase>
<configuration>
<target>
<script language="javascript"> <![CDATA[
// for some reason, project.basedir evaluates to null if we just get the property here.
// so we set main.basedir to project.basedir in the pom properties, then main.basedir is used here
// where it evaluates correctly for whatever reason
var baseDir = project.getProperty("main.basedir");
var targetDir = project.getProperty("project.build.directory");
var artifactId = project.getProperty("project.artifactId");
var version = project.getProperty("project.version");
var cfgFile = new java.io.File(targetDir, artifactId + "-" + version + ".json");
if (!cfgFile.exists()) {
cfgFile.createNewFile();
}
var etlRange = project.getProperty("etl.versionRange");
var config = {
"parents": [
"system:wrangler-transform[1.0.0-SNAPSHOT, 10.0.0-SNAPSHOT]"
],
"properties": {}
}
// look in widgets directory for widget config for each plugin
var widgetsDir = new java.io.File(baseDir, "widgets");
if (widgetsDir.isDirectory()) {
var widgetsFiles = widgetsDir.listFiles();
for (i = 0; i < widgetsFiles.length; i++) {
var widgetsFile = widgetsFiles[i];
if (widgetsFile.isFile()) {
var propertyName = "widgets." + widgetsFile.getName();
// if the filename ends with .json
if (propertyName.indexOf(".json", propertyName.length - 5) !== -1) {
// strip the .json
propertyName = propertyName.slice(0, -5);
var contents = new java.lang.String(java.nio.file.Files.readAllBytes(widgetsFile.toPath()), java.nio.charset.StandardCharsets.UTF_8);
var contentsAsJson = JSON.parse(contents);
config.properties[propertyName] = JSON.stringify(contentsAsJson);
}
}
}
}
// look in the docs directory for docs for each plugin
var docsDir = new java.io.File(baseDir, "docs");
if (docsDir.isDirectory()) {
var docFiles = docsDir.listFiles();
for (i = 0; i < docFiles.length; i++) {
var docFile = docFiles[i];
if (docFile.isFile()) {
var propertyName = "doc." + docFile.getName();
// if the filename ends with .md
if (propertyName.indexOf(".md", propertyName.length - 3) !== -1) {
// strip the extension
propertyName = propertyName.slice(0, -3);
var contents = new java.lang.String(java.nio.file.Files.readAllBytes(docFile.toPath()), java.nio.charset.StandardCharsets.UTF_8);
config.properties[propertyName] = contents + "";
}
}
}
}
var fw = new java.io.BufferedWriter(new java.io.FileWriter(cfgFile.getAbsoluteFile()));
fw.write(JSON.stringify(config, null, 2));
fw.close();
]]></script>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>