-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.xml
697 lines (605 loc) · 30.3 KB
/
configure.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
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2018 NEOautus Ltd. (http://neoautus.com)
Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License.
-->
<project name="configure"
xmlns:ivy="antlib:org.apache.ivy.ant"
xmlns:if="ant:if"
xmlns:unless="ant:unless">
<fail>Error:
***** This project should NOT be run as root *****
<condition>
<equals arg1="root" arg2="${user.name}"/>
</condition>
</fail>
<property environment="env"/>
<property name="docs.dir" value="${basedir}/docs"/>
<property name="dist.dir" value="${basedir}/dist"/>
<property name="build.dir" value="${basedir}/build"/>
<dirname property="configure.dir" file="${ant.file.configure}"/>
<property name="cache.dir" value="${configure.dir}/cache"/>
<property name="artifacts.dir" value="${configure.dir}/build/artifacts"/>
<property name="libcache.dir" value="${cache.dir}/lib"/>
<property name="tmp.dir" value="${cache.dir}/tmp"/>
<property name="user.cache.dir" value="${user.home}/.configure-cache"/>
<!-- Comment out if you want default Ivy cache location ${user.home}/.ivy2 -->
<property name="ivy.default.ivy.user.dir" value="${cache.dir}/ivy2" />
<property name="stage.dir" value="${configure.dir}/stage"/>
<condition property="stage.available.flag">
<available file="${stage.dir}" type="dir"/>
</condition>
<property name="javac.source" value="1.8"/>
<property name="javac.target" value="1.8"/>
<property name="javac.debug" value="true"/>
<property name="javac.debuglevel" value="lines,vars,source"/>
<property name="javac.deprecation" value="on"/>
<property name="javac.optional" value="-Xlint:unchecked"/>
<!--property name="javac.bootclasspath" value="${basedir}/extras/java-rt/rt.jar:${basedir}/extras/java-rt/jce.jar"/-->
<property name="setup.ok.file" value="${cache.dir}/setup.ok"/>
<condition property="setup.ok.flag">
<available file="${setup.ok.file}"/>
</condition>
<target name="getlibs"
description="Retrieve default libraries from maven repositories.">
<resolvePath id="default/osgi">
<ivy:dependency org="org.osgi" name="org.osgi.core" rev="5.0.0"/>
<ivy:dependency org="org.osgi" name="org.osgi.compendium" rev="5.0.0"/>
<ivy:dependency org="org.osgi" name="org.osgi.enterprise" rev="5.0.0"/>
</resolvePath>
<property name="ipojo.rev" value="1.12.1"/>
<resolvePath id="default/ipojo">
<ivy:dependency org="org.apache.felix" name="org.apache.felix.ipojo" rev="${ipojo.rev}" transitive="false"/>
<ivy:dependency org="org.apache.felix" name="org.apache.felix.ipojo.api" rev="${ipojo.rev}" transitive="false"/>
<ivy:dependency org="org.apache.felix" name="org.apache.felix.ipojo.annotations" rev="${ipojo.rev}" transitive="false"/>
<!--dependency org="org.apache.felix" name="org.apache.felix.ipojo.handler.eventadmin" rev="1.8.0"/-->
<ivy:dependency org="org.apache.felix" name="org.apache.felix.ipojo.handler.extender" rev="1.4.0" transitive="false"/>
</resolvePath>
<resolvePath id="default/slf4j-api">
<ivy:dependency org="org.slf4j" name="slf4j-api" rev="1.7.25" transitive="false"/>
</resolvePath>
</target>
<target name="setup" unless="setup.ok.flag"
description="Retrieve base tools for this project.">
<!-- Get Ivy -->
<mkdir dir="${cache.dir}/setup"/>
<get dest="${cache.dir}/setup/ivy.jar"
src="http://search.maven.org/remotecontent?filepath=org/apache/ivy/ivy/2.4.0/ivy-2.4.0.jar"
skipexisting="true"/>
<!-- Get Ant-Contrib -->
<get dest="${cache.dir}/setup/ant-contrib.jar"
src="http://search.maven.org/remotecontent?filepath=ant-contrib/ant-contrib/1.0b3/ant-contrib-1.0b3.jar"
skipexisting="true"/>
<!-- Done! -->
<touch file="${setup.ok.file}" verbose="false"/>
</target>
<!-- Fetch dependencies from Github and place jars on cache/lib/[group] -->
<macrodef name="getDependency">
<attribute name="group"/>
<attribute name="org"/>
<attribute name="name"/>
<attribute name="rev"/>
<attribute name="type" default="jar"/>
<attribute name="outfileProperty" default="_dist.jar"/>
<sequential>
<!-- The file downloaded from external repositories like Github -->
<local name="_cache.file"/>
<property name="_cache.file"
value="${user.cache.dir}/@{org}/@{name}/@{name}-@{rev}.@{type}"/>
<!-- The file built locally -->
<local name="_cache.snapshot.file"/>
<property name="_cache.snapshot.file"
value="${user.cache.dir}/@{org}/@{name}/@{name}-@{rev}-SNAPSHOT.@{type}"/>
<!-- If a local snapshot exists use it, otherwise use downloaded file -->
<local name="_source.file"/>
<condition property="_source.file" value="${_cache.snapshot.file}" else="${_cache.file}">
<and>
<available file="${_cache.snapshot.file}" type="file"/>
<not><isset property="no-snapshots"/></not>
</and>
</condition>
<!-- The downloaded file is available? -->
<if><not><available file="${_source.file}"/></not>
<then>
<!-- Create the base diretory location -->
<local name="_source.dirname"/>
<dirname property="_source.dirname" file="${_source.file}"/>
<mkdir dir="${_source.dirname}"/>
<!-- Make magic conversions -->
<local name="_project.dir"/>
<loadresource property="_project.dir">
<string value="@{org}"/>
<filterchain>
<!-- Make org.lucidj.someproject => neoautus/lucidj-someproject -->
<replacestring from="org.lucidj." to="neoautus/lucidj-"/>
</filterchain>
</loadresource>
<!-- Get the file from repository -->
<get dest="${_source.dirname}/@{name}.tmp"
src="https://github.com/${_project.dir}/releases/download/@{rev}/@{name}-@{rev}.@{type}"
skipexisting="false"/>
<move file="${_source.dirname}/@{name}.tmp"
tofile="${_source.file}"/>
</then>
</if>
<!-- TODO: DELETE THE TARGET.JAR AND TARGET-SNAPSHOT.JAR TO AVOID CONFLICT -->
<!-- Now we have either the downloaded file or the snapshot available to copy from -->
<echo taskname="getDependency" message="Source artifact: ${_source.file}"/>
<local name="_dest.basename"/>
<basename property="_dest.basename" file="${_source.file}"/>
<local name="_dist.jar"/>
<property name="_dist.jar" value="${libcache.dir}/@{group}/${_dest.basename}"/>
<property name="@{outfileProperty}" value="${_dist.jar}"/>
<copy file="${_source.file}" tofile="${_dist.jar}" taskname="getDependency" overwrite="true"/>
</sequential>
</macrodef>
<macrodef name="publish">
<attribute name="file"/>
<attribute name="org"/>
<attribute name="name"/>
<attribute name="rev"/>
<attribute name="type" default="jar"/>
<sequential>
<!-- Store the file with the intended version -->
<local name="_cache.file"/>
<property name="_cache.file"
value="${user.cache.dir}/@{org}/@{name}/@{name}-@{rev}.@{type}"/>
<copy file="@{file}" tofile="${_cache.file}" overwrite="true"/>
<!-- Store the file last snapshot -->
<local name="_cache.snapshot.file"/>
<property name="_cache.snapshot.file"
value="${user.cache.dir}/@{org}/@{name}/@{name}-@{rev}-SNAPSHOT.@{type}"/>
<copy file="@{file}" tofile="${_cache.snapshot.file}" overwrite="true"/>
</sequential>
</macrodef>
<!-- Fetch dependencies and place jars on cache/lib/[id] -->
<macrodef name="resolvePath">
<attribute name="id"/>
<attribute name="type" default="jar,bundle"/>
<attribute name="offline" default="false"/>
<attribute name="sync" default="false"/>
<element name="dependency-list" implicit="true" optional="no"/>
<sequential>
<local name="resolve.ok.file"/>
<property name="resolve.ok.file" value="${libcache.dir}/@{id}/resolve.ok"/>
<if><not><available file="${resolve.ok.file}"/></not>
<then>
<echo taskname="resolvePath" message=":: Resolving dependencies for: @{id}"/>
<ivy:resolve resolveid="@{id}.resolve"
log="download-only" useCacheOnly="@{offline}" type="@{type}">
<dependency-list/>
</ivy:resolve>
<ivy:retrieve taskname="resolvePath"
sync="@{sync}" type="@{type}" resolveid="@{id}.resolve"
pattern="${libcache.dir}/@{id}/[type]/[artifact]-[revision].[ext]"/>
<touch file="${resolve.ok.file}" verbose="false"/>
</then>
</if>
<path id="@{id}">
<fileset dir="${libcache.dir}/@{id}" includes="**/*.jar"/>
</path>
<!--echo message="Path @{id}: ${ant.refid:@{id}}"/-->
</sequential>
</macrodef>
<target name="setup-tasks" depends="setup">
<!-- Apache Ivy -->
<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant">
<classpath>
<fileset dir="${cache.dir}/setup" includes="ivy.jar"/>
</classpath>
</taskdef>
<!-- Ant-Contrib -->
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<fileset dir="${cache.dir}/setup" includes="ant-contrib.jar"/>
</classpath>
</taskdef>
<!-- Bnd Tasks -->
<resolvePath id="tasks/bnd">
<ivy:dependency org="biz.aQute.bnd" name="bnd" rev="2.4.0" transitive="false"/>
</resolvePath>
<taskdef resource="aQute/bnd/ant/taskdef.properties" classpathref="tasks/bnd"/>
<!-- iPojo Tasks -->
<resolvePath id="tasks/ipojo">
<dependency org="org.apache.felix" name="org.apache.felix.ipojo.ant" rev="1.12.1"/>
<dependency org="org.apache.felix" name="org.apache.felix.ipojo.metadata" rev="1.6.0"/>
<dependency org="org.apache.felix" name="org.apache.felix.ipojo.annotations" rev="1.12.1"/>
<dependency org="org.ow2.asm" name="asm-all" rev="5.0.2"/>
</resolvePath>
<taskdef name="ipojo" classname="org.apache.felix.ipojo.task.IPojoTask" classpathref="tasks/ipojo"/>
</target>
<target name="init" depends="setup-tasks, getlibs">
<path id="tasks.path">
<fileset dir="${libcache.dir}/tasks" includes="**/*.jar"/>
</path>
<path id="default.path">
<fileset dir="${libcache.dir}/default" includes="**/*.jar"/>
</path>
</target>
<target name="clean"
description="Clear all build artifacts created by the project.">
<delete dir="${build.dir}"/>
<delete dir="${dist.dir}"/>
</target>
<target name="zero" depends="clean"
description="Clear all build artifacts created by the project AND the stage.">
<delete dir="${stage.dir}"/>
</target>
<target name="reconfigure"
description="Clear all Ivy/Maven caches and retrieve all external dependencies.">
<delete dir="${cache.dir}"/>
<ant target="init" inheritall="false"/>
</target>
<target name="configure"
description="Clear library caches and retrieve all external dependencies.">
<delete dir="${cache.dir}/lib"/>
<ant target="init" inheritall="false"/>
</target>
<target name="rebuild" depends="zero, configure">
<!-- Invoke default task for build.xml -->
<subant buildpath="${basedir}"/>
</target>
<!-- Wrap any jar more or less like wrap: protocol -->
<!-- src: full path for source jar -->
<!-- dest: destination directory OR full path of wrapped jar -->
<macrodef name="wrapjar">
<attribute name="src"/>
<attribute name="dest"/>
<attribute name="excludes" default="!javax.*"/>
<sequential>
<basename property="src.basename" file="@{src}" suffix=".jar"/>
<propertyregex property="bsn" input="${src.basename}"
regexp="(.*)-(\d+\..*)" select="\1" defaultValue="${src.basename}"/>
<propertyregex property="version" input="${src.basename}"
regexp="(.*)-(\d+\..*)" select="\2" defaultValue="0.0.0"/>
<condition property="output.jar" value="@{dest}/${src.basename}.jar" else="@{dest}">
<available file="@{dest}" type="dir"/>
</condition>
<property name="output.bnd" value="${output.jar}.bnd"/>
<echo file="${output.bnd}">
Bundle-SymbolicName: ${bsn}
Bundle-Name: wrapped-${bsn}
Bundle-Version: ${version}
Import-Package: *;resolution:=optional
Export-Package: @{excludes},*;version=${version}
</echo>
<bnd files="${output.bnd}" output="${output.jar}"
eclipse="false" failok="false" exceptions="true">
<classpath location="@{src}"/>
</bnd>
<jar destfile="${output.jar}" update="true" filesonly="true">
<zipfileset src="@{src}">
<include name="**/*"/>
<exclude name="**/*.class"/>
</zipfileset>
</jar>
</sequential>
</macrodef>
<macrodef name="urlescape">
<attribute name="name"/>
<attribute name="value"/>
<sequential>
<loadresource property="@{name}">
<string value="@{value}"/>
<filterchain>
<tokenfilter>
<filetokenizer/>
<!-- TODO: WHAT MORE? IS THERE A BETTER WAY?? -->
<replacestring from=" " to="%20"/>
</tokenfilter>
</filterchain>
</loadresource>
</sequential>
</macrodef>
<macrodef name="deploy">
<attribute name="file"/>
<sequential>
<!-- 1) Top priority: env var DEPLOY_DIR set -->
<condition property="deploy.dir" value="${env.DEPLOY_DIR}">
<isset property="env.DEPLOY_DIR"/>
</condition>
<!-- 2) Then: explicit deploy.properties set -->
<property file="${stage.dir}/deploy.properties" if:set="stage.available.flag"/>
<!-- 3) Default: Only stage available -->
<condition property="deploy.dir" value="${stage.dir}/deploy">
<isset property="stage.available.flag"/>
</condition>
<if><isset property="deploy.dir"/>
<then>
<copy file="@{file}" todir="${deploy.dir}" overwrite="true" taskname="deploy"/>
</then>
<else>
<!-- 4) If none of above apply, try to deploy to an active server -->
<if><http url="http://localhost:8181/~localsvc/deploy"/>
<then>
<echo taskname="deploy" message="Remote deploy: @{file}"/>
<local name="file.location"/>
<urlescape name="file.location" value="@{file}"/>
<concat taskname="deploy">
<url url="http://localhost:8181/~localsvc/deploy?file:${file.location}"/>
</concat>
</then>
</if>
</else>
</if>
</sequential>
</macrodef>
<macrodef name="artifact">
<attribute name="file"/>
<attribute name="group" default="default"/>
<sequential>
<mkdir dir="${artifacts.dir}/@{group}" taskname="artifact"/>
<copy file="@{file}" todir="${artifacts.dir}/@{group}" overwrite="true" taskname="artifact"/>
</sequential>
</macrodef>
<macrodef name="iterate">
<attribute name="target"/>
<attribute name="dir" default="${basedir}"/>
<attribute name="includes" default="*/build.xml"/>
<sequential>
<subant target="@{target}">
<fileset dir="@{dir}" includes="@{includes}"/>
</subant>
</sequential>
</macrodef>
<macrodef name="listpackages">
<attribute name="dir"/>
<attribute name="property"/>
<sequential>
<fileset dir="@{dir}" id="classes">
<include name="**/*.class"/>
<exclude name="code/**"/>
</fileset>
<local name="packages"/>
<pathconvert dirsep="/" refid="classes" property="packages" pathsep="," setonempty="false">
<mapper type="regexp" from="@{dir}/(.*)/.*\.class" to="\1" />
</pathconvert>
<dirset id="unique.packages" dir="@{dir}" includes="${packages}"/>
<pathconvert dirsep="." refid="unique.packages" property="@{property}" pathsep=", ">
<map from="@{dir}/" to=""/>
</pathconvert>
</sequential>
</macrodef>
<macrodef name="build.bundle">
<attribute name="symbolicName"/>
<attribute name="version" default="0.0.0"/>
<attribute name="src"/>
<attribute name="bnd" default="auto"/>
<attribute name="exports" default="void"/>
<attribute name="ipojo" default="true"/>
<attribute name="outfileProperty" default="bundle.temp.jar"/>
<attribute name="defaultPathId" default="default.path"/>
<attribute name="embeddedClasses" default="emptyFileset"/>
<element name="classpaths" optional="yes"/>
<element name="privateClasspath" optional="yes"/>
<sequential>
<local name="module.build.dir"/>
<property name="module.build.dir" value="${build.dir}/@{symbolicName}-@{version}"/>
<local name="module.classes.dir"/>
<property name="module.classes.dir" value="${module.build.dir}/classes"/>
<local name="module.dist.dir"/>
<property name="module.dist.dir" value="${dist.dir}/@{symbolicName}"/>
<local name="module.dist.jar"/>
<property name="module.dist.jar" value="${module.dist.dir}/@{symbolicName}-@{version}.jar"/>
<local name="bundle.temp.jar"/>
<property name="@{outfileProperty}" value="${module.dist.jar}"/>
<delete dir="${module.classes.dir}"/>
<mkdir dir="${module.classes.dir}"/>
<!-- ================================= -->
<!-- Embed private libraries/classpath -->
<!-- ================================= -->
<!-- We use to default embeddedClasses=emptyFileset -->
<fileset id="emptyFileset" dir="@{src}" includes="---*---"/>
<copy todir="${module.build.dir}/private" overwrite="true" flatten="true">
<fileset refid="emptyFileset"/><!-- just satisfy copy if no privateClasspath -->
<privateClasspath/>
</copy>
<path id="private.path">
<fileset dir="${module.build.dir}">
<include name="private/**/*.jar"/>
</fileset>
</path>
<!-- So we can use defaultPathId=excludeDefault -->
<path id="excludeDefault"/>
<!-- ================= -->
<!-- Javac as usual... -->
<!-- ================= -->
<!-- Embed foreign classes if needed -->
<copy todir="${module.classes.dir}">
<fileset refid="@{embeddedClasses}"/>
</copy>
<path id="build.bundle.path">
<pathelement path="${module.classes.dir}"/>
<path refid="private.path"/>
<classpaths/>
<path refid="@{defaultPathId}"/>
</path>
<javac srcdir="@{src}" destdir="${module.classes.dir}"
source="${javac.source}" target="${javac.target}"
debug="${javac.debug}" debuglevel="${javac.debuglevel}" deprecation="${javac.deprecation}"
includeantruntime="false">
<compilerarg value="${javac.optional}"/>
<classpath refid="build.bundle.path"/>
</javac>
<delete file="${module.dist.jar}"/>
<mkdir dir="${module.dist.dir}"/>
<!-- ========================= -->
<!-- Let's build a OSGi Bundle -->
<!-- ========================= -->
<!--
We can't just create a jar at this point, because we
need a _bnd file_ to describe to Bnd Tool what to do.
The bnd file is much like a recipe. More info at:
http://bnd.bndtools.org/chapters/160-jars.html
-->
<!-- Creates simple bnd file if @bnd param set to auto -->
<local name="bnd.file"/>
<property name="bnd.file" value="${module.build.dir}/bundle.bnd"/>
<if><equals arg1="@{bnd}" arg2="auto"/>
<then>
<echo message="Bundle descriptor set to automatic"/>
<echo file="${bnd.file}" append="false"
message="### Start of generated content ###${line.separator}"/>
<echo file="${bnd.file}" append="true"
message="Bundle-Name: @{symbolicName}-@{version}${line.separator}"/>
<echo file="${bnd.file}" append="true"
message="Bundle-SymbolicName: @{symbolicName}${line.separator}"/>
<echo file="${bnd.file}" append="true"
message="Bundle-Version: @{version}${line.separator}"/>
<!-- Magically extracts all used packages directly from compiled classes dir -->
<local name="package.list"/>
<listpackages dir="${module.classes.dir}" property="package.list"/>
<echo file="${bnd.file}" append="true"
message="Private-Package: ${package.list}${line.separator}"/>
<!-- Include private classpath if it exists -->
<if><resourcecount refid="private.path" when="greater" count="0"/>
<then>
<!-- We need to cut-off the base directory and separate the list with ',' -->
<local name="private.path.bnd"/>
<pathconvert refid="private.path" property="private.path.bnd" dirsep="/" pathsep=",">
<map from="${module.build.dir}/" to=""/>
</pathconvert>
<!-- Set the handy Bundle-ClassPath to include all embedded libraries -->
<echo file="${bnd.file}" append="true"
message="Bundle-ClassPath: .,${private.path.bnd}${line.separator}"/>
<!-- We need to include private/ as resource, so the libraries get included into bundle -->
<echo file="${bnd.file}" append="true"
message="Include-Resource: private=private${line.separator}"/>
</then>
</if>
</then>
<else>
<copy file="@{bnd}" tofile="${bnd.file}" overwrite="true"/>
</else>
</if>
<!-- We may have a exports parameter -->
<if><not><equals arg1="@{exports}" arg2="void"/></not>
<then>
<echo file="${bnd.file}" append="true"
message="Export-Package: @{exports}${line.separator}"/>
</then>
</if>
<!-- Append bundle.inc to bundle.bnd, if it exists -->
<local name="bnd.inc.file"/>
<property name="bnd.inc.file" value="${basedir}/@{src}/../bundle.inc"/>
<if><available file="${bnd.inc.file}"/>
<then>
<concat destfile="${bnd.file}" append="true" fixlastline="true">
<file name="${bnd.inc.file}"/>
</concat>
</then>
</if>
<!--
At this point we have either a user-provided bnd file OR
a generated one. Now we are ready to create the OSGi bundle!
-->
<!-- Invokes the Bnd Tool task to create our jar bundle -->
<bnd files="${bnd.file}" output="${module.dist.jar}"
eclipse="false" failok="false" exceptions="true">
<classpath refid="build.bundle.path"/>
</bnd>
<!-- Add full resources/ dir if it exists -->
<if><available file="@{src}/../resources" type="dir"/>
<then>
<jar destfile="${module.dist.jar}" update="true">
<fileset dir="@{src}/../resources" includes="**/*"/>
</jar>
</then>
</if>
<!-- ================================ -->
<!-- Extra steps: Apply iPOJO tooling -->
<!-- ================================ -->
<if><istrue value="@{ipojo}"/>
<then>
<ipojo input="${module.dist.jar}">
<classpath refid="build.bundle.path"/>
</ipojo>
</then>
</if>
</sequential>
</macrodef>
<macrodef name="build.module">
<attribute name="dir"/>
<attribute name="symbolicName"/>
<attribute name="version" default="0.0.0"/>
<attribute name="ipojo" default="true"/>
<attribute name="deploy" default="false"/>
<attribute name="exports" default="void"/><!-- TODO: Make an 'auto' which auto-exports all -->
<attribute name="outfileProperty" default="module.temp.jar"/>
<attribute name="embeddedClasses" default="emptyFileset"/>
<element name="classpath" optional="yes"/>
<sequential>
<local name="bnd.file"/>
<condition property="bnd.file" value="@{dir}/bundle.bnd" else="auto">
<available file="@{dir}/bundle.bnd"/>
</condition>
<local name="module.temp.jar"/>
<build.bundle bnd="${bnd.file}" src="@{dir}/src" exports="@{exports}" version="@{version}"
symbolicName="@{symbolicName}" outfileProperty="@{outfileProperty}" ipojo="@{ipojo}"
embeddedClasses="@{embeddedClasses}">
<classpaths>
<classpath/>
</classpaths>
<privateClasspath>
<fileset dir="@{dir}">
<include name="private/**/*.jar"/>
</fileset>
</privateClasspath>
</build.bundle>
<if><istrue value="@{deploy}"/>
<then>
<deploy file="${@{outfileProperty}}"/>
</then>
</if>
</sequential>
</macrodef>
<macrodef name="build.classic.jar">
<attribute name="src" default="${basedir}/src"/>
<attribute name="name" default="@{src}"/>
<attribute name="version" default="none"/>
<attribute name="outfileProperty" default="_classic.temp.jar"/>
<element name="manifests" optional="yes"/>
<element name="classpaths" optional="yes"/>
<element name="addjar" optional="yes"/>
<sequential>
<local name="jar.name"/>
<condition property="jar.name" value="@{name}" else="@{name}-@{version}">
<equals arg1="@{version}" arg2="none"/>
</condition>
<local name="_classes.dir"/>
<property name="_classes.dir" value="${build.dir}/${jar.name}"/>
<delete dir="${_classes.dir}" quiet="true"/>
<mkdir dir="${_classes.dir}"/>
<javac srcdir="@{src}" destdir="${_classes.dir}"
debug="${javac.debug}" debuglevel="${javac.debuglevel}" deprecation="${javac.deprecation}"
source="${javac.source}" target="${javac.target}" bootclasspath="${javac.bootclasspath}"
includeantruntime="false">
<compilerarg line="${javac.optional}"/>
<classpath>
<classpaths/>
</classpath>
</javac>
<local name="_dist.jar"/>
<property name="_dist.jar" value="${dist.dir}/@{name}/${jar.name}.jar"/>
<local name="_classic.temp.jar"/>
<property name="@{outfileProperty}" value="${_dist.jar}"/>
<delete file="${_dist.jar}"/>
<jar destfile="${_dist.jar}">
<addjar/>
<fileset dir="${_classes.dir}" includes="**/*"/>
<manifest>
<!-- Some jars actually are not meant to be bundles! -->
<attribute name="Disclaimer" value=" |\ _,,,--,,_ +----------------------------+ /,`.-'`' ._ \-;;,_ | This jar is meant to be | Zzzz |,4- ) )_ .;.( `'-' | classic, not OSGi bundle | '---''(_/._)-'(_\_) +----------------------------+"/><manifests/>
</manifest>
</jar>
</sequential>
</macrodef>
</project>