forked from webdetails/pentahoLanguagePacks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
464 lines (416 loc) · 24.7 KB
/
build.xml
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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
<?xml version="1.0" encoding="utf-8"?>
<project name="buildProject" basedir="." default="build-language-packs"
xmlns:ivy="antlib:org.apache.ivy.ant">
<description>
This build file is used to create the languagePackInstaller project
and works with the common_build.xml file.
</description>
<!-- Import the common_build.xml file which contains all the default tasks -->
<import file="build-res/subfloor-pkg.xml" id="subfloor"/>
<property name="plugin.name"
value="languagePackInstaller"
description="Name of the plugin"/>
<property name="stage.dir"
value="${bin.dir}/stage"
description="Name of the resource directory"/>
<tstamp/>
<!-- Build the project.revision property -->
<property name="distribution.version" value="${project.stage}-${project.version}"/>
<echo>distribution.version = ${distribution.version}</echo>
<property name="plugin.artifact.id" value="${plugin.name}"/>
<property name="plugin.zipfile" value="${plugin.artifact.id}-${distribution.version}.zip"/>
<!--=======================================================================
dist
Creates a distribution of this project's plugin zip
====================================================================-->
<target name="dist" depends="clean,resolve" description="Creates a distribution">
<!-- delete and re-create the plugin dist folder tree -->
<mkdir dir="${stage.dir}"/>
<mkdir dir="${stage.dir}/${plugin.name}"/>
<mkdir dir="${stage.dir}/${plugin.name}"/>
<mkdir dir="${dist.dir}"/>
<!-- copy the entire plugin to that folder -->
<copy todir="${stage.dir}/${plugin.name}/" overwrite="true">
<fileset dir=".">
<include name="**/*"/>
<exclude name="bin/"/>
</fileset>
</copy>
<!-- create the version file -->
<tstamp/>
<property name="sequential.build.id" value="manual-${DSTAMP}"/>
<echo file="${stage.dir}/${plugin.name}/version.xml" message="<version branch='${project.stage}' buildId='${sequential.build.id}'>${distribution.version}</version>"/>
<!-- create a zip file -->
<zip zipfile="${dist.dir}/${plugin.zipfile}"
basedir="${stage.dir}"
includes="${plugin.name}/**/*"
excludes="**/Thumbs.db"/>
<!-- create a marketplace.xml file -->
<echoxml file="${dist.dir}/marketplace.xml">
<version>
<branch>${project.stage}</branch>
<version>${distribution.version}</version>
<name>${project.stage}</name>
<package_url>not defined</package_url>
<description>@PLUGIN_PACKAGE_DESCRIPTION@</description>
<build_id>${sequential.build.id}</build_id>
</version>
</echoxml>
<move tofile="${dist.dir}/${ivy.artifact.id}-${project.revision}.zip" file="${dist.dir}/${plugin.zipfile}"/>
</target>
<!--=======================================================================
install-plugin
Installs the plugin locally
====================================================================-->
<target name="install-plugin" depends="clean, resolve, dist" description="Installs the plugin locally">
<fail message="plugin.local.install.solutions.dir not set - cannot copy"
unless="plugin.local.install.solutions.dir"/>
<delete dir="${plugin.local.install.solutions.dir}/system/${plugin.name}"/>
<copy todir="${plugin.local.install.solutions.dir}/system/${plugin.name}">
<fileset dir="${stage.dir}/${plugin.name}">
<include name="**/*"/>
</fileset>
</copy>
<get src="http://127.0.0.1:8080/pentaho/Publish?publish=now&class=org.pentaho.platform.plugin.services.pluginmgr.PluginAdapter&userid=${plugin.local.install.user}&password=${plugin.local.install.pass}"
dest="${stage.dir}/blah.html"/>
</target>
<!-- Overriding resolve target so we can add resolve-dev -->
<target name="resolve"
depends="resolve-default, resolve-test, resolve-codegen, resolve-runtime, ivy.check-releasable"
description="Retrieves all the dependent libraries" />
<target name="resolve-runtime" depends="resolve-init">
<ivy:resolve file="${ivyfile}" conf="runtime" />
<ivy:retrieve conf="runtime" pattern="${runtimelib.dir}/[module]-[revision](-[classifier]).[ext]" />
</target>
<target name="clean-jars">
<delete dir="${lib.dir}" />
<delete dir="${testlib.dir}" />
<delete dir="${runtimelib.dir}" />
</target>
<!--=======================================================================
build-language-pack
Builds a language pack: duplicate the plugin, delete
unnecessary files
====================================================================-->
<scriptdef language="javascript" name="upper">
<attribute name="string" />
<attribute name="to" />
project.setProperty( attributes.get( "to" ),
attributes.get( "string" ).toUpperCase() );
</scriptdef>
<scriptdef language="javascript" name="lower">
<attribute name="string" />
<attribute name="to" />
project.setProperty( attributes.get( "to" ),
attributes.get( "string" ).toLowerCase() );
</scriptdef>
<scriptdef language="javascript" name="ucfirst">
<attribute name="string" />
<attribute name="to" />
var the_string = attributes.get( "string" );
project.setProperty( attributes.get( "to" ),
the_string.substr(0,1).toUpperCase() + the_string.substr(1) );
</scriptdef>
<scriptdef language="javascript" name="capitalize">
<attribute name="string" />
<attribute name="to" />
var s = new String( attributes.get( "string" ) );
project.setProperty( attributes.get( "to" ),
s.toLowerCase().replace( /^.|\s\S/g,
function(a) { return a.toUpperCase(); }) );
</scriptdef>
<target name="build-language-pack"
description="Builds a specific language pack: duplicate the plugin, delete unnecessary files. Warning: no clean, no resolve. Invoke using -DlangCode=pt_PT">
<property name="langpack.name">languagePack_${langCode}</property>
<taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask">
<classpath path="${basedir}/lib/xmltask-1.16.jar" />
</taskdef>
<echo>Generating ${langpack.name}</echo>
<!-- delete and re-create the plugin dist folder tree -->
<mkdir dir="${stage.dir}/${langpack.name}"/>
<mkdir dir="${dist.dir}"/>
<delete><fileset dir="${stage.dir}/${langpack.name}"/></delete>
<!-- Copy files requiring NATIVE2ASCII conversion into the staging folder -->
<!-- handle .properties inside jars -->
<native2ascii encoding="UTF-8" src="${basedir}/data/${langCode}"
dest="${stage.dir}/${langpack.name}/data/${langCode}">
<include name="**/*_${langCode}.properties" />
<!-- <include name="**/*_jar/**/*" /> -->
<!-- <include name="**/system/analyzer/**/*_${langCode}.properties"/> -->
<!-- <include name="**/system/dashboards/**/*_${langCode}.properties"/> -->
<!-- <include name="**/system/data-access/**/*_${langCode}.properties"/> -->
<!-- <include name="**/system/pentaho-geo/**/*_${langCode}.properties"/> -->
</native2ascii>
<!--copy remaining files into the staging folder -->
<basename property="bin.dir.relative" file="${bin.dir}"/>
<basename property="dist.dir.relative" file="${dist.dir}"/>
<copy todir="${stage.dir}/${langpack.name}/" overwrite="false">
<fileset dir="${basedir}">
<include name="**/*"/>
<exclude name="${bin.dir.relative}/**"/>
<exclude name="data/**"/>
<exclude name="${dist.dir.relative}/**"/>
<exclude name="translations/**"/>
<exclude name="tools/**"/>
<exclude name="documentation/**"/>
</fileset>
<fileset dir="${basedir}">
<include name="data/${langCode}/system/**"/>
<include name="data/${langCode}/tomcat/**"/>
</fileset>
</copy>
<!-- Remove any remaining <TRANSLATE ME> tags to avoid breaking the UI -->
<replace dir="${stage.dir}/${langpack.name}/data" token="<TRANSLATE ME>" value=""/>
<!-- Add metadata.json -->
<property name="metadata.json" value="${stage.dir}/${langpack.name}/data/metadata.json"/>
<copy file="${basedir}/data/${langCode}/metadata.json"
tofile="${metadata.json}"/>
<!-- localization of the plugin -->
<mkdir dir="${stage.dir}/${langpack.name}/resources/lang"/>
<copy todir="${stage.dir}/${langpack.name}/resources/lang" overwrite="true">
<fileset dir="${basedir}/data/${langCode}/resources/lang">
<include name="**/*"/>
</fileset>
</copy>
<!-- Copy the flag -->
<!-- <available file="${basedir}/data/${langCode}/resources/img/flag.png" property="flag.img.present"/> -->
<copy todir="${stage.dir}/${langpack.name}/static/custom/img" overwrite="true" failonerror="false">
<fileset dir="${basedir}/data/${langCode}/resources/img">
<include name="flag.png"/>
</fileset>
</copy>
<loadproperties prefix='here'>
<file file="${basedir}/data/${langCode}/resources/lang/messages.properties"/>
<!-- Loads variables: here.languagePack.title, here.languagePack.description, among others-->
</loadproperties>
<echo>Read from ${basedir}/data/${langCode}/resources/lang/messages.properties: title = ${languagePack.title}...</echo>
<loadresource property="langpackMetadata">
<file file="${metadata.json}"/>
</loadresource>
<script language="javascript"><![CDATA[
// Evaluate the serialized JSON
var struct = eval("(" + langpackMetadata + ")");
// Set each property in the project environment.
for (i in struct) {
//echo1 = project.createTask("echo");
//echo1.setMessage(i + " is of type " + typeof struct[i]);
//echo1.perform();
if (typeof struct[i] == "object"){
if (! (struct[i] instanceof Array)){
for (k in struct[i]){
echo0 = project.createTask("echo");
echo0.setMessage(i + "." + k + " = " + struct[i][k]);
echo0.perform();
project.setProperty('langpack.metadata.' + i + '.' + k, struct[i][k]);
}
}
} else {
echo = project.createTask("echo");
echo.setMessage(i + " = " + struct[i]);
echo.perform();
project.setProperty('langpack.metadata.' + i, struct[i]);
}
}
]]></script>
<echo>Read from ${metadata.json}: appTitle = ${langpack.metadata.appTitle}...</echo>
<!-- create the version file -->
<property name="langpack.distribution.version" value="${langpack.metadata.version}"/>
<tstamp/>
<property name="sequential.build.id" value="manual-${DSTAMP}"/>
<echoxml file="${stage.dir}/${langpack.name}/version.xml">
<version branch='${project.stage}' buildId='${sequential.build.id}'>${langpack.distribution.version}</version>
</echoxml>
<!-- Update plugin metadata -->
<echo>Updating metadata for ${langpack.name}</echo>
<echo>Generating a new ${stage.dir}/${langpack.name}/plugin.xml...</echo>
<echoxml file="${stage.dir}/${langpack.name}/plugin.xml">
<!-- <?xml version="1.0" encoding="UTF-8" standalone="no"?> -->
<plugin loader="DEFAULT" title="${langpack.name}" name="${langpack.name}">
<overlays>
<overlay id="startup.${langpack.name}" resourcebundle="content/${langpack.name}/resources/lang/messages">
<menubar id="toolsmenu">
<menubar id="languagePacks" label="${Launcher.menuLanguagePacks}" layout="vertical">
<menuitem id="${langpack.name}"
label="${languagePack.title}"
command="mantleXulHandler.openUrl('${languagePack.title}','${languagePack.title}','plugin/${langpack.name}/api/main')"/>
</menubar>
</menubar>
</overlay>
</overlays>
<lifecycle-listener class="pt.webdetails.cpk.CpkLifecycleListener"/>
<static-paths>
<static-path localFolder="static" url="/${langpack.name}/static"/>
<static-path localFolder="resources" url="/${langpack.name}/resources"/>
</static-paths>
<content-types>
<content-type>
<title>${here.languagePack.title}</title>
<description>${here.languagePack.description}</description>
<company logo="${langpack.metadata.maintainer.img}" name="${langpack.metadata.maintainer.name}" url="${langpack.metadata.maintainer.url}"/>
</content-type>
</content-types>
<content-generator class="pt.webdetails.cpk.CpkContentGenerator" id="${langpack.name}" title="${here.languagePack.title}" type="${langpack.name}"/>
<!-- Menu entry -->
<menu-items>
<menu-item anchor="tools-submenu" command="plugin/${langpack.name}/api/main" how="LAST_CHILD" id="${langpack.name}_main" label="${here.languagePack.title}" type="MENU_ITEM"/>
</menu-items>
</plugin>
</echoxml>
<echo>Updating ${stage.dir}/${langpack.name}/cpk.xml</echo>
<xmltask source="${stage.dir}/${langpack.name}/cpk.xml"
dest="${stage.dir}/${langpack.name}/cpk.xml"
report="false">
<replace path="cpk/info/name/text()" withText="${here.languagePack.title}"/>
<replace path="cpk/info/description/text()" withText="${here.languagePack.description}"/>
</xmltask>
<!-- replace file="${stage.dir}/${langpack.name}/cpk.xml" token="Language Pack Installer" value="${langpack.name}"/ -->
<replace file="${stage.dir}/${langpack.name}/plugin.spring.xml" token="${plugin.name}.api" value="${langpack.name}.api"/>
<replace file="${stage.dir}/${langpack.name}/settings.xml" token="${plugin.name}" value="${langpack.name}"/>
<xmltask source="${stage.dir}/${langpack.name}/build.xml"
dest="${stage.dir}/${langpack.name}/build.xml"
report="false">
<attr path="project/property[@name='plugin.name']" attr="value" value="${langpack.name}"/>
</xmltask>
<propertyfile file="${stage.dir}/${langpack.name}/build.properties">
<entry key="ivy.artifact.id" value="${langpack.name}" />
<entry key="impl.title" value="${here.languagePack.title}" />
</propertyfile>
<!-- Update dashboards -->
<upper string="${plugin.name}" to="plugin.NAME" />
<upper string="${langpack.name}" to="langpack.NAME" />
<replace dir="${stage.dir}/${langpack.name}/dashboards" includes="**/*.cdfde">
<replacefilter token=""${plugin.name}"" value=""${langpack.name}""/> <!--covers: meta_pluginID -->
<replacefilter token="Components${plugin.name}_" value="Components${langpack.name}_"/> <!--covers: CPK datasources -->
<replacefilter token="${plugin.NAME}" value="${langpack.NAME}"/> <!--covers: CPK datasources -->
<replacefilter token="/${plugin.name}/" value="/${langpack.name}/"/> <!--covers: resource paths, filename -->
</replace>
<!-- Inherit the project.revision property -->
<property name="langpack.artifact.id" value="${langpack.name}"/>
<property name="langpack.zipfile" value="${langpack.artifact.id}-${langpack.distribution.version}.zip"/>
<property name="langpack.package.url" value="http://ci.analytical-labs.com/job/Webdetails-languagePackInstallers/lastSuccessfulBuild/artifact/dist/${langpack.zipfile}"/>
<!-- create a zip file -->
<zip zipfile="${dist.dir}/${langpack.zipfile}"
basedir="${stage.dir}"
excludes="**/Thumbs.db **/.DS_Store **/.git"
includes="${langpack.name}/**/*" />
<move tofile="${dist.dir}/${langpack.name}-${langpack.distribution.version}.zip" file="${dist.dir}/${langpack.zipfile}"/>
<!-- create a marketplace.xml file -->
<echoxml file="${dist.dir}/${langpack.name}.marketplace.xml">
<version>
<branch>${project.stage}</branch>
<version>${langpack.distribution.version}</version>
<name>${project.stage}</name>
<package_url>${langpack.package.url}</package_url>
<description>${here.languagePack.title}</description>
<build_id>${sequential.build.id}</build_id>
<min_parent_version>${marketplace.metadata.min_parent_version}</min_parent_version>
<max_parent_version>${marketplace.metadata.max_parent_version}</max_parent_version>
<development_stage>
<lane>${langpack.metadata.maturity.lane}</lane>
<phase>${langpack.metadata.maturity.phase}</phase>
</development_stage>
</version>
</echoxml>
<!-- create a market_entry.xml file -->
<copy file="${basedir}/market_entry.xml" tofile="${dist.dir}/${langpack.name}.market_entry.xml">
<filterset>
<filter token="langpack.name" value="${langpack.name}"/>
<filter token="langpack.metadata.appTitle" value="${here.languagePack.title}"/>
<filter token="langpack.metadata.appWelcomeMessage" value="${here.languagePack.description}"/>
<filter token="langpack.metadata.pentahoVersion" value="${langpack.metadata.pentahoVersion}"/>
<filter token="langpack.metadata.maintainer.name" value="${langpack.metadata.maintainer.name}"/>
<filter token="langpack.metadata.maintainer.url" value="${langpack.metadata.maintainer.url}"/>
<filter token="langpack.metadata.maintainer.img" value="${langpack.metadata.maintainer.img}"/>
<filter token="langpack.metadata.maturity.lane" value="${langpack.metadata.maturity.lane}"/>
<filter token="langpack.metadata.maturity.phase" value="${langpack.metadata.maturity.phase}"/>
<filter token="langpack.package.url" value="${langpack.package.url}"/>
<filter token="langCode" value="${langCode}"/>
<filter token="project.stage" value="${project.stage}"/>
<filter token="project.revision" value="${langpack.distribution.version}"/>
</filterset>
</copy>
<available file="${basedir}/data/${langCode}/resources/img/flag.png" property="market.entry.img.present"/>
<available file="${basedir}/data/${langCode}/resources/img/flag.png" property="market.entry.small_img.present"/>
<available file="${basedir}/data/${langCode}/resources/img/screenshot_1.png" property="market.entry.screenshot.1.present"/>
<available file="${basedir}/data/${langCode}/resources/img/screenshot_1.png" property="market.entry.screenshot.2.present"/>
<available file="${basedir}/data/${langCode}/resources/img/screenshot_1.png" property="market.entry.screenshot.3.present"/>
<!-- remove the xml comments and any references to non-existent images-->
<xmltask source="${dist.dir}/${langpack.name}.market_entry.xml"
dest="${dist.dir}/${langpack.name}.market_entry.xml"
report="false">
<remove path="//child::comment()"/>
<remove path="/market_entry/img" unless="market.entry.img.present"/>
<remove path="/market_entry/small_img" unless="market.entry.small_img.present"/>
<remove path="/market_entry/screenshots/screenshot[@id='1']" unless="market.entry.screenshot.1.present"/>
<remove path="/market_entry/screenshots/screenshot[@id='2']" unless="market.entry.screenshot.2.present"/>
<remove path="/market_entry/screenshots/screenshot[@id='3']" unless="market.entry.screenshot.3.present"/>
</xmltask>
</target>
<!--=======================================================================
build-language-packs
Builds all language packs
====================================================================-->
<target name="infer-and-build-language-pack">
<basename property="langCode" file="${langCodeFolder}"/>
<echo>Found language code: ${langCode} </echo>
<antcall target="build-language-pack" inheritall="true"/>
</target>
<target name="build-language-packs" depends="clean, resolve"
description="Builds all language packs">
<antcall target="install-antcontrib"/>
<foreach target="infer-and-build-language-pack" param="langCodeFolder">
<path>
<dirset dir="${basedir}/data/">
<include name="*"/>
</dirset>
</path>
</foreach>
</target>
<target name="install-packs" depends="build-language-packs">
<fail message="plugin.local.install.solutions.dir not set - cannot copy"
unless="plugin.local.install.solutions.dir"/>
<delete includeemptydirs="true">
<fileset dir="${basedir}/../">
<include name="languagePack_*/**/*"/>
</fileset>
</delete>
<move todir="${plugin.local.install.solutions.dir}/system/">
<fileset dir="${stage.dir}">
<include name="languagePack_*/**/*"/>
</fileset>
</move>
</target>
<target name="read-metadata">
<property name="metadata.json" value="./data/metadata.json"/>
<loadresource property="langpackMetadata">
<file file="${metadata.json}"/>
</loadresource>
<echo>Reading metadata...</echo>
<script language="javascript"><![CDATA[
// Evaluate the serialized JSON
var struct = eval("(" + langpackMetadata + ")");
// Set each property in the project environment.
for (i in struct) {
//echo1 = project.createTask("echo");
//echo1.setMessage(i + " is of type " + typeof struct[i]);
//echo1.perform();
if (typeof struct[i] == "object"){
if (! (struct[i] instanceof Array)){
for (k in struct[i]){
echo0 = project.createTask("echo");
echo0.setMessage(i + "." + k + " = " + struct[i][k]);
echo0.perform();
project.setProperty('langpack.metadata.' + i + '.' + k, struct[i][k]);
}
}
} else {
echo = project.createTask("echo");
echo.setMessage(i + " = " + struct[i]);
echo.perform();
buildProject.setProperty('langpack_metadata_' + i, "'" + struct[i] + "'");
}
}
]]></script>
<echo>Read from ${metadata.json}: appTitle = ${langpack_metadata_appTitle}...</echo>
</target>
</project>