Skip to main content
summaryrefslogtreecommitdiffstats
blob: 6bccd4840b6577ea57c6d6ca1dedd947b4c9678a (plain) (blame)
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
<?xml version="1.0"?>
<!--
	Copyright (c) 2011-2016 Eike Stepper (Berlin, Germany) and others.
	All rights reserved. This program and the accompanying materials
	are made available under the terms of the Eclipse Public License v1.0
	which accompanies this distribution, and is available at
	http://www.eclipse.org/legal/epl-v10.html

	Contributors:
	  Eike Stepper - initial API and implementation
-->
<project name="CDO" default="all">

  <property file="local.properties" />
  <property file="build.properties" />
  <property environment="env" />

  <taskdef resource="net/sf/antcontrib/antlib.xml">
    <classpath>
      <pathelement location="${ant.contrib}" />
    </classpath>
  </taskdef>

  <!-- ========= -->
  <!-- Clean Dir -->
  <!-- ========= -->

  <macrodef name="cleandir">
    <attribute name="dir" />
    <attribute name="mkdir" default="true" />
    <sequential>
      <delete includeemptydirs="true" failonerror="false" verbose="false">
        <fileset dir="@{dir}" defaultexcludes="false">
          <include name="**" />
        </fileset>
      </delete>
      <if>
        <equals arg1="@{mkdir}" arg2="true" />
        <then>
          <mkdir dir="@{dir}" />
        </then>
      </if>
    </sequential>
  </macrodef>

  <!-- ============= -->
  <!-- Generate Site -->
  <!-- ============= -->

  <macrodef name="generate.site">
    <attribute name="site" />
    <attribute name="todir" default="${build.root}" />
    <sequential>
      <echo message="Generating site" />

      <!-- Clean -->
      <delete includeemptydirs="true" failonerror="false">
        <fileset dir="@{todir}" defaultexcludes="false">
          <include name="target/**" />
          <include name="category.xml" />
          <include name="binary/**" />
          <include name="features/**" />
          <include name="plugins/**" />
          <include name="artifacts.jar" />
          <include name="content.jar" />
        </fileset>
      </delete>

      <!-- Copy site contents -->
      <copy todir="@{todir}" overwrite="true" includeemptydirs="true" preservelastmodified="true" failonerror="true">
        <fileset dir="@{site}">
          <include name="**" />
        </fileset>
      </copy>
    </sequential>
  </macrodef>

  <!-- ============= -->
  <!-- Generate Help -->
  <!-- ============= -->

  <macrodef name="generate.help">
    <sequential>
      <echo message="" />
      <echo message="Generating help center" />
      <cleandir dir="${build.root}/help" mkdir="true" />
      <copy todir="${build.root}/help">
        <fileset dir="${releng.help}/html">
          <include name="**" />
        </fileset>
        <fileset dir="${releng.help}">
          <include name="docs.txt" />
        </fileset>
      </copy>
    </sequential>
  </macrodef>

  <!-- ============== -->
  <!-- Generate Index -->
  <!-- ============== -->

  <macrodef name="generate.index">
    <sequential>
      <echo message="" />
      <echo message="Generating repository index" />
      <unzip src="${build.root}/content.jar" dest="${build.root}" />
      <property name="content.xml" location="${build.root}/content.xml" />
      <xslt style="xsl/content2html.xsl" in="${content.xml}" out="${build.root}/index.html" />
      <xslt style="xsl/content2xml.xsl" in="${content.xml}" out="${build.root}/index.xml" />
      <delete file="${content.xml}" />
    </sequential>
  </macrodef>

  <!-- =================== -->
  <!-- Generate Booksmarks -->
  <!-- =================== -->

  <macrodef name="generate.bookmarks">
    <sequential>
      <echo message="" />
      <echo message="Generating dependency bookmarks" />
      <property name="bookmarks.tmp" location="${build.root}/bookmarks.tmp" />
      <xslt style="xsl/bom2bookmarks.xsl" in="${build.root}/bom.xml" out="${bookmarks.tmp}" />
      <replace file="${bookmarks.tmp}" token="http://dev.eclipse.org" value="file://to-be-removed" />
      <replace file="${bookmarks.tmp}" token="file:/home/data/httpd/" value="http://" />
      <property name="bookmarks.xml" location="${build.root}/bookmarks.xml" />
      <concat destfile="${bookmarks.xml}">
        <header filtering="false">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;bookmarks&gt;
