File: build.xml

package info (click to toggle)
libjibx-java 1.0.1-2
  • links: PTS
  • area: contrib
  • in suites: lenny
  • size: 15,748 kB
  • ctags: 10,069
  • sloc: java: 29,151; xml: 7,963; makefile: 14
file content (142 lines) | stat: -rw-r--r-- 5,479 bytes parent folder | download
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
<?xml version="1.0"?>

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

Ant build file for JiBX data binding 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">
    <and>
      <available file="${jibx-home}/lib/jibx-run.jar"/>
      <available file="${jibx-home}/lib/xpp3.jar"/>
    </and>
  </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"/>
      <available file="${jibx-home}/lib/xpp3.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">
    <fileset dir="${jibx-home}/lib"
      includes="jibx-extras.jar,jibx-run.jar,xpp3.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 or xpp3.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>
  
  <!-- clean compiled class files and output file -->
  <target name="clean">
    <delete quiet="true" dir="bin"/>
    <delete quiet="true" file="out.xml"/>
  </target>
  
  <!-- compile as a separate step -->
  <target name="compile" depends="clean,check-runtime">
  
    <echo message="Compiling Java source code"/>
    <mkdir dir="bin"/>
    <javac srcdir="src" destdir="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"/>
    <taskdef name="bind" classname="org.jibx.binding.ant.CompileTask">
      <classpath>
        <pathelement location="${jibx-home}/lib/jibx-bind.jar"/>
      </classpath>
    </taskdef>
    <bind binding="${basedir}/binding.xml">
      <classpath refid="classpath"/>
    </bind>
    
  </target>
  
  <!-- compile and bind -->
  <target name="build" depends="compile,bind"/>
  
  <!-- test binding with jibx-extras roundtripping tool -->
  <target name="roundtrip" depends="check-extras">
    <echo message="Roundtripping the document using binding..."/>
    <java classname="org.jibx.extras.TestRoundtrip"
        fork="true" failonerror="true">
      <classpath refid="classpath"/>
      <arg value="org.jibx.starter.Customer"/>
      <arg value="${basedir}/data.xml"/>
    </java>
    <echo message="Roundtrip test successful"/>
  </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="${basedir}/data.xml"/>
      <arg value="${basedir}/out.xml"/>
    </java>
    <echo message="Generated output document out.xml"/>
  </target>
  
  <!-- show list of targets -->
  <target name="help">
    <echo message="Targets are:"/>
    <echo/>
    <echo message="clean      delete all class files and generated code"/>
    <echo message="compile    compile class files as a separate step"/>
    <echo message="bind       compile JiBX bindings as a separate step"/>
    <echo message="build      compile classes and JiBX binding"/>
    <echo message="roundtrip  test binding with jibx-extras roundtripping tool"/>
    <echo message="run        run the test application"/>
  </target>

</project>