File: build.xml

package info (click to toggle)
nekohtml 1.9.21-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,868 kB
  • ctags: 1,211
  • sloc: java: 7,972; xml: 380; makefile: 22; sh: 13
file content (404 lines) | stat: -rw-r--r-- 16,228 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
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
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
<?xml version='1.0' encoding='UTF-8'?>
<project default='all' basedir='.' xmlns:artifact="urn:maven-artifact-ant">

 <!-- PROPERTIES -->
 <property file='build-custom.properties' />
 
 <property name='version'   value='1.9.21'/>
 <property name='name'      value='nekohtml'/>
 <property name='fullname'  value='${name}-${version}'/>
 <property name='Title'     value='NekoHTML'/>
 <property name='FullTitle' value='CyberNeko HTML Parser'/>
 <property name='Name'      value='${Title} ${version}'/>
 <property name='author'    value='Andy Clark, Marc Guillemot'/>
 <property name='copyright' value='(C) Copyright 2002-2014, ${author}. All rights reserved.'/>
 <property name='URL'       value='http://nekohtml.sourceforge.net/index.html'/>
 
 <property name='compile.source' value='1.3' />
 <property name='compile.target' value='1.3' />
  
 <property name='src.dir'           value='src' />
 <property name='src.test.dir'      value='test/java' />
 <property name='doc.dir'           value='doc' />
 <property name='data.dir'          value='data' />
 <property name='lib.dir'           value='lib' />
 <property name='build.dir'         value='build' />
 <property name='build.classes.dir' value='${build.dir}/classes' />
 <property name='build.test-classes.dir' value='${build.dir}/test-classes' />
 <property name='build.src.dir'     value='${build.dir}/src' />
 <property name='build.doc.dir'     value='${build.dir}/doc/api' />
 <property name='build.data.dir'	value='${build.dir}/data/output' />
 <property name='build.lib.dir'     value='${build.dir}/lib' />
 
 <property name='jar.file'         value='${build.lib.dir}/${name}.jar'/>
 <property name='jar.samples.file' value='${build.lib.dir}/${name}Samples.jar'/>
 <property name='jar.xni.file'     value='${build.lib.dir}/${name}Xni.jar'/>

 <property name='zip.file' value='${build.dir}/${fullname}.zip'/>
 <property name='tgz.file' value='${build.dir}/${fullname}.tar.gz'/>

 <property name='package' value='org.cyberneko.html'/>

 <property name='version.java.dir' value='${build.src.dir}/org/cyberneko/html'/>
 <property name='version.java'     value='${version.java.dir}/Version.java'/>
 
 <!-- defined maven snapshots and staging repository id and url -->
 <property name="maven-snapshots-repository-id" value="sonatype-nexus-snapshots" />
 <property name="maven-snapshots-repository-url" value="https://oss.sonatype.org/content/repositories/snapshots/" />
 <property name="maven-staging-repository-id" value="sonatype-nexus-staging" />
 <property name="maven-staging-repository-url" value="https://oss.sonatype.org/service/local/staging/deploy/maven2/" />

 <!-- DEPENDENCIES -->
 <available property='bcel.available' file='${lib.dir}/bcel-5.2.jar' />

 <property name="xerces.version" value="2.9.1"/>

 <!-- TARGETS --> 
 <target name='all' depends='zip,tgz'/>

 <target name='init'>
 </target>

	<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<macrodef name="compileWith" description="clean compile for the specified Xerces version">
	<attribute name="xercesVersion" description="the name of the /lib subfolder containing Xerces"/>
	<attribute name="bridge" description="the name of the bridge package that should be compiled"/>
	<sequential>
		<echo message="Compiling with Xerces-@{xercesVersion}"/>
		<delete>
			<fileset dir='${build.classes.dir}'>
				<include name="**/*"/>
				<exclude name="**/xercesbridge/XercesBridge_*.*"/>
			</fileset>
			<fileset dir='${build.classes.dir}'>
				<include name="**/xercesbridge/XercesBridge_@{bridge}.*"/>
			</fileset>
		</delete>
		<javac destdir='${build.classes.dir}' debug='true' encoding="ISO-8859-1" 
			source='${compile.source}' target='${compile.target}'
			includeAntRuntime='false'>
			<classpath>
				<pathelement path="${java.class.path}"/>
			</classpath>
			<src path='${src.dir}' />
			<src path='${build.src.dir}' />
			<include name='**/*.java' />
			<exclude name="**/xercesbridge/XercesBridge_*.java"/>
		</javac>
		<javac destdir='${build.classes.dir}' debug='true' encoding="ISO-8859-1" 
			source='${compile.source}' target='${compile.target}'
			includeAntRuntime='false'>
			<classpath>
				<pathelement path="${java.class.path}"/>
			</classpath>
			<src path='${src.dir}' />
			<src path='${build.src.dir}' />
			<include name="**/xercesbridge/XercesBridge_@{bridge}.java"/>
		</javac>
	</sequential>
