summaryrefslogtreecommitdiff
path: root/qpid/java/build.xml
blob: e761677f6df544ceedc4590c9d159f4f5b8e839b (plain)
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
<!--
 -
 - Licensed to the Apache Software Foundation (ASF) under one
 - or more contributor license agreements.  See the NOTICE file
 - distributed with this work for additional information
 - regarding copyright ownership.  The ASF licenses this file
 - to you 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="AMQ Java" xmlns:ivy="antlib:org.apache.ivy.ant" default="build">

  <import file="common.xml"/>

  <property name="optional" value="false"/>
  <property name="modules.opt.default" value="bdbstore bdbstore/jmx bdbstore/systests perftests/visualisation-jfc"/>
  <condition property="modules.opt" value="" else="${modules.opt.default}">
    <isfalse value="${optional}"/>
  </condition>
  <condition property="broker-plugins-exclude" value="jdbc-provider-bone" else="">
    <isfalse value="${optional}"/>
  </condition>

  <findSubProjects name="broker-plugins" dir="broker-plugins" excludes="${broker-plugins-exclude}"/>
  <findSubProjects name="client-plugins" dir="client-plugins"/>

  <property name="modules.core"       value="qpid-test-utils common management/common amqp-1-0-common broker-core broker client amqp-1-0-client amqp-1-0-client-jms tools"/>
  <property name="modules.examples"   value="client/example management/example amqp-1-0-client/example amqp-1-0-client-jms/example"/>
  <property name="modules.tests"      value="systests perftests"/>
  <property name="modules.plugin"     value="${broker-plugins} ${client-plugins}"/>
  <property name="modules.jca"        value="jca"/>
  <property name="modules"            value="${modules.core} ${modules.examples}
   ${modules.jca} ${modules.plugin} ${modules.tests} ${modules.opt}"/>

  <property name="qpid.jar"           location="${build.lib}/qpid-all.jar"/>
  <basename property="qpid.jar.name"  file="${qpid.jar}"/>

  <property name="resources"     value="${project.root}/resources"/>

  <!-- Modules for which coverage will be created by the cover-test target -->
  <property name="coverage.modules" value="${modules}"/>

  <map property="release.excludes" value="${modules}">
    <globmapper from="*" to="*/\*\*"/>
  </map>


  <property name="release.zip"          location="${release}/${project.namever}-java.zip"/>
  <property name="release.tar"          location="${release}/${project.namever}-java.tar"/>
  <property name="release.tgz"          location="${release}/${project.namever}-java.tar.gz"/>
  <property name="release.bz2"          location="${release}/${project.namever}-java.tar.bz2"/>

  <macrodef name="iterate">
    <attribute name="target"/>
    <attribute name="modules" default="${modules}"/>
    <element name="elements" implicit="true" optional="true"/>
    <sequential>
      <subant target="@{target}" antfile="build.xml">
        <filelist dir="." files="@{modules}"/>
        <elements/>
      </subant>
    </sequential>
  </macrodef>

  <target name="pom" description="generate poms">
    <iterate target="pom"/>
  </target>

  <target name="release-mvn" description="Install the artifacts into the local repository">
    <iterate target="release-mvn"/>
  </target>

  <target name="deploy-snapshot" description="deploy snapshot artifacts to nexus">
    <iterate target="deploy-snapshot"/>
  </target>

  <target name="compile" description="compile sources">
    <iterate target="compile"/>
  </target>

  <target name="compile-tests" description="compile unit tests">
    <iterate target="compile-tests"/>
  </target>

  <target name="test" description="execute tests" depends="manifest">

    <delete file="${build.failed}"/>

    <iterate target="test">
      <property name="test.failures.ignore" value="true"/>
    </iterate>

    <condition property="failed">
      <available file="${build.failed}"/>
    </condition>

    <fail if="failed" message="TEST SUITE FAILED"/>

  </target>

  <target name="report-module" description="generate junitreport for modules">
    <iterate target="report-module"/>
  </target>

  <target name="jar" description="create module jars">
    <iterate target="jar"/>
  </target>

  <target name="jar-tests" description="create unit test jars">
    <iterate target="jar-tests"/>
  </target>

  <target name="libs" description="copy dependencies into build tree">
    <iterate target="libs"/>
  </target>

  <target name="doc" description="generate api-doc">
    <iterate target="doc"/>
  </target>

  <target name="test-doc" description="generate api-doc">
    <iterate target="test-doc"/>
  </target>

  <target name="bundle" description="create OSGi bundles">
    <iterate target="bundle"/>
  </target>

  <target name="release-bin" description="build a binary release artifact" depends="build,bundle">
      <iterate  target="release-bin"/>
  </target>


  <target name="check-manifest">
    <uptodate property="manifest.done" targetfile="${qpid.jar}">
      <srcfiles dir="${build.lib}" includes="**/*.jar" excludes="**/${qpid.jar.name}"/>
    </uptodate>
  </target>

  <target name="manifest" depends="check-manifest" unless="manifest.done">
    <path id="class.path">
      <fileset dir="${build.lib}" >
        <include name="*.jar"/>
        <exclude name="${qpid.jar.name}"/>
      </fileset>
    </path>
    <pathconvert property="qpid.jar.classpath" pathsep=" " dirsep="/">
      <path refid="class.path"/>
      <globmapper from="${build.lib}${file.separator}*" to="*"/>
    </pathconvert>

    <jar destfile="${qpid.jar}">
      <manifest>
        <attribute name="Class-Path" value="${qpid.jar.classpath}"/>
      </manifest>
      <metainf dir="${project.root}/resources/"/>
    </jar>

    <touch file="${qpid.jar}"/>
  </target>

  <target name="build" depends="retrieve-dependencies" description="build the project">
    <iterate target="build"/>
    <antcall target="manifest"/>
  </target>

  <target name="prepare">
    <mkdir dir="${release}"/>
  </target>

  <target name="zip" depends="build,prepare" description="build release archive">
    <zip destfile="${release.zip}">
      <zipfileset dir="${build}" prefix="${project.namever}" filemode="755">
        <include name="bin/*"/>
	<exclude name="bin/*.txt"/>
      </zipfileset>

      <zipfileset dir="${build}" prefix="${project.namever}" filemode="644">
        <include name="bin/*.txt"/>
      </zipfileset>

      <zipfileset dir="${build}" prefix="${project.namever}" excludes="${release.excludes}" filemode="644" dirmode="755">
        <exclude name="bin/**"/>
	<exclude name="scratch/**"/>
      </zipfileset>

      <zipfileset dir="${resources}" prefix="${project.namever}" filemode="644"/>
    </zip>
  </target>

  <target name="tar" depends="zip" description="build release archive">
    <tar destfile="${release.tar}" longfile="gnu" >
      <zipfileset src="${release.zip}"/>
    </tar>
  </target>

  <target name="gzip" depends="tar" description="build release archive">
    <gzip src="${release.tar}" destfile="${release.tgz}"/>
  </target>

  <target name="bzip2" depends="tar" description="build release archive">
    <bzip2 src="${release.tar}" destfile="${release.bz2}"/>
  </target>

  <target name="release" depends="zip,gzip" description="build all release archives except .bz2"/>

  <target name="release-all" depends="zip,gzip,bzip2" description="build all release archives"/>


  <target name="clean" description="remove build and release artifacts">
    <iterate target="clean"/>
    <delete dir="${build}"/>
    <delete dir="${release}"/>
    <delete dir="${tasks.classes}"/>
  </target>

  <target name="coverage-report" description="generate coverage report" depends="cobertura-init">
    <mkdir dir="${build.coverage.report}" />
    <mkdir dir="${build.coverage.src}" />

    <cobertura-merge datafile="${build.coverage.report}/cobertura.ser">
      <!-- merge all module coverage reports -->
      <fileset dir="${build}">
        <include name="**/*.ser"/>
      </fileset>
    </cobertura-merge>

    <!-- Copy all covered sources to single directory for cobertura report -->

    <foreach property="module" list="${coverage.modules}">

      <copy todir="${build.coverage.src}">
        <fileset dir="${module}/src/main/java" includes="**/*.java"/>
      </copy>

      <copy todir="${build.coverage.src}">
        <fileset dir="build/scratch/${module}/src" includes="**/*.java"/>
      </copy>
    </foreach>

    <cobertura-report format="xml"
                      destdir="${build.coverage.report}"
		      datafile="${build.coverage.report}/cobertura.ser">
      <fileset dir="${build.coverage.src}" includes="**/*.java" />
    </cobertura-report>

    <cobertura-report format="html"
                      destdir="${build.coverage.report}"
		      datafile="${build.coverage.report}/cobertura.ser">
      <fileset dir="${build.coverage.src}" includes="**/*.java" />
    </cobertura-report>
  </target>

  <target name="instrument" description="instrument for artifacts">
    <iterate target="instrument"/>
  </target>

  <target name="cover-test" description="run tests and generate coverage information" depends="build">
    <iterate target="cover-test" modules="${coverage.modules}"/>
  </target>

  <target name="test-interop" depends="build,compile-tests"
      description="run JMS examples against the corresponding c++ and python examples">
      <property name="qpid.src.home" location=".."/>
      <echo-prop name="qpid.src.home"/>
      <exec executable="/bin/sh" failonerror="true">
         <env key="QPID_SRC_HOME" value="${qpid.src.home}"/>
         <arg value="-c"/>
         <arg value="${project.root}/client/example/bin/verify_all"/>
      </exec>
  </target>

  <target name="testkit" depends="build,compile-tests">
    <jython path="${mllib.dir}">
      <args>
        <arg value="${mllib.dir}/qpid-python-test"/>
        <arg value="-m ${basedir}/testkit/testkit"/>
      </args>
    </jython>
  </target>

  <target name="findbugs" depends="build,findbugs-init">

    <mkdir dir="${build.findbugs}"/>

    <findbugs home="${findbugs.dir}"
              output="html"
              outputFile="${build.findbugs}/report.html"
              stylesheet="fancy-hist.xsl"
              jvmargs="-Xmx512m"
              projectName="Qpid">
      <!-- The classes for analysis -->
      <fileset dir="${build.lib}" includes="qpid*.jar" excludes="*test*.jar *-sources*.jar *example*.jar qpid-all.jar"/>

      <!--Additional classes, not for analysis -->
      <auxClassPath>
        <fileset dir="${basedir}/lib" includes="**/*.jar"/>
      </auxClassPath>

      <!-- Source, used for improved reporting -->
      <sourcePath>
        <fileset dir="${basedir}" includes="**/src/**/org/.." />
      </sourcePath>
    </findbugs>
  </target>

  <target name="eclipse" description="build eclipse project and classpath files">
    <iterate target="eclipse"/>
  </target>

  <!-- check the following properties which must be specified by the user-->
  <target name="check-upload-props-exist" description="check that the required properties have been set">
    <fail unless="nexus.user" message="You must supply the 'nexus.user' property"/>
    <fail unless="nexus.password" message="You must supply the 'nexus.password' property"/>
    <fail unless="maven.artifact.dir" message="You must supply the 'maven.artifact.dir' property"/>
  </target>

  <target name="perform-nexus-upload">
    <ivy:configure file="ivysettings.nexus.xml"/>
    <ivy:resolve file="ivy.nexus.xml"/>
    <ivy:deliver/>
    <ivy:publish publishivy="false" resolver="nexus"
             artifactspattern="${maven.artifact.dir}/[organisation]/[module]/[artifact]/[revision]/[artifact]-[revision](-[classifier]).[ext]"/>
  </target>

  <target name="upload" depends="load-ivy, check-upload-props-exist, perform-nexus-upload"/>

</project>