-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
514 lines (465 loc) · 21.1 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
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
<project name="Ceylon SDK Transaction module" basedir="." default="test">
<property file="build.properties" />
<!-- Try to determine where Ceylon is installed -->
<condition property="batExt" value=".bat">
<os family="windows" />
</condition>
<property name="batExt" value=""/>
<exec executable="ceylon${batExt}" outputproperty="ceylon.home" failifexecutionfails="false">
<arg value="--show-home" />
</exec>
<property environment="env"/>
<condition property="ceylon.home" value="${env.CEYLON_HOME}" else="${basedir}/../ceylon/dist/dist">
<isset property="env.CEYLON_HOME" />
</condition>
<property name="ceylon.verbosity" value="false"/>
<property name="ceylon.executable" value="${ceylon.home}/bin/ceylon"/>
<property name="out.repo" location="${basedir}/modules"/>
<property name="deps.repo" location="${basedir}/test-deps"/>
<property name="test.repo" location="${basedir}/modules"/>
<property name="lib.dir" location="${basedir}/lib"/>
<property name="ceylon.ant.lib" value="${ceylon.home}/lib/ceylon-ant.jar" />
<property name="osgi" location="${basedir}/osgi" />
<property name="osgi.p2" location="${osgi}/p2" />
<property name="osgi.karaf" location="${osgi}/karaf" />
<property name="osgi.dist" location="${osgi}/dist" />
<property name="osgi.build" location="${osgi}/build" />
<property name="osgi.dist.plugins" location="${osgi.dist}/plugins" />
<property name="eclipse.project.path" location="${basedir}/../ceylon-ide-eclipse"/>
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="${lib.dir}/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
<taskdef resource="taskdef.properties">
<classpath>
<pathelement path="${lib.dir}/org.osgi.impl.bundle.repoindex.ant-2.1.2.jar" />
</classpath>
</taskdef>
<taskdef resource="aQute/bnd/ant/taskdef.properties"
classpath="${lib.dir}/biz.aQute.bnd-2.3.0.jar"/>
<taskdef name="bindex" classname="org.osgi.impl.bundle.bindex.ant.BindexTask"
classpath="${lib.dir}/org.osgi.impl.bundle.bindex-2.2.0.jar"/>
<!-- Local repository -->
<property name="ceylon.repo.dir" location="${user.home}/.ceylon/repo" />
<path id="ant-tasks">
<pathelement location="${ceylon.ant.lib}"/>
</path>
<target name="ceylondefs" unless="ceylondefined">
<property name="ceylondefined" value="true" />
<typedef resource="com/redhat/ceylon/ant/antlib.xml" classpathref="ant-tasks"/>
<reposet id="reposet.compile.test">
<repo url="${out.repo}"/>
<repo url="${deps.repo}"/><!-- Needed for h2.jar dep of test.ceylon.dbc -->
</reposet>
<reposet id="reposet.run.test">
<reposet refid="reposet.compile.test"/>
<repo url="${test.repo}"/>
</reposet>
<moduleset id="modules.sdk.jvm">
<module name="ceylon.transaction"/>
</moduleset>
<moduleset id="modules.sdk.js">
</moduleset>
<moduleset id="modules.sdk.doc">
<module name="ceylon.transaction"/>
</moduleset>
<moduleset id="modules.test.jvm">
<module name="test.ceylon.transaction"/>
</moduleset>
<moduleset id="modules.test.js">
</moduleset>
</target>
<target name="clean"
description="Deletes the test-modules and modules directories">
<delete dir="${out.repo}"/>
<delete dir="${test.repo}"/>
<delete dir="${osgi.dist}"/>
<delete dir="${osgi.build}"/>
</target>
<target name="compile-jvm" depends="ceylondefs">
<ceylon-compile executable="${ceylon.executable}"
verbose="${ceylon.verbosity}"
encoding="UTF-8"
pack200="true"
out="${out.repo}"
fork="true">
<moduleset refid="modules.sdk.jvm"/>
</ceylon-compile>
</target>
<target name="compile" depends="compile-jvm"
description="Compiles the SDK modules to the 'modules' repository" />
<target name="compile-test-jvm" depends="ceylondefs">
<ceylon-compile executable="${ceylon.executable}"
src="test-source"
out="${test.repo}"
verbose="${ceylon.verbosity}"
encoding="UTF-8"
fork="true">
<reposet refid="reposet.compile.test"/>
<moduleset refid="modules.test.jvm"/>
</ceylon-compile>
</target>
<target name="compile-test" depends="compile-test-jvm"
description="Compiles the test modules to the 'test-modules' repository" />
<target name="test-jvm" depends="compile-test-jvm"
description="Runs the compiled test modules from the 'test-modules' repository">
<ceylon-test
report="true"
fork="true">
<reposet refid="reposet.run.test"/>
<moduleset refid="modules.test.jvm"/>
</ceylon-test>
</target>
<target name="test" depends="compile,compile-test,test-jvm"
description="Runs the compiled test modules from the 'test-modules' repository" />
<target name="test-quick" depends="compile-test,test-jvm" />
<target name="doc" depends="ceylondefs"
description="Documents the SDK modules to the 'modules' repository">
<ceylon-doc executable="${ceylon.executable}"
includesourcecode="true"
nomtimecheck="true"
encoding="UTF-8"
fork="true">
<moduleset refid="modules.sdk.doc"/>
<linkset>
<link pattern="ceylon" url="http://modules.ceylon-lang.org/repo/1/"/>
</linkset>
</ceylon-doc>
</target>
<target name="dist" depends="compile,doc">
</target>
<target name="publish" depends="dist,publish-quick"
description="Copies the SDK modules to the user's repository">
</target>
<target name="publish-quick" depends="ceylondefs">
<ceylon-copy
out="${ceylon.repo.dir}"
all="true"
fork="true">
<moduleset>
<sourcemodules/>
</moduleset>
</ceylon-copy>
</target>
<target name="copy-herd" depends="ceylondefs">
<fail message="Please specify a target Herd upload repo url with -Dherd.repo=..." unless="herd.repo"/>
<fail message="Please specify a target Herd user name with -Dherd.user=..." unless="herd.user"/>
<fail message="Please specify a target Herd password with -Dherd.pass=..." unless="herd.pass"/>
<ceylon-copy
nodefaultrepositories="true"
withdependencies="false"
out="${herd.repo}"
user="${herd.user}"
pass="${herd.pass}"
all="true"
verbose="files"
fork="true">
<reposet>
<repo url="${out.repo}"/>
</reposet>
<moduleset>
<sourcemodules/>
</moduleset>
</ceylon-copy>
</target>
<target name="addRequiredOSGIHeaders">
<echo>Adding / overriding OSGI metadata in ${currentFile}</echo>
<tempfile property="bundleDefinitionFile"/>
<echo file="${bundleDefinitionFile}">Bundle-SymbolicName: ${CeylonName}${line.separator}</echo>
<echo file="${bundleDefinitionFile}" append="true">Bundle-Version: ${CeylonVersion}${line.separator}</echo>
<echo file="${bundleDefinitionFile}" append="true">Export-Package: *${line.separator}</echo>
<echo file="${bundleDefinitionFile}" append="true">Import-Package: org.apache.log4j.*;resolution:=optional, org.slf4j.*;resolution:=optional, org.jboss.logmanager.*;resolution:=optional, javax.enterprise.*;resolution:=optional, javax.interceptor.*;resolution:=optional, javax.resource.spi.*;resolution:=optional, org.apache.webdav.*;resolution:=optional, javax.inject.*;resolution:=optional, org.hornetq.core.journal.*;resolution:=optional, sun.misc.*;resolution:=optional, org.apache.commons.httpclient;resolution:=optional, org.apache.activemq.artemis.*;resolution:=optional, *${line.separator}</echo>
<if>
<equals arg1="${CeylonName}" arg2="org.jboss.xnio.nio"/>
<then>
<echo file="${bundleDefinitionFile}" append="true">Require-Bundle: org.jboss.xnio.api;bundle-version=${CeylonVersion};visibility:=reexport${line.separator}</echo>
</then>
</if>
<bndwrap exceptions="true" force="true" jars="${currentFile}" output="${currentFile}.bnd.jar" definitions="${bundleDefinitionFile}">
</bndwrap>
<delete file="${bundleDefinitionFile}"/>
<echo message="Adding OSGI headers to ${currentFile}"/>
<copy file="${currentFile}" tofile="${currentFile}.original"/>
<jar destfile="${currentFile}.result" filesetmanifest="merge">
<zipfileset src="${currentFile}.original" includes="**" excludes="META-INF/MANIFEST.MF"/>
<zipfileset src="${currentFile}.bnd.jar" includes="META-INF/MANIFEST.MF"/>
</jar>
<copy file="${currentFile}.result" tofile="${currentFile}" overwrite="true" force="true"/>
<delete file="${currentFile}.original" failonerror="false" deleteonexit="true"/>
<delete file="${currentFile}.bnd.jar" failonerror="false" deleteonexit="true"/>
<delete file="${currentFile}.result" failonerror="false" deleteonexit="true"/>
</target>
<target name="copyModuleArchiveForOSGI">
<loadproperties>
<zipentry zipfile="${currentFile}" name="META-INF/MANIFEST.MF"/>
<filterchain>
<linecontainsregexp>
<regexp pattern="^(Bundle-SymbolicName|Bundle-Version)"/>
</linecontainsregexp>
<replaceregex pattern="\s+$" replace=""/>
<replaceregex pattern="^\s+" replace=""/>
</filterchain>
</loadproperties>
<basename property="module.jar.name" file="${currentFile}"/>
<pathconvert property="unixPath" targetos="unix">
<path location="${currentFile}"/>
</pathconvert>
<propertyregex property="CeylonVersion"
input="${unixPath}"
regexp=".+/([^/]+)/[^/]+\.(j|c)ar"
replace="\1">
</propertyregex>
<propertyregex property="CeylonName"
input="${module.jar.name}"
regexp="(.+)-${CeylonVersion}\.(j|c)ar"
replace="\1">
</propertyregex>
<echo>Ceylon name: ${CeylonName}</echo>
<echo>Ceylon version: ${CeylonVersion}</echo>
<if>
<or>
<not>
<isset property="Bundle-SymbolicName"/>
</not>
<not>
<equals arg1="${Bundle-SymbolicName}" arg2="${CeylonName}"/>
</not>
</or>
<then>
<antcall target="addRequiredOSGIHeaders" inheritall="true"/>
<property name="CheckedBundleSymbolicName" value="${CeylonName}"/>
<property name="CheckedBundleVersion" value="${CeylonVersion}"/>
</then>
<else>
<property name="CheckedBundleSymbolicName" value="${Bundle-SymbolicName}"/>
<property name="CheckedBundleVersion" value="${Bundle-Version}"/>
</else>
</if>
<property name="bundleFileName" value="${CheckedBundleSymbolicName}_${CheckedBundleVersion}.jar"/>
<if>
<or>
<contains string="${bundleFileName}" substring="ceylon.interop.spring_"/>
<contains string="${bundleFileName}" substring="ceylon.interop.persistence_"/>
</or>
<then>
<echo>Ignoring bundle: ${bundleFileName}</echo>
</then>
<else>
<copy file="${currentFile}"
tofile="${osgi.dist.plugins}/${bundleFileName}"
overwrite="true"/>
</else>
</if>
</target>
<target name="retrieveDependencies" depends="ceylondefs">
<ceylon-copy
executable="${ceylon.executable}"
offline="true"
verbose="${ceylon.verbosity}"
nodefaultrepositories="true"
withdependencies="true"
out="${osgi.dist}/tempRepo"
fork="true">
<rep url="${basedir}/modules"/>
<rep url="${user.home}/.ceylon/cache"/>
<sourcemodules dir="${basedir}/source"/>
</ceylon-copy>
</target>
<target name="generateFeatures">
<property name="feature.dir" value="${build.dist.features}/${feature.id}_${feature.version}"/>
<mkdir dir="${feature.dir}"/>
<property name="featureFile" value="${feature.dir}/feature.xml"/>
<xslt style="${xslFile}" in="${osgi.dist}/index.xml" out="${featureFile}">
<param name="featureId" expression="${feature.id}"/>
<param name="featureVersion" expression="${feature.version}"/>
</xslt>
</target>
<target name="osgi-quick" depends="retrieveDependencies">
<mkdir dir="${osgi.dist.plugins}" />
<pathconvert pathsep="
" property="distribRepoBase">
<path location="${ceylon.main.dir}/dist/dist/repo"/>
</pathconvert>
<echo file="${osgi.dist}/distribRepoBase.txt">${distribRepoBase}</echo>
<fileset id="distributionArchivesSet" dir="${distribRepoBase}"
includes="**/*.?ar"/>
<pathconvert pathsep="
" property="distributionArchivesProp" refid="distributionArchivesSet">
<map from="${distribRepoBase}/" to=""/>
</pathconvert>
<echo file="${osgi.dist}/excludes.txt">${distributionArchivesProp}</echo>
<foreach target="copyModuleArchiveForOSGI" param="currentFile" >
<path>
<fileset dir="${osgi.dist}/tempRepo">
<include name="**/*.?ar"/>
<exclude name="**/com.redhat.ceylon.*.?ar"/>
<excludesfile name="${osgi.dist}/excludes.txt"/>
</fileset>
</path>
</foreach>
<copy todir="${osgi.dist.plugins}">
<fileset dir="${ceylon.main.dir}/dist/osgi/build/dist/plugins" includes="org.jboss.logmanager_*.jar"/>
</copy>
<!-- <delete dir="${osgi.dist}/tempRepo" failonerror="false" deleteonexit="true"/> -->
<!-- <delete dir="${osgi.dist}/excludes.txt" failonerror="false" deleteonexit="true"/> -->
<makeurl property="rootUrl" file="${osgi.dist}"/>
<repoindex name="Ceylon SDK Bundles - R5 OBR format"
out="${osgi.dist}/index.xml"
compressed="false"
pretty="true"
rooturl="${rootUrl}">
<fileset dir="${osgi.dist.plugins}" includes="*.jar"/>
</repoindex>
<bindex name="Ceylon SDK Bundles - Old OBR format"
quiet="true"
repositoryFile="${osgi.dist}/repository.xml"
root="${osgi.dist}">
<fileset dir="${osgi.dist.plugins}" includes="*.jar"/>
</bindex>
<ant target="generateFeatures" inheritall="true">
<property name="feature.id" value="ceylon.sdk"/>
<property name="feature.version" value="${sdk.version}"/>
<property name="xslFile" value="${osgi.karaf}/generateKarafSDKFeature.xsl"/>
<property name="feature.dir" value="${osgi.dist}"/>
<property name="featureFile" value="${osgi.dist}/karaf-features.xml"/>
</ant>
</target>
<!-- Rule to setup a plugins directory with required bundles -->
<target name="osgi-p2-quick" depends="osgi-quick,ceylondefs">
<makeurl property="destinationRepository" file="${osgi.dist}"/>
<makeurl property="categoryDefinition" file="${osgi.p2}/category.xml"/>
<mkdir dir="${osgi.build}"/>
<touch file="${osgi.build}/bundles.info"/>
<makeurl property="bundlesInfoUrl" file="${osgi.build}/bundles.info"/>
<ceylon-p2 executable="${ceylon.executable}"
offline="true"
verbose="${ceylon.verbosity}"
nodefaultrepositories="true"
out="${osgi.dist}"
repositoryName="Ceylon SDK Bundles"
categoryPrefix="ceylon.sdk"
categories="${osgi.p2}/category.xml"
fork="true">
<moduleset refid="modules.sdk.jvm"/>
<rep url="${basedir}/modules"/>
<rep url="${user.home}/.ceylon/cache"/>
</ceylon-p2>
<!--
<exec dir="${basedir}" executable="eclipse" failonerror="true">
<arg value="-noSplash"/>
<arg value="-clean"/>
<arg value="-console"/>
<arg value="-consolelog"/>
<arg value="- -launcher.suppressErrors"/>
<arg value="-application"/>
<arg value="org.eclipse.equinox.p2.publisher.FeaturesAndBundlesPublisher"/>
<arg value="-metadataRepositoryName"/>
<arg value="Ceylon SDK Bundles"/>
<arg value="-metadataRepository"/>
<arg value="${destinationRepository}"/>
<arg value="-artifactRepositoryName"/>
<arg value="Ceylon SDK Bundles"/>
<arg value="-artifactRepository"/>
<arg value="${destinationRepository}"/>
<arg value="-source"/>
<arg file="${osgi.dist}"/>
<arg value="-publishArtifacts"/>
<arg value="-append"/>
<arg value="-vmargs"/>
<arg value="-Dorg.eclipse.equinox.simpleconfigurator.configUrl=${bundlesInfoUrl}"/>
<arg value="-Dosgi.bundles=${bundlesToStart}"/>
</exec>
<exec dir="${basedir}" executable="eclipse">
<arg value="-noSplash"/>
<arg value="-clean"/>
<arg value="-console"/>
<arg value="-consolelog"/>
<arg value="- -launcher.suppressErrors"/>
<arg value="-application"/>
<arg value="org.eclipse.equinox.p2.publisher.CategoryPublisher"/>
<arg value="-metadataRepository"/>
<arg value="${destinationRepository}"/>
<arg value="-categoryDefinition"/>
<arg value="${categoryDefinition}"/>
<arg value="-categoryQualifier"/>
<arg value="ceylon.sdk"/>
<arg value="-vmargs"/>
<arg value="-Dorg.eclipse.equinox.simpleconfigurator.configUrl=${bundlesInfoUrl}"/>
<arg value="-Dosgi.bundles=${bundlesToStart}"/>
</exec>
-->
</target>
<target name="osgi" depends="compile-jvm,osgi-quick"/>
<target name="osgi-p2" depends="compile-jvm,osgi-p2-quick"/>
<target name="ide" depends="osgi-p2"/>
<target name="ide-quick" depends="osgi-p2-quick">
<foreach target="updateIdeProxyProject" param="archivePath">
<path>
</path>
</foreach>
</target>
<target name="bundle-proxy">
<basename file="${archivePath}" property="archiveFileName"/>
<property name="proxy-project" value="${eclipse.project.path}/required-bundle-proxies/${archiveFileName}"/>
<mkdir dir="${proxy-project}"/>
<delete failonerror="false" dir="${proxy-project}/META-INF"/>
<copy toDir="${proxy-project}" overwrite="true">
<zipfileset src="${archivePath}" includes="META-INF/**"/>
<fileset file="${archivePath}"/>
</copy>
<manifest file="${proxy-project}/META-INF/MANIFEST.MF" mode="update">
<attribute name="Bundle-Classpath" value="${archiveFileName}"/>
</manifest>
<echo file="${proxy-project}/.project"><![CDATA[<projectDescription>
<name>${archiveFileName}</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<linkedResources>
<link>
<name>project</name>
<type>2</type>
<locationURI>PARENT-3-PROJECT_LOC/ceylon-sdk</locationURI>
</link>
</linkedResources>
</projectDescription>]]></echo>
<echo file="${proxy-project}/.classpath"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry exported="true" kind="lib" path="${archiveFileName}" sourcepath="project"/>
<classpathentry kind="output" path="bin"/>
</classpath>]]></echo>
<echo file="${proxy-project}/.gitignore"><![CDATA[/META-INF
/${archiveFileName}
/.classpath
/.project
/.gitignore
/bin/]]></echo>
</target>
<target name="updateIdeProxyProject">
<antcall target="bundle-proxy">
<param name="archivePath" value="${archivePath}"/>
</antcall>
</target>
</project>