</header>
        <union>
          <sort>
            <tokens>
              <file file="${bookmarks.tmp}" />
              <linetokenizer includedelims="true" />
            </tokens>
          </sort>
        </union>
        <filterchain>
          <linecontains>
            <contains value="http://" />
          </linecontains>
        </filterchain>
        <footer filtering="false">&lt;/bookmarks&gt;
			</footer>
      </concat>
      <delete file="${bookmarks.tmp}" />
    </sequential>
  </macrodef>

  <!-- ================ -->
  <!-- Generate Dropins -->
  <!-- ================ -->

  <macrodef name="generate.dropins">
    <sequential>
      <echo message="" />
      <echo message="Generating dropin archives" />
    	
      <mkdir dir="${zips}" />
      <zip destfile="${zips}/emf-cdo-${build.qualifier}-Dropins.zip">
        <fileset dir="${releng.site}/target/repository">
          <include name="features/*.jar" />
          <include name="plugins/*.jar" />
        </fileset>
      </zip>
      <echo message=" for use with a &lt;a href=&quot;http://help.eclipse.org/indigo/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/misc/p2_dropins_format.html&quot;&gt;dropins&lt;/a&gt; folder."
            file="${zips}/emf-cdo-${build.qualifier}-Dropins.properties" />
    </sequential>
  </macrodef>

  <!-- ============ -->
  <!-- Generate API -->
  <!-- ============ 

  <macrodef name="generate.apireports">
    <sequential>
      <echo message="" />
      <echo message="Generating API reports" />
      <buckminster command="perform">
        <cmdargs>
          <arg value="-D" />
          <arg value="api.report=${build.root}/api.xml" />
          <arg value="org.eclipse.emf.cdo.releng#generate.apireports" />
        </cmdargs>
      </buckminster>
      <echo message="Converting to HTML" />
      <java classname="org.eclipse.emf.cdo.releng.Api2Html">
        <classpath>
          <pathelement location="${releng}/bin/" />
          <pathelement location="/opt/public/common/apache-ant-1.7.1/lib/xercesImpl.jar" />
        </classpath>
        <arg value="${build.root}" />
        <arg value="${build.qualifier}" />
        <arg value="${plugins.dir}" />
        <arg value="${tp}/plugins" />
      </java>
      <copy file="${releng}/hudson/api.css" todir="${build.root}" overwrite="true" />
    </sequential>
  </macrodef>
  -->

  <!-- ==================== -->
  <!-- Check Commit Message -->
  <!-- ==================== -->

  <target name="check.commit.msg" if="GERRIT_CHANGE_SUBJECT">
  	<condition property="commit.msg.ok" value="true">
  		<matches pattern="^\[[1-9][0-9]*\] .*$" string="${GERRIT_CHANGE_SUBJECT}"/>
  	</condition>
  	<fail message="The commit message is not of the form '[bug-id] bug-subject'." unless="commit.msg.ok"/>
  </target>

  <!-- =========== -->
  <!-- Init Hudson -->
  <!-- =========== -->

  <target name="init.hudson" if="env.HUDSON_URL" depends="check.commit.msg">
    <property name="build.root" value="${env.WORKSPACE}" />
    <property name="build.location" value="hudson" />
    <property name="build.timestamp" value="${env.BUILD_ID}" />
    <property name="loglevel" value="${env.LOG_LEVEL}" />
    <property name="skip.test" value="${env.SKIP_TEST}" />

    <!-- build.trigger -->
    <if>
      <not>
        <isset property="build.trigger" />
      </not>
      <then>
        <xmlproperty keeproot="false">
          <url url="${env.BUILD_URL}/api/xml?tree=actions[causes[shortDescription]]" />
        </xmlproperty>
        <loadresource property="build.trigger">
          <propertyresource name="action.cause.shortDescription" />
          <filterchain>
            <replaceregex pattern="^Triggered by " replace="" />
            <replaceregex pattern="^Gerrit: .*" replace="gerrit" />
            <replaceregex pattern="^Started by " replace="" />
            <replaceregex pattern="^Gestartet durch " replace="" />
            <replaceregex pattern="Benutzer" replace="user" />
          </filterchain>
        </loadresource>
      </then>
    </if>

    <!-- build.type -->
    <if>
      <equals arg1="${env.BUILD_TYPE}" arg2="&lt;default&gt;" />
      <then>
        <condition property="build.type" value="${weekly}" else="N">
          <equals arg1="${build.trigger}" arg2="timer" />
        </condition>
      </then>
      <else>
        <property name="build.type" value="${env.BUILD_TYPE}" />
      </else>
    </if>

    <!-- site.signing -->
    <condition property="site.signing" value="true" else="false">
      <and>
        <not>
          <equals arg1="${build.type}" arg2="N" />
        </not>
      	<or>
      	  <equals arg1="${env.HUDSON_URL}" arg2="https://hudson.eclipse.org/cdo/" />
      	  <equals arg1="${env.HUDSON_URL}" arg2="https://hudson.eclipse.org/hudson/" />
      	</or>
      </and>
    </condition>

    <!-- eclipse.staging.area -->
    <if>
      <equals arg1="${site.signing}" arg2="true" />
      <then>
        <property name="eclipse.staging.area" value="/shared/download-staging.priv/modeling/emf/cdo/${env.JOB_NAME}" />
      </then>
    </if>
  </target>

  <!-- ========== -->
  <!-- Init Local -->
  <!-- ========== -->

  <target name="init.local" unless="env.HUDSON_URL">
    <fail unless="build.root" message="The property 'build.root' must be defined in a 'local.properties' file" />

    <property name="build.location" value="local" />
    <property name="build.trigger" value="manual" />
    <property name="site.signing" value="false" />
    <property name="git.clone" value="${build.root}/git" />

    <!-- build.timestamp -->
    <tstamp>
      <format property="build.timestamp" pattern="yyyy-MM-dd_HH-mm-ss" />
    </tstamp>

    <!-- git.clone -->
    <if>
      <and>
        <equals arg1="${keep.git}" arg2="true" />
        <available file="${git.clone}" type="dir" />
      </and>
      <then>
        <echo message="Keeping Git clone" />
      </then>
      <else>
        <echo message="Copying Git clone from ${original.git.dir}" />
        <cleandir dir="${git.clone}" />
        <copy todir="${git.clone}">
          <fileset dir="${original.git.dir}" defaultexcludes="false">
            <exclude name="**/*.class" />
          </fileset>
        </copy>
      </else>
    </if>
  </target>

  <!-- =============== -->
  <!-- Init Properties -->
  <!-- =============== -->

  <target name="init.properties" depends="init.hudson,init.local">
    <condition property="no.proxy" value="${env.no_proxy}, dev.eclipse.org" else="dev.eclipse.org">
      <isset property="env.no_proxy" />
    </condition>

    <property name="git.clone" location="${build.root}/git" />
    <property name="features.dir" location="${git.clone}/features" />
    <property name="plugins.dir" location="${git.clone}/plugins" />
    <property name="releng.dir" location="${git.clone}/releng" />
    <property name="releng" location="${releng.dir}/org.eclipse.emf.cdo.releng" />
    <property name="releng.help" location="${releng.dir}/org.eclipse.emf.cdo.releng.help" />
    <property name="releng.site" location="${releng.dir}/org.eclipse.emf.cdo.releng.site" />
    <property name="test.report" location="${build.root}/test-report.xml" />
    <property name="zips" location="${build.root}/zips" />

    <!-- build.qualifier -->
    <tempfile property="build.qualifier.tmp"
              destdir="${java.io.tmpdir}"
              prefix="build-qualifier-"
              suffix=".tmp"
              deleteonexit="true" />
    <echo message="build.qualifier.date=${build.timestamp}" file="${build.qualifier.tmp}" />
    <replaceregexp file="${build.qualifier.tmp}">
      <regexp pattern="([0-9]*)-([0-9]*)-([0-9]*)_([0-9]*)-([0-9]*)-([0-9]*)" />
      <substitution expression="\1\2\3-\4\5" />
    </replaceregexp >
    <property file="${build.qualifier.tmp}" />
  	<property name="build.qualifier" value="${build.type}${build.qualifier.date}" />
  	<property name="build.version" value="v${build.qualifier.date}" />

    <!-- build-info.xml -->
    <echoxml file="${build.root}/build-info.xml">
      <build stream="${stream}"
             branch="${branch}"
             train="${train}"
             eclipse="${eclipse}"
             emf="${emf}"
             type="${build.type}"
             timestamp="${build.timestamp}"
             qualifier="${build.qualifier}"
             trigger="${build.trigger}"
             hudson="${env.HUDSON_URL}"
             revision="${env.GIT_COMMIT}"
             job="${env.JOB_NAME}"
             number="${env.BUILD_NUMBER}" />
    </echoxml>

    <!-- Echo -->
    <echo message="stream = ${stream}" />
    <echo message="branch = ${branch}" />
    <echo message="train = ${train}" />
    <echo message="build.type = ${build.type}" />
    <echo message="build.location = ${build.location}" />
    <echo message="build.trigger = ${build.trigger}" />
    <echo message="build.timestamp = ${build.timestamp}" />
    <echo message="build.qualifier = ${build.qualifier}" />
    <echo message="site.signing = ${site.signing}" />
  </target>

  <!-- ===== -->
  <!-- Clean -->
  <!-- ===== -->

  <target name="clean" depends="init.properties" description="Imports projects and binaries">
    <if>
      <not>
        <equals arg1="${skip.clean}" arg2="true" />
      </not>
      <then>
        <!-- Cleanup build.root -->
        <delete failonerror="false" includeemptydirs="true">
          <fileset dir="${build.root}" defaultexcludes="false">
            <include name="zips/**" />
            <include name="*.css" />
            <include name="*.html" />
            <include name="*.xml" />
            <include name="*.log" />
            <include name="*.txt" />
            <exclude name="build-info.xml" />
          </fileset>
        </delete>

        <!-- Cleanup doc plugins -->
        <delete failonerror="false" includeemptydirs="true">
          <fileset dir="${plugins.dir}">
            <include name="*.doc/bin/**" />
            <include name="*.help/bin/**" />
          </fileset>
        </delete>

        <!-- Initialize test report -->
        <copy file="${releng}/hudson/test-report-empty.xml" tofile="${test.report}" overwrite="true" verbose="true" />
      </then>
    </if>
  </target>

  <!-- ==== -->
  <!-- Test -->
  <!-- ==== -->

  <target name="test" depends="clean" description="Runs the tests">
    <if>
      <equals arg1="${skip.test}" arg2="true" />
      <then>
        <echo message="Skipping test" />
      </then>
      <else>
        <condition property="launch.config"
                   value="org.eclipse.emf.cdo.tests.all/CDO GerritTests"
                   else="org.eclipse.emf.cdo.tests.db/CDO AllTests (H2 ALL)">
          <isset property="GERRIT_CHANGE_ID" />
        </condition>
        <echo message="Running ${launch.config}" />
      </else>
    </if>
  </target>

  <!-- ======== -->
  <!-- Generate -->
  <!-- ======== -->

  <target name="generate" depends="clean" description="Generates the site and other artifacts">
    <if>
      <or>
        <isset property="GERRIT_CHANGE_ID" />
        <equals arg1="${skip.generate}" arg2="true" />
      </or>
      <then>
        <echo message="Skipping generate" />
      </then>
      <else>
        <if>
          <not>
            <equals arg1="${skip.generate.site}" arg2="true" />
          </not>
          <then>
            <generate.site site="${releng.site}/target/repository" />
          </then>
        </if>

        <if>
          <not>
            <equals arg1="${skip.generate.help}" arg2="true" />
          </not>
          <then>
            <generate.help />
          </then>
        </if>

        <if>
          <not>
            <equals arg1="${skip.generate.index}" arg2="true" />
          </not>
          <then>
            <generate.index />
          </then>
        </if>

        <if>
          <not>
            <equals arg1="${skip.generate.bookmarks}" arg2="true" />
          </not>
          <then>
            <generate.bookmarks />
          </then>
        </if>

        <if>
          <not>
            <equals arg1="${skip.generate.dropins}" arg2="true" />
          </not>
          <then>
            <generate.dropins />
          </then>
        </if>

      	<!--
        <if>
          <not>
            <equals arg1="${skip.generate.apireports}" arg2="true" />
          </not>
          <then>
            <generate.apireports />
          </then>
        </if>
        -->
      </else>
    </if>
  </target>

  <!-- === -->
  <!-- All -->
  <!-- === -->

  <target name="all" depends="test,generate" description="Runs the tests and generates the site and other artifacts" />

</project>

Back to the top