summaryrefslogtreecommitdiffstats
path: root/build.xml
blob: 72c496070c4b17e1d1a8e85db63dfd8edcf02d3f (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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
<?xml version="1.0" encoding="UTF-8"?>
<project name="iciql" default="buildAll" basedir=".">

	<!-- Google Code upload task -->
	<taskdef classname="net.bluecow.googlecode.ant.GoogleCodeUploadTask" 
		classpath="${basedir}/tools/ant-googlecode-0.0.3.jar" name="gcupload"/>

	<!-- Project Properties -->
	<property name="project.build.dir" value="${basedir}/build" />
	<property name="project.site.dir" value="${basedir}/site" />

	<!-- Load publication servers, paths, and credentials --> 
	<loadproperties srcfile="${basedir}/build.properties" />
	
	
	<!--
		~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
		Scrape the version info from code and setup the build properties 
		~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	-->
	<target name="buildinfo">
	
		<!-- extract iciql version number from source code -->
		<loadfile property="iq.version" srcfile="${basedir}/src/com/iciql/Constants.java">
			<filterchain>
				<linecontains>
					<contains value="public static final String VERSION = " />
				</linecontains>
				<striplinebreaks />
				<tokenfilter>
					<replacestring from="public static final String VERSION = &quot;" to="" />
					<replacestring from="&quot;;" to="" />
					<trim />
				</tokenfilter>
			</filterchain>
		</loadfile>

		<!-- extract iciql version date from source code -->
		<loadfile property="iq.versionDate" srcfile="${basedir}/src/com/iciql/Constants.java">
			<filterchain>
				<linecontains>
					<contains value="public static final String VERSION_DATE = " />
				</linecontains>
				<striplinebreaks />
				<tokenfilter>
					<replacestring from="public static final String VERSION_DATE = &quot;" to="" />
					<replacestring from="&quot;;" to="" />
					<trim />
				</tokenfilter>
			</filterchain>
		</loadfile>
		
		<!-- extract iciql current api version from source code -->
		<loadfile property="iq.apiCurrent" srcfile="${basedir}/src/com/iciql/Constants.java">
			<filterchain>
				<linecontains>
					<contains value="public static final String API_CURRENT = " />
				</linecontains>
				<striplinebreaks />
				<tokenfilter>
					<replacestring from="public static final String API_CURRENT = &quot;" to="" />
					<replacestring from="&quot;;" to="" />
					<trim />
				</tokenfilter>
			</filterchain>
		</loadfile>

		<property name="library.jar" value="${basedir}/iciql-${iq.version}.jar" />
		<property name="javadoc.jar" value="${basedir}/iciql-${iq.version}-javadoc.jar" />
		<property name="sources.jar" value="${basedir}/iciql-${iq.version}-sources.jar" />
		<property name="distribution.zip" value="${basedir}/iciql-${iq.version}.zip" />
	</target>

	
	<!--
		~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
		Compile
		~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	-->
	<target name="compile" depends="buildinfo" description="Retrieves dependencies and compiles iciql from source">
		<!-- Compile the build tool and execute it.
			 This downloads missing compile-time dependencies from Maven. -->

		<delete dir="${project.build.dir}" />
		<mkdir dir="${project.build.dir}" />
		<javac srcdir="${basedir}/src" destdir="${project.build.dir}">
			<include name="com/iciql/build/Build.java" />
			<include name="com/iciql/Constants.java" />
			<include name="com/iciql/utils/Utils.java" />
			<include name="com/iciql/utils/StringUtils.java" />
		</javac>
		<java classpath="${project.build.dir}" classname="com.iciql.build.Build" />

		<!-- Compile Project -->
		<path id="master-classpath">
			<fileset dir="${basedir}/ext">
				<include name="*.jar" />
			</fileset>
		</path>
		<javac destdir="${project.build.dir}" failonerror="false">
			<src path="${basedir}/src" />
			<src path="${basedir}/tests" />
			<classpath refid="master-classpath" />
		</javac>
		<copy todir="${project.build.dir}">
			<fileset dir="${basedir}/src" excludes="**/*.java,**/thumbs.db" />
		</copy>

		<!-- Execute the test suite -->
		<echo>Executing iciql ${iq.version} test suite</echo>
		<echo>This will take a few minutes...</echo>
		<java classpath="${project.build.dir}" classname="com.iciql.test.IciqlSuite">
			<classpath refid="master-classpath" />
			<arg value="--dbFile" />
			<arg value="${basedir}/performance_db.txt" />
				
			<arg value="--sqlFile" />
			<arg value="${basedir}/performance_sql.txt" />
		</java>
		
		<!-- Build Standard Javadoc -->
		<delete dir="${basedir}/javadoc" />
		<javadoc destdir="${basedir}/javadoc" nonavbar="true" stylesheetfile="${basedir}/docs/resources/javadoc.css">
			<fileset dir="${basedir}/src" defaultexcludes="yes">
		  		<include name="com/iciql/**/*.java"/>
		  		<exclude name="com/iciql/build/**"/>
			</fileset>
		</javadoc>

		<!-- Build Doclava Javadoc -->
		<!-- Build API XML file -->
		<delete dir="${basedir}/doclava" />
		<javadoc destdir="${basedir}/doclava" 
			docletpath="${basedir}/ext/doclava-1.0.3.jar"
			bootclasspath="${java.home}/lib/rt.jar">
		 	<doclet name="com.google.doclava.Doclava">
		        <param name="-hdf"/> <param name="project.name"/> <param name="iciql"/>
		 		
		        <!-- versioning -->
		 		<param name="-since"/> <param name="api/v1.xml"/> <param name="v1" />
		 		<param name="-since"/> <param name="api/v2.xml"/> <param name="v2" />
		 		<param name="-since"/> <param name="api/v3.xml"/> <param name="v3" />
		 		<param name="-since"/> <param name="api/v4.xml"/> <param name="v4" />
		 		<param name="-since"/> <param name="api/v5.xml"/> <param name="v5" />
		        <param name="-apiversion" value="v${iq.apiCurrent}"/>
		 		
		 		<param name="-apixml" value="api/v${iq.apiCurrent}.xml"/>
		 		
		        <!-- federation -->
		        <param name="-federate" /><param name="JDK"/>
		        <param name="http://download.oracle.com/javase/6/docs/api/index.html?"/>
		        <param name="-federationxml"/><param name="JDK"/>
		        <param name="http://doclava.googlecode.com/svn/static/api/openjdk-6.xml"/>
		      </doclet>
			<fileset dir="${basedir}/src" defaultexcludes="yes">
			  <include name="com/iciql/**/*.java"/>
			  <exclude name="com/iciql/build/**"/>
			</fileset>
		</javadoc>
	</target>

	
	<!--
		~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
		Build
		~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	-->
	<target name="build" depends="compile" description="Builds iciql from source">
		
		<echo>Building iciql binaries ${iq.version}</echo>
		
		<!-- delete any old artifacts -->
		<delete>
			<fileset dir="${basedir}">
				<include name="*.jar"/>
				<include name="*.zip"/>
			</fileset>
		</delete>
		
		<!-- library jar -->
		<jar destfile="${library.jar}">
			<manifest>
				<attribute name="Main-Class" value="com.iciql.util.GenerateModels" />
			</manifest>
			<fileset dir="${project.build.dir}">
				<include name="**/*" />
				<exclude name="com/iciql/build/" />
				<exclude name="com/iciql/test/" />
				<exclude name="**/*.html" />
			</fileset>
		</jar>
		
		<!-- standard javadoc jar -->
		<jar destfile="${javadoc.jar}">
			<fileset dir="${basedir}/javadoc">
				<include name="**/*" />
			</fileset>
		</jar>
		
		<!-- sources jar -->		
		<jar destfile="${sources.jar}">
			<fileset dir="${basedir}/src">
				<include name="**/*" />
				<exclude name="com/iciql/build/" />
				<exclude name="com/iciql/tests/" />
				<exclude name="**/*.html" />
			</fileset>
		</jar>
		
		<!-- zip distribution file -->
		<jar destfile="${distribution.zip}">
			<fileset dir="${basedir}">
				<include name="*.jar" />
				<include name="LICENSE" />
				<include name="NOTICE" />
				<include name="javadoc/**/*" />
			</fileset>
		</jar>
	</target>

	
	<!-- 
		~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
		Build the iciql website
		~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	-->
	<target name="buildSite" depends="compile" description="Build the iciql website">
		
		<echo>Building iciql website ${iq.version}</echo>

		<!-- Build Site -->
		<delete dir="${project.site.dir}" />
		<mkdir dir="${project.site.dir}" />
		<copy todir="${project.site.dir}">
			<fileset dir="${basedir}/docs/resources">
				<include name="*.png" />
				<include name="*.css" />
				<include name="*.js" />
			</fileset>
		</copy>
		
		<!-- Copy standard javadoc -->
		<mkdir dir="${project.site.dir}/javadoc" />
		<copy todir="${project.site.dir}/javadoc">
			<fileset dir="${basedir}/javadoc">
				<include name="**/*" />
			</fileset>
		</copy>
		
		<!-- Build site pages -->
		<java classpath="${project.build.dir}" classname="com.iciql.build.BuildSite">
			<classpath refid="master-classpath" />
			<arg value="--sourceFolder" />
			<arg value="${basedir}/docs" />

			<arg value="--outputFolder" />
			<arg value="${project.site.dir}" />

			<arg value="--pageHeader" />
			<arg value="${basedir}/docs/resources/site_header.html" />
			
			<arg value="--pageFooter" />
			<arg value="${basedir}/docs/resources/site_footer.html" />

			<arg value="--analyticsSnippet" />
			<arg value="${basedir}/docs/resources/site_analytics.html" />

			<arg value="--adSnippet" />
			<arg value="${basedir}/docs/resources/site_ads.html" />

			<arg value="--alias" />
			<arg value="index=overview" />

			<arg value="--alias" />
			<arg value="table_versioning=versioning" />

			<arg value="--nomarkdown" />
			<arg value="%BEGINCODE%:%ENDCODE%" />

			<arg value="--substitute" />
			<arg value="%VERSION%=${iq.version}" />

			<arg value="--substitute" />
			<arg value="%BUILDDATE%=${iq.versionDate}" />

			<arg value="--substitute" />
			<arg value="%JAR%=${library.jar}" />

			<arg value="--substitute" />
			<arg value="%ZIP%=${distribution.zip}" />

			<arg value="--substitute" />
			<arg value="&quot;%BEGINCODE%=&lt;pre class='prettyprint lang-java'&gt;&quot;" />

			<arg value="--substitute" />
			<arg value="%ENDCODE%=&lt;/pre&gt;" />
			
			<arg value="--regex" />
			<arg value="&quot;\b(issue)(\s*[#]?|-){0,1}(\d+)\b!!!&lt;a href='http://code.google.com/p/iciql/issues/detail?id=$3'&gt;issue $3&lt;/a&gt;&quot;" />

			<arg value="--load" />
			<arg value="%DBPERFORMANCE%=${basedir}/performance_db.txt" />

		</java>	
	</target>

	
	<!-- 
		~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
		Build binary artifacts and site 
		~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	-->
	<target name="buildAll" description="Build the iciql artifacts and the site" depends="build,buildSite">
	</target>

	<!-- 
		~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
		Publish binaries to Google Code
		~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	-->
	<target name="publishBinaries" depends="build" description="Publish the iciql binaries to Google Code">

		<echo>Uploading iciql ${iq.version} binaries</echo>

		<gcupload 
			 username="${googlecode.user}" 
			 password="${googlecode.password}" 
			 projectname="iciql" 
			 filename="${distribution.zip}" 
			 targetfilename="iciql-${iq.version}.zip"
			 summary="Version ${iq.version} -- library, sources, javadoc, and docs"
			 labels="Featured, Type-Package, OpSys-All" />
	
		<gcupload 
			 username="${googlecode.user}" 
			 password="${googlecode.password}" 
			 projectname="iciql" 
			 filename="${library.jar}" 
			 targetfilename="iciql-${iq.version}.jar"
			 summary="Version ${iq.version} -- library"
			 labels="Featured, Type-Package, OpSys-All" />
	</target>

	
	<!--
		~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
		Publish site to hosting service
		You must add ext/commons-net-1.4.0.jar to your ANT classpath.
		~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	-->
	<target name="publishSite" depends="buildSite" description="Publish the iciql site to a webserver (requires ext/commons-net-1.4.0.jar)" >

		<echo>Uploading iciql ${iq.version} website</echo>

		<ftp server="${ftp.server}"
			userid="${ftp.user}"
			password="${ftp.password}"
			remotedir="${ftp.dir}"
			passive="true"
			verbose="yes">
			<fileset dir="${project.site.dir}" />
		</ftp>
	</target>


	<!--
		~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
		Compile from source, publish binaries, and build & deploy site
		~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	-->
	<target name="publishAll" depends="publishBinaries,publishSite">
		<!-- Cleanup -->
		<delete dir="${project.build.dir}" />
	</target>
</project>