</macrodef>
	
<target name='compile' depends='init,version' 
		description="compiles many times to ensure compatibility with the different Xerces versions"
		unless="compile.skip">
	<mkdir dir="${build.classes.dir}"/>
	
	<compileWith xercesVersion="2.9.1" bridge="2_3"/>
	<compileWith xercesVersion="2.10.0" bridge="2_3"/>

	<copy todir="${build.classes.dir}">
		<fileset dir='${src.dir}' includes='**' excludes='META-INF/**, **/*.java*' />
  	</copy>
</target>

	<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
 <target name='jar' depends='compile'>
  <mkdir dir='${build.lib.dir}' />
  <jar jarfile='${jar.file}'>
	<manifest>
    	<attribute name="Built-By" value="${author}"/>
    	<section name="org/cyberneko/html/">
		  <attribute name="Specification-Title" value="Hyper-Text Markup Language (HTML)" />
    	  <attribute name="Specification-Version" value="4.01" />
	      <attribute name="Specification-Vendor" value="World Wide Web Consortium (W3C)" />
    	  <attribute name="Implementation-Title" value="${FullTitle}" />
	      <attribute name="Implementation-Version" value="${version}" /> 
    	  <attribute name="Implementation-Vendor" value="${author}" />
		  <attribute name="Implementation-URL" value="${URL}" />
    	</section>
	</manifest>
    <fileset dir='.' includes='LICENSE*' />
    <fileset dir='${build.classes.dir}' includes='org/**/*' />
  </jar>
  <jar jarfile='${jar.samples.file}'>
    <fileset dir='.' includes='LICENSE.txt' />
    <fileset dir='${build.classes.dir}' includes='sample/**' />
  </jar>
 </target> 

 <target name='jar-xni'>
  <mkdir dir="${build.lib.dir}"/>
  <jar jarfile='${jar.xni.file}'>
    <fileset dir='.' includes='LICENSE.txt' />
    <fileset dir='${src.dir}' includes='META-INF/services/**' />
  </jar>
 </target>

 <target name='zip' depends='jar,doc'>
  <zip zipfile='${zip.file}'>
    <zipfileset prefix='${fullname}' dir='.' includes='LICENSE*,README*,TODO*' />
    <zipfileset prefix='${fullname}' dir='.' includes='build.xml' />
    <zipfileset prefix='${fullname}' dir='.' includes='${src.dir}/**' />
    <zipfileset prefix='${fullname}' dir='.' includes='${src.test.dir}/**' />
    <zipfileset prefix='${fullname}' dir='.' includes='${doc.dir}/**' excludes='${doc.dir}/javadoc/**' />
    <zipfileset prefix='${fullname}' dir='.' includes='${data.dir}/**' />
    <zipfileset prefix='${fullname}' dir='.' includes='${lib.dir}/**/*.jar' />
    <zipfileset prefix='${fullname}' dir='${build.dir}' includes='doc/**' />
    <zipfileset prefix='${fullname}' dir='${build.lib.dir}' includes='**' />
  </zip>
 </target>

 <target name='tgz' depends='zip'>
  <unzip src='${zip.file}' dest='${build.dir}' />
  <tar destfile='${tgz.file}' compression='gzip'>
  	<tarfileset dir='${build.dir}' includes='${fullname}/**' />
  </tar>
 </target>

 <target name='doc' depends='doc-init' unless='doc.done'>
  <delete dir='${build.doc.dir}'/>
  <mkdir dir='${build.doc.dir}'/>
  <javadoc packagenames='${package},${package}.parsers,${package}.filters'
           sourcepath='${src.dir}' destdir='${build.doc.dir}'
           author='true' version='true' use='true'
           windowtitle="${Name} Implementation"
           doctitle="${Name}" encoding="ISO-8859-1"
           bottom="${copyright}" 
  />
 </target>
 
 <target name='doc-init'>
 	<dependset>
 		<srcfileset dir='${src.dir}' />
 		<targetfileset dir='${build.doc.dir}' />
 	</dependset>
 	<available property='doc.done' file='${build.doc.dir}/index.html' />	
 </target>

 <target name='version' depends='version-init' unless='available.version'>
  <echo message='Generating ${version.java}'/>
  <echo file='${version.java}'>/* ${copyright} */

package org.cyberneko.html;

