File: build.xml

package info (click to toggle)
libjibx1.2-java 1.2.6-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 26,260 kB
  • sloc: java: 75,013; xml: 14,068; makefile: 17
file content (317 lines) | stat: -rw-r--r-- 12,344 bytes parent folder | download | duplicates (5)
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
<?xml version="1.0"?>

<!-- ===================================================================

Ant build file for JiBX data binding schema to code starter example.

=================================================================== -->

<project basedir="." default="help">
  
  <!-- The following block is intended to set the jibx-home location. It first
   checks the relative location of the JiBX libraries when this starter example
   is run directly from the JiBX distribution, then (if that fails), looks for
   an environmental variable JIBX_HOME with the installation path. If you prefer
   to just set the path directly in this file, uncomment the following line and
   set the value to the appropriate directory, then delete the rest of the Ant
   commands down to the end of this block. -->
<!--  <property name="jibx-home" value="jibx-home-directory-path"/> -->
  <available file="../../lib/jibx-bind.jar" property="jibx-home" value="../.."/>
  <property environment="env"/>
  <condition property="jibx-home" value="${env.JIBX_HOME}">
    <and>
      <not>
        <isset property="jibx-home"/>
      </not>
      <available file="${env.JIBX_HOME}/lib"/>
    </and>
  </condition>
  <!-- End of jibx-home location setting block. -->
  
  <!-- make sure required jars are present -->
  <condition property="runtime-jars-found">
    <available file="${jibx-home}/lib/jibx-run.jar"/>
  </condition>
  <condition property="binding-jars-found">
    <and>
      <available file="${jibx-home}/lib/bcel.jar"/>
      <available file="${jibx-home}/lib/jibx-bind.jar"/>
      <available file="${jibx-home}/lib/jibx-run.jar"/>
    </and>
  </condition>
  <available property="extras-jar-found" file="${jibx-home}/lib/jibx-extras.jar"/>
  
  <!-- set classpath for compiling and running application with JiBX -->
  <path id="classpath">
    <pathelement location="."/>
    <fileset dir="${jibx-home}/lib" includes="*.jar"/>
    <pathelement location="bin"/>
  </path>
  
  <!-- make sure runtime jars are present -->
  <target name="check-runtime">
    <fail unless="jibx-home">JiBX home directory not found - define JIBX_HOME system property or set path directly in build.xml file.</fail>
    <fail unless="runtime-jars-found">Required JiBX runtime jar jibx-run.jar was not found in JiBX home lib directory (${jibx-home}/lib)</fail>
  </target>
  
  <!-- make sure extras jars are present -->
  <target name="check-extras" depends="check-runtime">
    <fail unless="extras-jar-found">Required JiBX extras jar jibx-extras.jar was not found in JiBX home lib directory (${jibx-home}/lib)</fail>
  </target>
  
  <!-- make sure binding jars are present -->
  <target name="check-binding" depends="check-runtime">
    <fail unless="binding-jars-found">Required JiBX binding jar jibx-bind.jar or bcel.jar was not found in JiBX home lib directory (${jibx-home}/lib)</fail>
  </target>
  
  <!-- make sure modular base jar is present -->
  <target name="check-base">
    <condition property="base-found">
      <available file="${basedir}/base.jar"/>
    </condition>
    <fail unless="base-found">Need to first run base generation and build (ant custgen3a buildbase).</fail>
  </target>
  
  <!-- binding task definition -->
  <taskdef name="bind" classname="org.jibx.binding.ant.CompileTask">
    <classpath>
      <fileset dir="${jibx-home}/lib" includes="*.jar"/>
    </classpath>
  </taskdef>
  
  <!-- clean compiled class files and generated code+binding -->
  <target name="clean-partial">
    <delete quiet="true" dir="${basedir}/bin"/>
    <delete quiet="true" dir="${basedir}/gen"/>
  </target>
  <target name="clean" depends="clean-partial">
    <delete quiet="true" file="${basedir}/base.jar"/>
  </target>
  
  <!-- generate using default settings -->
  <target name="codegen" depends="check-runtime,clean">
    
    <echo message="Running code generation from schema"/>
    <delete quiet="true" dir="${basedir}/gen"/>
    <java classname="org.jibx.schema.codegen.CodeGen" fork="yes"
        classpathref="classpath" failonerror="true">
      <arg value="-t"/>
      <arg value="${basedir}/gen/src"/>
      <arg value="otasubset/OTA_AirLowFareSearch*.xsd"/>
    </java>
    
  </target>
  
  <!-- generate using first customizations -->
  <target name="custgen1" depends="check-runtime,clean">
    
    <echo message="Running code generation from schema"/>
    <delete quiet="true" dir="${basedir}/gen"/>
    <java classname="org.jibx.schema.codegen.CodeGen" fork="yes"
        classpathref="classpath" failonerror="true">
      <arg value="-t"/>
      <arg value="${basedir}/gen/src"/>
      <arg value="-c"/>
      <arg value="${basedir}/custom1.xml"/>
      <arg value="otasubset/OTA_AirLowFareSearch*.xsd"/>
    </java>
    
  </target>
  
  <!-- generate using second customizations -->
  <target name="custgen2" depends="check-runtime,clean">
    
    <echo message="Running code generation from schema"/>
    <delete quiet="true" dir="${basedir}/gen"/>
    <java classname="org.jibx.schema.codegen.CodeGen" fork="yes"
        classpathref="classpath" failonerror="true">
      <arg value="-t"/>
      <arg value="${basedir}/gen/src"/>
      <arg value="-c"/>
      <arg value="${basedir}/custom2.xml"/>
      <arg value="otasubset/OTA_AirLowFareSearch*.xsd"/>
    </java>
    
  </target>
  
  <!-- modular generation of common types -->
  <target name="custgen3a" depends="check-runtime,clean">
    
    <echo message="Running base code generation from schema"/>
    <delete quiet="true" dir="${basedir}/gen"/>
    <java classname="org.jibx.schema.codegen.CodeGen" fork="yes"
        classpathref="classpath" failonerror="true">
      <arg value="-t"/>
      <arg value="${basedir}/gen/src"/>
      <arg value="-c"/>
      <arg value="${basedir}/custom3a.xml"/>
      <arg value="-u"/>
      <arg value="http://www.opentravel.org/OTA/2003/05"/>
      <arg value="otasubset/OTA_Common*.xsd"/>
    </java>
    
  </target>
  
  <!-- modular generation of extension types -->
  <target name="custgen3b" depends="check-runtime,check-base,clean-partial">
    
    <echo message="Running extension code generation from schema"/>
    <delete quiet="true" dir="${basedir}/gen"/>
    <java classname="org.jibx.schema.codegen.CodeGen" fork="yes"
        failonerror="true">
      <classpath>
        <path refid="classpath"/>
        <pathelement location="${basedir}/base.jar"/>
      </classpath>
      <arg value="-t"/>
      <arg value="${basedir}/gen/src"/>
      <arg value="-i"/>
      <arg value="classpath:base-binding.xml"/>
      <arg value="-c"/>
      <arg value="${basedir}/custom3b.xml"/>
      <arg value="otasubset/OTA_AirLowFareSearch*.xsd"/>
    </java>
    
  </target>
  
  <!-- compile the classes -->
  <target name="compile" depends="check-runtime">
  
    <echo message="Compiling Java source code"/>
    <delete quiet="true" dir="${basedir}/bin"/>
    <mkdir dir="${basedir}/bin"/>
    <javac srcdir="${basedir}/gen/src" destdir="${basedir}/bin" debug="on">
      <classpath refid="classpath"/>
    </javac>
    <javac srcdir="${basedir}/src" destdir="${basedir}/bin" debug="on">
      <classpath refid="classpath"/>
    </javac>
    
  </target>  
  
  <!-- bind as a separate step -->
  <target name="bind" depends="check-binding">
    
    <echo message="Running JiBX binding compiler"/>
    <bind binding="${basedir}/gen/src/binding.xml">
      <classpath refid="classpath"/>
    </bind>
    
  </target>
  
  <!-- compile, bind, and jar modular base classes -->
  <target name="buildbase" depends="check-runtime">
  
    <echo message="Compiling Java source code"/>
    <delete quiet="true" dir="${basedir}/gen/bin"/>
    <mkdir dir="${basedir}/gen/bin"/>
    <javac srcdir="${basedir}/gen/src" destdir="${basedir}/gen/bin" debug="on">
      <classpath refid="classpath"/>
    </javac>
    
    <echo message="Running JiBX binding compiler"/>
    <bind binding="${basedir}/gen/src/base-binding.xml">
      <classpath>
        <path refid="classpath"/>
        <pathelement location="${basedir}/gen/bin"/>
      </classpath>
    </bind>
    
    <echo message="Building jar"/>
    <jar jarfile="${basedir}/base.jar">
      <fileset dir="${basedir}/gen/bin"/>
      <fileset dir="${basedir}/gen/src" includes="*.xml"/>
    </jar>
    
  </target>
  
  <!-- compile and bind the modular classes extending base classes -->
  <target name="buildext" depends="check-runtime">
  
    <echo message="Compiling Java source code"/>
    <delete quiet="true" dir="${basedir}/bin"/>
    <mkdir dir="${basedir}/bin"/>
    <javac srcdir="${basedir}/gen/src" destdir="${basedir}/bin" debug="on">
      <classpath>
        <path refid="classpath"/>
        <pathelement path="${basedir}/base.jar"/>
      </classpath>
    </javac>
    <javac srcdir="${basedir}/src" destdir="${basedir}/bin" debug="on">
      <classpath refid="classpath"/>
    </javac>
    
    <echo message="Running JiBX binding compiler"/>
    <bind binding="${basedir}/gen/src/binding.xml">
      <classpath>
        <path refid="classpath"/>
        <pathelement path="${basedir}/base.jar"/>
      </classpath>
    </bind>
    
  </target>
  
  <!-- run the included test program to read and then write to separate file -->
  <target name="run" depends="check-runtime">
    <echo message="Running the sample application..."/>
    <java classname="org.jibx.starter.Test" fork="true" failonerror="true">
      <classpath refid="classpath"/>
      <arg value="org.opentravel.ota"/>
      <arg value="${basedir}/samples"/>
    </java>
  </target>
  
  <!-- run the included test program to read and then write to separate file -->
  <target name="runcust" depends="check-runtime">
    <echo message="Running the sample application..."/>
    <java classname="org.jibx.starter.Test" fork="true" failonerror="true">
      <classpath refid="classpath"/>
      <arg value="org.ota.air"/>
      <arg value="${basedir}/samples"/>
    </java>
  </target>
  
  <!-- run the included test program to read and then write to separate file -->
  <target name="runmodular" depends="check-runtime">
    <echo message="Running the sample application..."/>
    <java classname="org.jibx.starter.Test" fork="true" failonerror="true">
      <classpath>
        <path refid="classpath"/>
        <pathelement path="${basedir}/base.jar"/>
      </classpath>
      <arg value="org.ota.air"/>
      <arg value="${basedir}/samples"/>
    </java>
  </target>
  
  <!-- compile, generate, compile binding, run test -->
  <target name="full" depends="codegen,compile,bind,run"/>
  <target name="custom1" depends="custgen1,compile,bind,runcust"/>
  <target name="custom2" depends="custgen2,compile,bind,runcust"/>
  <target name="modular" depends="custgen3a,buildbase,custgen3b,buildext,runmodular"/>
  
  <!-- show list of targets -->
  <target name="help">
    <echo message="Targets are:"/>
    <echo/>
    <echo message="clean         delete all class files and generated code"/>
    <echo message="codegen       generate default code and binding"/>
    <echo message="custgen1      generate code and binding using custom1.xml"/>
    <echo message="custgen2      generate code and binding using custom2.xml"/>
    <echo message="compile       compile class files (non-modular)"/>
    <echo message="bind          compile JiBX bindings (non-modular)"/>
    <echo message="run           run test application with default code package"/>
    <echo message="runcust       run test application with custom code package"/>
    <echo message="full          generate default, compile, bind, and test"/>
    <echo message="custom1       generate using custom1.xml, compile, bind, and test"/>
    <echo message="custom2       generate using custom2.xml, compile, bind, and test"/>
    <echo message="custgen3a     generate base code and binding using custom3a.xml"/>
    <echo message="custgen3b     generate extension code and binding using custom3b.xml"/>
    <echo message="buildbase     compile, bind, and jar base code for modular binding"/>
    <echo message="buildext      compile and bind modular extension JiBX bindings"/>
    <echo message="runmodular    run test application with modular code package"/>
    <echo message="modular       generate modular using custom3a.xml and custom3b.xml,"/>
    <echo message="              compile, bind, and test"/>
  </target>

</project>