summaryrefslogtreecommitdiff
path: root/java/module.xml
blob: 42385e3f53553f15f8bacb3d803477833a2688d4 (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
<!--
 -
 - 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="module">

  <import file="common.xml"/>

  <map property="module" value="${basedir}" split="${path.separator}">
    <globmapper from="${project.root}${file.separator}*" to="*"/>
  </map>

  <echo message="Running ant for module : ${module}"/>

  <property file="${project.root}/build.deps"/>

  <property name="module.build"        location="${build}/${module}"/>
  <property name="module.classes"      location="${module.build}/classes"/>
  <property name="module.precompiled"  location="${module.build}/src"/>
  <property name="module.api"          location="${module.build}/api"/>
  <property name="module.test.classes" location="${module.build}/test/classes"/>
  <property name="module.results"      location="${build.results}/${module}"/>
  <property name="module.failed"       location="${module.results}/FAILED"/>
  <property name="module.src"          location="src/main/java"/>
  <property name="module.test.src"     location="src/test/java"/>
  <property name="module.bin"          location="bin"/>
  <property name="module.etc"          location="etc"/>

  <available property="module.test.src.exists" file="${module.test.src}"/>
  <available property="module.etc.exists" file="${module.etc}"/>
  <available property="module.bin.exists" file="${module.bin}"/>

  <map property="module.name" value="${module}">
    <filtermapper>
      <replacestring from="${file.separator}" to="-"/>
    </filtermapper>
  </map>

  <indirect name="module.libs"         variable="${module.name}.libs"/>
  <indirect name="module.test.libs"    variable="${module.name}.test.libs"/>

  <path id="module.libs">
    <filelist dir="${project.root}" files="${module.libs}"/>
  </path>

  <path id="module.test.libs">
    <filelist dir="${project.root}" files="${module.test.libs}"/>
  </path>

  <path id="module.src.path">
    <pathelement location="${module.src}"/>
    <pathelement location="${module.precompiled}"/>
  </path>

  <condition property="module.jar"
             value="${build.plugins}/${project.name}-${module.name}-${project.version}.jar"
             else="${build.lib}/${project.name}-${module.name}-${project.version}.jar">
    <and>
      <isset property="module.plugin"/>
      <istrue value="${module.plugin}"/>
    </and>
  </condition>

  <property name="module.test.jar"
            location="${build.lib}/${project.name}-${module.name}-tests-${project.version}.jar"/>

  <!-- module.depends and module.test.depends are supplied by the importing file -->
  <property name="module.depends"       value=""/>
  <property name="module.test.depends"  value=""/>
  <property name="module.test.excludes" value=""/>

  <map property="module.depends.path" value="${module.depends}" join="${path.separator}">
    <globmapper from="*" to="${build}/*/classes"/>
  </map>

  <map property="module.test.depends.path" value="${module.test.depends}" join="${path.separator}">
    <globmapper from="*" to="${build}/*/classes"/>
  </map>

  <path id="module.class.path">
    <pathelement location="${module.classes}"/>
    <pathelement path="${module.depends.path}"/>
    <path refid="module.libs"/>
  </path>

  <path id="module.test.path">
    <pathelement path="${module.test.classes}"/>
    <path refid="module.class.path"/>
    <pathelement path="${module.test.depends.path}"/>
    <path refid="module.test.libs"/>
  </path>

  <property name="javac.deprecation" value="off"/>

  <target name="debug">
    <echo-prop name="basedir"/>
    <echo-prop name="project.root"/>
    <echo-prop name="module"/>
    <echo-prop name="module.libs"/>
    <echo-prop name="module.test.libs"/>
    <echo-prop name="module.name"/>
    <echo-prop name="module.jar"/>
    <echo-prop name="module.depends"/>
    <echo-prop name="module.depends.path"/>
    <echo-prop name="module.test.depends"/>
    <echo-prop name="module.test.depends.path"/>
    <echo-path refid="module.src.path"/>
    <echo-path refid="module.class.path"/>
    <echo-path refid="module.test.path"/>
  </target>

  <target name="prepare">
    <mkdir dir="${build.bin}"/>
    <mkdir dir="${build.etc}"/>
    <mkdir dir="${build.lib}"/>
    <mkdir dir="${build.results}"/>
    <mkdir dir="${build.data}"/>
    <mkdir dir="${build.plugins}"/>
    <mkdir dir="${module.classes}"/>
    <mkdir dir="${module.precompiled}"/>
    <mkdir dir="${module.api}"/>
    <mkdir dir="${module.test.classes}"/>
    <mkdir dir="${module.results}"/>
  </target>

  <target name="precompile"/>

  <target name="compile" depends="prepare,precompile" description="compile sources">
    <javac source="${java.source}" target="${java.target}"
           destdir="${module.classes}" debug="on"
           deprecation="${javac.deprecation}">
      <src refid="module.src.path"/>
      <classpath refid="module.class.path"/>
    </javac>

    <!-- copy any non java src files into the build tree, e.g. log4j.properties -->
    <copy todir="${module.classes}" verbose="true">
      <fileset dir="${module.src}">
        <exclude name="**/*.java"/>
        <exclude name="**/package.html"/>
      </fileset>
    </copy>
  </target>

  <target name="precompile-tests" if="module.test.src.exists"/>

  <target name="compile-tests" depends="compile,precompile-tests" if="module.test.src.exists"
          description="compilte unit tests">
    <javac target="${java.target}" source="${java.source}"
           destdir="${module.test.classes}" debug="on"
           deprecation="${javac.deprecation}"
           srcdir="${module.test.src}">
      <classpath refid="module.test.path"/>
    </javac>

    <!-- copy any non java src files into the build tree, e.g. log4j.properties -->
    <copy todir="${module.test.classes}" verbose="true">
      <fileset dir="${module.test.src}">
        <exclude name="**/*.java"/>
        <exclude name="**/package.html"/>
      </fileset>
    </copy>
  </target>

  <property name="java.naming.factory.initial" value="org.apache.qpid.jndi.PropertiesFileInitialContextFactory"/>

  <condition property="config" value="${profile}.testprofile" else="default.testprofile">
    <and>
      <isset property="profile"/>
      <available file="${project.root}/${profile}.testprofile" type="file"/>
    </and>
  </condition>


  <property file="${project.root}/${config}"/>

  <condition property="dontruntest" value="dontruntest" else="runtest">
         <contains substring="${module.name}" string="${exclude.modules}" />
  </condition>

  <target name="test" depends="build,compile-tests" if="module.test.src.exists"
         unless="${dontruntest}" description="execute unit tests">

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

    <junit fork="${test.fork}" maxmemory="${test.mem}" reloading="no"
           haltonfailure="${haltonfailure}" haltonerror="${haltonerror}"
           failureproperty="test.failures" printsummary="on" timeout="600000" >

      <sysproperty key="amqj.logging.level" value="${amqj.logging.level}"/>
      <sysproperty key="root.logging.level" value="${root.logging.level}"/>
      <sysproperty key="log4j.configuration" value="${log4j.configuration}"/>
      <sysproperty key="java.naming.factory.initial" value="${java.naming.factory.initial}"/>
      <sysproperty key="java.naming.provider.url" value="${java.naming.provider.url}"/>
      <sysproperty key="broker" value="${broker}"/>
      <sysproperty key="broker.clean" value="${broker.clean}"/>
      <sysproperty key="broker.version" value="${broker.version}"/>
      <sysproperty key="broker.ready" value="${broker.ready}" />
      <sysproperty key="test.excludes" value="${test.excludes}"/>
      <sysproperty key="test.excludesfile" value="${test.excludesfile}"/>
      <sysproperty key="max_prefetch" value ="${max_prefetch}"/>
      <sysproperty key="example.plugin.target" value="${project.root}/build/lib/plugins"/>
      <sysproperty key="QPID_EXAMPLE_HOME" value="${project.root}/broker"/>
      <sysproperty key="QPID_HOME" value="${project.root}/broker"/>

      <formatter type="plain"/>
      <formatter type="xml"/>

      <classpath refid="module.test.path"/>

      <batchtest fork="${test.fork}" todir="${module.results}">
        <fileset dir="${module.test.src}" excludes="${module.test.excludes}">
          <include name="**/${test}.java"/>
        </fileset>
      </batchtest>
    </junit>

    <antcall target="touch-failed"/>

    <condition property="failed">
      <and>
        <isfalse value="${test.failures.ignore}"/>
        <available file="${module.failed}"/>
      </and>
    </condition>

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

  </target>

  <target name="touch-failed" if="test.failures">
    <touch file="${module.failed}"/>
    <touch file="${build.failed}"/>
  </target>

  <target name="copy-bin" if="module.bin.exists" description="copy bin directory if it exists to build tree">
    <copy todir="${build.bin}" failonerror="false">
      <fileset dir="${module.bin}"/>
    </copy>
    <chmod dir="${build.bin}" perm="ugo+rx" includes="**/*"/>
  </target>

  <target name="copy-etc" if="module.etc.exists" description="copy etc directory if it exists to build tree">
    <copy todir="${build.etc}" failonerror="false">
      <fileset dir="${module.etc}"/>
    </copy>
  </target>

  <target name="build" depends="jar,jar-tests,libs,copy-bin,copy-etc" description="compile and copy resources into build tree"/>
  <target name="jar.manifest" depends="compile" if="module.manifest">
    <jar destfile="${module.jar}" basedir="${module.classes}" manifest="${module.manifest}"/>
  </target>

  <target name="jar.nomanifest" depends="compile" unless="module.manifest">
    <jar destfile="${module.jar}" basedir="${module.classes}"/>
  </target>

  <target name="jar" depends="jar.manifest,jar.nomanifest" description="create jar"/>

  <target name="jar-tests" depends="compile-tests" description="create unit test jar">
    <jar destfile="${module.test.jar}" basedir="${module.test.classes}"/>
  </target>

  <target name="libs" description="copy dependencies into build tree">
    <copy todir="${build.lib}" failonerror="false" flatten="true">
      <fileset dir="${basedir}${file.separator}.." includes="${module.libs}"/>
    </copy>
  </target>

  <uptodate property="doc.done" targetfile="${module.api}/index.html">
    <srcfiles dir="${module.src}" includes="**/*.java"/>
  </uptodate>

  <target name="doc" depends="prepare" unless="doc.done" description="generate api-doc">
    <javadoc destdir="${module.api}" sourcepathref="module.src.path"
             classpathref="module.class.path" packagenames="*"/>
  </target>

  <target name="clean" description="remove build artifacts">
    <delete dir="${module.build}"/>
    <delete dir="${module.results}"/>
  </target>

</project>