/**
 * This class holds version information for the ${FullTitle}.
 *
 * @author ${author}
 */
public class Version {

    /** Returns the version string. */
    public static String getVersion() { return "${Name}"; }

    /** Prints the version string to standard output. */
    public static void main(String[] argv) {
        System.out.println(getVersion());
    } // main(String[])

} // class Version</echo>
 </target>

 <target name='version-init'>
  <mkdir dir='${version.java.dir}/'/>
  <dependset>
   <srcfilelist    dir='.' files='build.xml'/>
   <targetfilelist dir='.' files='${version.java}'/>
  </dependset>
  <available property='available.version' file='${version.java}'/>
 </target>

 <target name='minimal' depends='minimal-init,compile'>
 	<java classname='org.apache.tools.ant.Main'>
 		<classpath>
 			<pathelement path='${java.class.path}' />
 			<pathelement location='${lib.dir}/bcel-5.2.jar' />
 		</classpath>
 		<arg value='x-minimal' />
 	</java>
 </target>

 <target name='x-minimal'>
 	<unzip dest='${build.classes.dir}' src='${lib.dir}/xerces-${xerces.version}/xercesImpl-${xerces.version}.jar' />
 	<classfileset id='minimal.classes' dir="${build.classes.dir}" includes='org/apache/**'>
 		<root classname="org.cyberneko.html.HTMLConfiguration"/> 
 		<root classname="org.cyberneko.html.parsers.DOMFragmentParser"/> 
 		<root classname="org.apache.xerces.parsers.DOMParser"/>
 		<root classname="org.apache.html.dom.HTMLDocumentImpl"/>
 		<root classname="org.apache.xerces.impl.Version"/>
 	</classfileset>
 	<mkdir dir='${build.lib.dir}' />
 	<jar destfile='${build.lib.dir}/xercesMinimal.jar'>
 		<fileset refid='minimal.classes' />
 		<exclude name='org/cyberneko/**' />
	</jar>
 </target>
 
 <target name='minimal-init' unless='bcel.available'>
 	<fail>
 	!!! REQUIRED FILES MISSING !!!
 	
 	Please install the BCEL jars into the lib/ directory. 
 	</fail>
