-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.xml
226 lines (198 loc) · 7.37 KB
/
build.xml
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
<project name="dbunit-samples" basedir="." default="usage" xmlns:ivy="antlib:org.apache.ivy.ant">
<property file="build.local.properties"/>
<property file="build.properties"/>
<path id="classpath.compile">
<fileset dir="lib/ivy/compile"/>
</path>
<path id="classpath.runtime">
<fileset dir="lib/ivy/runtime"/>
</path>
<path id="classpath.test">
<fileset dir="lib/ivy/test"/>
</path>
<path id="classpath.system">
<fileset dir="lib/system"/>
</path>
<path id="classpath.ant">
<fileset dir="lib/ivy/ant"/>
</path>
<!-- Ivy bootstrap: see http://www.draconianoverlord.com/2009/04/23/ivy-is-useful.html -->
<available property="ivy.installed" file="${ivy.home}/${ivy.jar.name}"/>
<target name="ivy.install" unless="ivy.installed">
<mkdir dir="${ivy.home}"/>
<get src="http://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.jar.version}/${ivy.jar.name}"
dest="${ivy.home}/${ivy.jar.name}"/>
</target>
<target name="ivy.bootstrap" depends="ivy.install" unless="ivy.bootstrapped">
<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant"
classpath="${ivy.home}/${ivy.jar.name}"/>
<property name="ivy.bootstrapped" value="true"/> <!-- Avoid re-bootstrapping because it causes classloader issues. -->
</target>
<target name="ivy-retrieve" depends="ivy.bootstrap">
<ivy:retrieve sync="true" conf="${ivy.configurations}"/>
</target>
<available property="ojdbc.installed" file="${oracle.jar}"/>
<target name="check-ojdbc" unless="ojdbc.installed">
<fail message="Download Oracle ojdbc JAR from http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/htdocs/jdbc_112010.html, copy to ${oracle.jar}."/>
</target>
<macrodef name="run-sql">
<attribute name="userid" default="${db.userid}"/>
<attribute name="password" default="${db.password}"/>
<attribute name="file"/>
<sequential>
<sql driver="${db.driver}"
url="${db.url}"
userid="@{userid}"
password="@{password}"
delimiter=";">
<classpath refid="classpath.system"/>
<fileset dir="src/main/sql/ddl" includes="@{file}"/>
</sql>
</sequential>
</macrodef>
<target name="create-schema" depends="check-ojdbc"
description="Create 'birt' user/schema in database.">
<run-sql userid="${db.system.userid}" password="${db.system.password}" file="create_schema.sql"/>
</target>
<target name="drop-schema" depends="check-ojdbc"
description="Drop 'birt' user/schema from database.">
<run-sql userid="${db.system.userid}" password="${db.system.password}" file="drop_schema.sql"/>
</target>
<target name="create-classicmodels" depends="check-ojdbc"
description="Create tables for classicmodels application.">
<run-sql file="create_classicmodels.sql"/>
</target>
<target name="create-xml-table" depends="check-ojdbc"
description="Create xml_table for special XML test.">
<run-sql file="create_xml_table.sql"/>
</target>
<target name="load-classicmodels" depends="check-ojdbc"
description="Load data via SQL INSERT script.">
<run-sql file="load_classicmodels.sql"/>
</target>
<target name="taskdef-dbunit" depends="ivy-retrieve">
<taskdef name="dbunit" classname="org.dbunit.ant.DbUnitTask">
<classpath refid="classpath.ant"/>
</taskdef>
</target>
<macrodef name="run-dbunit">
<element name="commands" implicit="true"/>
<sequential>
<dbunit driver="${db.driver}"
url="${db.url}"
userid="${db.userid}"
password="${db.password}"
schema="${db.schema}">
<classpath refid="classpath.ant"/>
<classpath refid="classpath.system"/>
<dbconfig>
<property name="datatypeFactory" value="org.dbunit.ext.oracle.Oracle10DataTypeFactory" />
</dbconfig>
<commands/>
</dbunit>
</sequential>
</macrodef>
<target name="dbunit-export" depends="check-ojdbc,taskdef-dbunit"
description="Export table contents to FlatXmlDataSet.">
<run-dbunit>
<export dest="data/dbunit-dataset.xml">
<table name="productlines"/>
<table name="products"/>
<table name="offices"/>
<table name="employees"/>
<table name="customers"/>
<table name="payments"/>
<table name="orders"/>
<table name="orderdetails"/>
</export>
</run-dbunit>
</target>
<target name="dbunit-import" depends="check-ojdbc,taskdef-dbunit"
description="Import table contents from FlatXmlDataSet.">
<run-dbunit>
<operation type="CLEAN_INSERT" src="data/dbunit-dataset.xml"/>
</run-dbunit>
</target>
<target name="clean">
<delete dir="build"/>
</target>
<target name="prepare">
<mkdir dir="build/classes/main"/>
<mkdir dir="build/classes/test"/>
<mkdir dir="build/reports/junit"/>
</target>
<macrodef name="run-javac">
<attribute name="srcdir"/>
<attribute name="destdir"/>
<element name="body" implicit="true"/>
<sequential>
<javac srcdir="@{srcdir}"
destdir="@{destdir}"
debug="${compile.debug}"
optimize="${compile.optimize}"
source="${compile.source}"
target="${compile.target}">
<body/>
</javac>
</sequential>
</macrodef>
<target name="compile-main" depends="prepare">
<run-javac srcdir="src/main/java" destdir="build/classes/main">
<classpath>
<path refid="classpath.compile"/>
</classpath>
</run-javac>
</target>
<target name="compile-test" depends="compile-main">
<run-javac srcdir="src/test/java" destdir="build/classes/test">
<classpath>
<path refid="classpath.system"/>
<path refid="classpath.test"/>
<pathelement location="build/classes/main"/>
</classpath>
</run-javac>
<copy todir="build/classes/test">
<fileset dir="src/test/resources"/>
</copy>
</target>
<target name="test" depends="compile-test">
<junit
errorProperty="test.failed"
failureProperty="test.failed"
printsummary="${test.printsummary}"
haltonfailure="${test.haltonfailure}"
fork="true"
forkmode="once"
reloading="false"
dir="."
showoutput="${test.showoutput}">
<classpath path="build/classes/main"/>
<classpath path="build/classes/test"/>
<classpath refid="classpath.system"/>
<classpath refid="classpath.test"/>
<formatter type="brief" usefile="false"/>
<formatter type="xml"/>
<sysproperty key="db.driver" value="${db.driver}"/>
<sysproperty key="db.url" value="${db.url}"/>
<sysproperty key="db.userid" value="${db.userid}"/>
<sysproperty key="db.password" value="${db.password}"/>
<sysproperty key="db.schema" value="${db.schema}"/>
<batchtest todir="build/reports/junit">
<fileset dir="build/classes/test">
<include name="**/${test.class}.class"/>
</fileset>
</batchtest>
</junit>
</target>
<target name="zip-src" description="Create ZIP file of dbunit-oracle-sample project.">
<zip basedir="." file="dbunit-oracle-sample.zip">
<include name="build.*"/>
<include name="data/**"/>
<include name="lib/**"/>
<include name="src/**"/>
</zip>
</target>
<target name="usage">
<echo message="Run ant -p to see targets defined."/>
</target>
</project>