</target>
 
	<target name='clean'>
		<delete dir='${build.dir}' />
	</target>

	<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
	 <target name='compile.test' depends="compile" description="compiles the test classes">
	  <mkdir dir="${build.test-classes.dir}"/>
	  <javac destdir='${build.test-classes.dir}' debug='true' encoding="ISO-8859-1" 
	  		 source='${compile.source}' target='${compile.target}'
	  		 includeAntRuntime='true'>
	  	<classpath>
	  		<fileset dir='${lib.dir}' includes='xml-apis.jar,xerces*.jar, junit*.jar' />
		    <pathelement location='${build.classes.dir}' />
	  	</classpath>
	    <src path='${src.test.dir}' />
	  </javac>
	 </target>

	<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
	<macrodef name="testWith" description="run the tests for the specified Xerces version">
		<attribute name="xercesVersion" description="the name of the /lib subfolder containing Xerces"/>
		<sequential>
			<echo message="Testing with Xerces-@{xercesVersion}"/>
			<mkdir dir="${build.dir}/junit/xerces-@{xercesVersion}"/>
			<!-- 
			We have to fork and can't use Ant to be sure that the Xerces version 
			we specify and not an other one (for instance the one of Ant)
			-->
			<junit printsummary="yes" haltonfailure="false" fork="true" failureproperty="junitFailed">
				<classpath>
				    <pathelement path='${build.test-classes.dir}'/>
				    <pathelement location='${build.classes.dir}' />
			  		<fileset dir='${lib.dir}' includes='junit*.jar' />
		  	  		<fileset dir='${lib.dir}/xerces-@{xercesVersion}' includes='*.jar' />
				</classpath>
	
				<formatter type="xml"/>
	
				<batchtest fork="yes" todir="${build.dir}/junit/xerces-@{xercesVersion}">
					<fileset dir="${src.test.dir}">
						<include name="**/*Test.java"/>
					</fileset>
				</batchtest>
			</junit>
		</sequential>
	</macrodef>

	<target name="test" depends="compile, compile.test" description="Runs the junit tests and generates a report (junit jar must be in ANT_HOME/lib)">
		<delete dir="${build.dir}/junit"/>
		<mkdir dir="${build.dir}/junit"/>

		<testWith xercesVersion="2.10.0"/>
		<testWith xercesVersion="2.9.1"/>
		<testWith xercesVersion="2.8.1"/>
		<testWith xercesVersion="2.3.0"/>
		<testWith xercesVersion="2.2.1"/>
		<testWith xercesVersion="minimal"/>
		<!--
		<testWith xercesVersion="2.1.0"/>
		<testWith xercesVersion="2.0.2"/>
		-->

		<junitreport todir="${build.dir}/junit">
			<fileset dir="${build.dir}/junit">
				<include name="**/TEST-*.xml"/>
			</fileset>
			<report format="frames" todir="${build.dir}/junit"/>
		</junitreport>
		<echo message="Report has been generated to ${build.dir}/junit/index.html"/>
		<fail message="JUnit test failed" if="junitFailed"/>
	</target>
	
	<target name="deploy-mvn" depends="mvn-bundle" description="Deploys a release to NekoHTML maven repository">
		<!-- sign and deploy the main artifact -->
		<artifact:mvn>
			<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file" />
			<arg value="-Durl=${maven-staging-repository-url}" />
			<arg value="-DrepositoryId=${maven-staging-repository-id}" />
			<arg value="-DpomFile=pom.xml" />
			<arg value="-Dfile=${jar.file}" />
            <arg value="-Pgpg" />
		</artifact:mvn>

		<!-- sign and deploy the sources artifact -->
		<artifact:mvn>
			<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file" />
			<arg value="-Durl=${maven-staging-repository-url}" />
			<arg value="-DrepositoryId=${maven-staging-repository-id}" />
			<arg value="-DpomFile=pom.xml" />
			<arg value="-Dfile=${build.dir}/dist/nekohtml-${version}-sources.jar" />
			<arg value="-Dclassifier=sources" />
            <arg value="-Pgpg" />
		</artifact:mvn>

		<!-- sign and deploy the javadoc artifact -->
		<artifact:mvn>
			<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file" />
			<arg value="-Durl=${maven-staging-repository-url}" />
			<arg value="-DrepositoryId=${maven-staging-repository-id}" />
			<arg value="-DpomFile=pom.xml" />
			<arg value="-Dfile=${build.dir}/dist/nekohtml-${version}-javadoc.jar" />
			<arg value="-Dclassifier=javadoc" />
            <arg value="-Pgpg" />
		</artifact:mvn>
	</target>

	<target name="mvn-deploy-oss.sonatype" depends="-defineMavenAntTasks, mvn-bundle" description="Deploys a snapshot to Sonatype snapshot repository">
		<artifact:mvn>
			<arg value="org.apache.maven.plugins:maven-deploy-plugin:2.6:deploy-file" />
			<arg value="-Durl=${maven-snapshots-repository-url}" />
			<arg value="-DrepositoryId=${maven-snapshots-repository-id}" />
			<arg value="-DpomFile=pom.xml" />
			<arg value="-Dfile=${jar.file}" />
		</artifact:mvn>
	</target>
	
	<target name="mvn-bundle" depends="jar, doc, -defineMavenAntTasks">
		<property name="mvn.bundle.sources" value="${build.dir}/dist/nekohtml-${version}-sources.jar"/>
		<property name="mvn.bundle.javadoc" value="${build.dir}/dist/nekohtml-${version}-javadoc.jar"/>
		<mkdir dir="${build.dir}/dist"/>
	 	<jar destfile="${mvn.bundle.javadoc}">
	 		<fileset dir="${build.doc.dir}"/>
		</jar>
	 	<jar destfile="${mvn.bundle.sources}">
		    <fileset dir='${src.dir}' />
		    <fileset dir='${build.src.dir}' />
		</jar>
	</target>

	<target name="-defineMavenAntTasks">
		<path id="maven-ant-tasks.classpath" path="lib/maven-ant-tasks-2.1.3.jar" />
		<typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="urn:maven-artifact-ant"
			classpathref="maven-ant-tasks.classpath" />
		<artifact:pom id="maven.project" file="pom.xml" />
	</target>
	
	<target name="deploy-mvn-local" depends="mvn-bundle" description="Deploys jars to a local folder">
		<property name="deploy-mvn-local.dir" location="${build.dir}/dist/m2-repo"/>
		<echo message="Deploying locally to ${deploy-mvn-local.dir}"/>
		<mkdir dir="${deploy-mvn-local.dir}"/>
		<artifact:deploy file="${build.lib.dir}/${name}.jar">
			<remoteRepository url="file://${deploy-mvn-local.dir}"/>
			<pom refid="maven.project"/>
			<attach file="${mvn.bundle.sources}" classifier="sources" /> 
			<attach file="${mvn.bundle.javadoc}" classifier="javadoc" /> 
			<localrepository path="${build.dir}/mvn"/>
		</artifact:deploy>
	</target>
	
</project>