-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.xml
363 lines (309 loc) · 15.1 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
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
<?xml version="1.0"?>
<project name="yarep" default="usage"
xmlns:artifact="antlib:org.apache.maven.artifact.ant"
xmlns:wyona-tools="http://www.wyona.org/tools/1.0"
xmlns:svnant="antlib:org.tigris.subversion.svnant"
>
<import file="tools/apache-ant_extras/artifacts.build.xml"/>
<import file="dependencies.xml"/>
<target name="usage" description="How to see all the targets">
<echo>USAGE: ant -projecthelp</echo>
<echo>NOTE: Read the README.txt</echo>
</target>
<!-- Init all parameters and other settings. -->
<target name="init" depends="dependencies">
<property file="local.build.properties"/>
<property file="build.properties"/>
<property name="source.home" value="${basedir}"/>
<property name="classes.dir" value="${build.dir}/classes"/>
<path id="classpath.core">
<fileset dir="lib">
<include name="*.jar"/>
</fileset>
<pathelement path="${maven2.cp}"/>
</path>
<path id="classpath.impl">
<fileset dir="lib">
<include name="*.jar"/>
</fileset>
<pathelement path="${classes.dir}"/>
<pathelement path="${maven2.cp}"/>
</path>
<path id="classpath.examples">
<fileset dir="lib">
<include name="*.jar"/>
</fileset>
<pathelement path="${classes.dir}"/>
<pathelement path="${maven2.cp}"/>
</path>
<path id="classpath.run">
<fileset dir="lib">
<include name="*.jar"/>
</fileset>
<pathelement path="${classes.dir}"/>
<pathelement path="lib"/> <!-- log4j.properties and log4j2.xml -->
<pathelement path="build/repository"/> <!-- repository configs -->
<pathelement path="${maven2.cp}"/>
</path>
</target>
<target name="compile-core" description="Compile Java classes" depends="init">
<echo>INFO: Compiling with Java version ${ant.java.version} and building with Ant version ${ant.version}</echo>
<echo>${classes.dir}</echo>
<mkdir dir="${classes.dir}"/>
<javac srcdir="src/core" destdir="${classes.dir}"
classpathref="classpath.core"
debug="true"
source="${source.java.version}"
target="${target.java.version}"
/>
</target>
<target name="compile-impl" description="Compile Java classes of Implementation" depends="init">
<echo>${classes.dir}</echo>
<mkdir dir="${classes.dir}"/>
<javac srcdir="src/impl" destdir="${classes.dir}"
classpathref="classpath.impl"
debug="true"
/>
</target>
<target name="compile-examples" description="Compile Java classes of examples" depends="init,compile-core, compile-impl">
<echo>${classes.dir}</echo>
<mkdir dir="${classes.dir}"/>
<javac srcdir="src/test" destdir="${classes.dir}"
classpathref="classpath.examples"
debug="true"
source="${source.java.version}"
target="${target.java.version}"
/>
<copy file="src/test/java/yarep.properties" todir="${classes.dir}"/>
</target>
<target name="eclipse:classpath" description="Update Eclipse's .classpath file" depends="init">
<ant dir="${source.home}/tools/eclipse.settings" target="update-classpath"
inheritAll="false" inheritRefs="false">
<reference torefid="classpath.ref" refid="classpath.core"/>
<property name="classpath.dir" value="${source.home}"/>
<property name="classes.dir" value=""/>
<property name="source.dirs" value="src/core/java:src/impl/java:src/test/java"/>
</ant>
</target>
<target name="eclipse" description="Generate all files needed to use the project under Eclipse (WARNING: .project file will be overwritten!)" depends="eclipse:classpath">
<copy file="${source.home}/tools/eclipse.settings/Eclipse-3.template.project" tofile="${source.home}/.project">
<filterset>
<filter token="PROJECT_NAME" value="Wyona Yarep"/>
<filter token="PROJECT_VERSION" value="${yarep.version}-r${subversion.revision}"/>
<filter token="GENERATION_COMMAND" value="build eclipse"/>
</filterset>
</copy>
<echo>Eclipse project created: in Eclipse you can now import (as an existing project into your workspace) this project with root directory set to ${source.home} and build it there!</echo>
</target>
<target name="build-examples" description="Build examples" depends="init,compile-examples,compile-impl">
<copy todir="${build.dir}/repository">
<fileset dir="src/test/repository"/>
</copy>
<mkdir dir="build/lib"/>
</target>
<target name="jar" description="Create jar files for core and impl" depends="init,compile-core,compile-impl">
<mkdir dir="build/lib"/>
<jar
destfile="build/lib/yarep-core-${yarep.version}-r${subversion.revision}.jar"
basedir="build/classes"
excludes="org/wyona/yarep/examples/**,org/wyona/yarep/tests/**,org/wyona/yarep/impl/**,org/wyona/yarep/core/impl/**,yarep.properties"
>
<!--
<manifest>
<attribute name="main-class" value="org.wyona.yarep.examples.HelloWorld"/>
</manifest>
-->
</jar>
<jar
destfile="build/lib/yarep-impl-${yarep.version}-r${subversion.revision}.jar"
basedir="build/classes"
includes="org/wyona/yarep/impl/**,org/wyona/yarep/core/impl/**"
>
<!--
<manifest>
<attribute name="main-class" value="org.wyona.yarep.examples.HelloWorld"/>
</manifest>
-->
</jar>
</target>
<!-- USAGE: java -jar build/lib/yarep-all-1.0-dev-r912fe112fc45468536afb6f6b4b27ddbfdc3d4a1.jar /home/USER/data-repository.xml -->
<target name="jar-all" description="Create one jar file containing all classes (core, impl, etc.)" depends="init,compile-core,compile-impl,compile-tools">
<mkdir dir="build/lib"/>
<mkdir dir="build/dependencies"/>
<copy todir="build/dependencies">
<fileset refid="maven2.fileset"/>
<mapper type="flatten"/>
</copy>
<copy file="lib/log4j.properties" todir="build/classes"/>
<jar
destfile="build/lib/yarep-all-${yarep.version}-r${subversion.revision}.jar"
basedir="build/classes"
excludes="yarep.properties"
>
<zipgroupfileset dir="build/dependencies" includes="*.jar"/>
<manifest>
<attribute name="main-class" value="org.wyona.yarep.tools.cmdl.CleanIndex"/>
</manifest>
</jar>
<delete file="build/classes/log4j.properties"/>
</target>
<target name="install-jars" description="Place jar files for core and impl into local maven repository" depends="clean, init, jar, patch-pom-files">
<artifact:pom id="maven.project.core" file="build/lib/pom-core.xml"/>
<artifact:install file="build/lib/yarep-core-${yarep.version}-r${subversion.revision}.jar">
<pom refid="maven.project.core"/>
</artifact:install>
<artifact:pom id="maven.project.impl" file="build/lib/pom-impl.xml"/>
<artifact:install file="build/lib/yarep-impl-${yarep.version}-r${subversion.revision}.jar">
<pom refid="maven.project.impl"/>
</artifact:install>
</target>
<!-- Install Yarep core JAR. Hidden because it's still a bit HACKy but please keep it as it's used to produce source JARs for debugging. -->
<target name="install-core-jar" depends="compile-core">
<wyona-tools:install-jar source-home="." name="yarep-core" version="${yarep.version}-r${subversion.revision}" package-root-path="org/wyona/yarep" id="core">
<!--HACK: both source and binary JARs will get these: -->
<fileset dir="./src/core" includes="org/wyona/yarep/core/**" excludes="org/wyona/yarep/core/impl/**"/>
<fileset dir="${classes.dir}" includes="org/wyona/yarep/core/**" excludes="org/wyona/yarep/core/impl/**"/>
<fileset dir="./src/core" includes="org/wyona/yarep/util/**"/>
<fileset dir="${classes.dir}" includes="org/wyona/yarep/util/**"/>
</wyona-tools:install-jar>
</target>
<!-- Install Yarep implementation JAR. Hidden because it's still a bit HACKy but please keep it as it's used to produce source JARs for debugging. -->
<target name="install-impl-jar" depends="compile-impl">
<wyona-tools:install-jar source-home="." name="yarep-impl" version="${yarep.version}-r${subversion.revision}" package-root-path="org/wyona/yarep" id="impl">
<!--HACK: both source and binary JARs will get these: -->
<fileset dir="./src/core" includes="org/wyona/yarep/core/impl/**"/>
<fileset dir="${classes.dir}" includes="org/wyona/yarep/core/impl/**"/>
</wyona-tools:install-jar>
</target>
<target name="deploy-jars" description="Upload jar files for core and impl into remote maven repository" depends="clean, init, jar, patch-pom-files">
<!-- TODO: SVN export first and deploy from within this export!
<target name="deploy-jars" description="Upload jar files for core and impl into remote maven repository" depends="clean, init, svn-export, jar, patch-pom-files">
-->
<!-- <artifact:install-provider artifactId="wagon-ssh" version="1.0-beta-2"/> -->
<artifact:install-provider artifactId="wagon-ssh" version="1.0-alpha-7"/>
<echo>deploying to ${repository.url}</echo>
<artifact:pom id="maven.project.core" file="build/lib/pom-core.xml"/>
<artifact:deploy file="build/lib/yarep-core-${yarep.version}-r${subversion.revision}.jar">
<remoteRepository url="${repository.url}">
<authentication username="${repository.username}" password="${repository.password}"/>
<!--
<authentication username="${repository.username}" privateKey="${user.home}/.ssh/id_dsa"/>
-->
</remoteRepository>
<pom refid="maven.project.core"/>
</artifact:deploy>
<artifact:pom id="maven.project.impl" file="build/lib/pom-impl.xml"/>
<artifact:deploy file="build/lib/yarep-impl-${yarep.version}-r${subversion.revision}.jar">
<remoteRepository url="${repository.url}">
<authentication username="${repository.username}" password="${repository.password}"/>
<!--
<authentication username="${repository.username}" privateKey="${user.home}/.ssh/id_dsa"/>
-->
</remoteRepository>
<pom refid="maven.project.impl"/>
</artifact:deploy>
</target>
<target name="git-clone" description="Git clone master branch" depends="init">
<echo>Start cloning source from Git, revision: ${subversion.revision}</echo>
<exec executable="git">
<arg value="clone"/>
<arg value="https://github.com/wyona/yarep.git"/>
<arg value="${build.dir}/git-clone-master-r${subversion.revision}"/>
</exec>
</target>
<target name="svn-export" description="Export a particular revision of SVN trunk" depends="init">
<echo>Start exporting source from SVN, revision: ${subversion.revision}</echo>
<exec executable="svn">
<arg value="export"/>
<arg value="-r${subversion.revision}"/>
<arg value="http://svn.wyona.com/repos/public/yarep/trunk"/>
<arg value="${build.dir}/svn-export-trunk-r${subversion.revision}"/>
</exec>
<!--
<svnant:svn username="anonymous" password="anonymous">
<export
revision="${subversion.revision}"
srcUrl="http://svn.wyona.com/repos/public/yarep/trunk"
destPath="${build.dir}/svn-export-trunk-r${subversion.revision}"
/>
</svnant:svn>
-->
</target>
<target name="patch-pom-files" depends="init">
<copy file="src/core/pom.xml" tofile="build/lib/pom-core.xml"/>
<replace file="build/lib/pom-core.xml" value="${yarep.version}-r${subversion.revision}">
<replacetoken>@VERSION@</replacetoken>
</replace>
<copy file="src/impl/pom.xml" tofile="build/lib/pom-impl.xml"/>
<replace file="build/lib/pom-impl.xml" value="${yarep.version}-r${subversion.revision}">
<replacetoken>@VERSION@</replacetoken>
</replace>
</target>
<target name="clean" description="Clean Build" depends="init">
<delete dir="${build.dir}"/>
</target>
<!-- USAGE: Run ./build.sh run-clean-index -Drepository-config=/home/USER/data-repository.xml -->
<target name="run-clean-index" description="Run Clean Index Utility" depends="init, compile-tools">
<java classname="org.wyona.yarep.tools.cmdl.CleanIndex">
<classpath refid="classpath.run"/>
<arg value="${repository-config}"/>
<arg value="false"/> <!-- INFO: If set to false, then documents inside index will NOT be deleted although these might not exist inside repository -->
<arg value="5"/> <!-- INFO: If set to '-1', then there is no limit -->
</java>
</target>
<target name="run-examples" description="Run Example" depends="init, build-examples">
<java classname="org.wyona.yarep.examples.HelloWorld">
<!--
<java classname="org.wyona.yarep.examples.TestVirtualFileSystemRepository">
-->
<classpath refid="classpath.run"/>
</java>
</target>
<!-- INFO: The test target executes all tests in the test directory, or alternatively it executes a single test which is specified by the 'test.class.name' property, e.g. './build.sh test -Dtest.class.name=org.wyona.yarep.tests.VirtualFilesystemRevisionsTest' -->
<target name="test" description="Run all tests or a particular test using the property 'test.class.name'" depends="clean, init, build-examples">
<mkdir dir="build/log"/>
<junit fork="yes" printsummary="yes" haltonfailure="no" showoutput="yes" failureproperty="tests.failed">
<formatter type="plain" usefile="false" />
<formatter type="xml"/>
<classpath refid="classpath.run" />
<!-- Execute all tests if property test.class.name has not been specified -->
<batchtest todir="build/log" unless="test.class.name">
<fileset dir="${classes.dir}" includes="**/*Test.class" excludes="**/Abstract*.class"/>
</batchtest>
<!-- Execute a particular test -->
<test todir="build/log" name="${test.class.name}" if="test.class.name"/>
</junit>
<fail if="tests.failed" message="One or more junit tests failed. Please check the log (build/log)."/>
</target>
<target name="javadoc" description="Generate Javadoc" depends="init">
<javadoc
packagenames="org.*"
sourcepath="src/core/java"
destdir="build/javadoc"
>
</javadoc>
</target>
<target name="compile-tools" description="Build tools" depends="compile-examples, compile-impl">
<javac srcdir="src/tools/java" destdir="${classes.dir}"
classpathref="classpath.impl"
debug="true"
source="${source.java.version}"
target="${target.java.version}"
/>
</target>
<target name="copy-repository" description="Copy repository" depends="init">
<!-- <taskdef name="copyrepository" classpath="${classes.dir}" classname="org.wyona.yarep.tools.ant.CopyRepositoryTask"/> -->
<taskdef name="copyrepository" classpathref="classpath.run" classname="org.wyona.yarep.tools.ant.CopyRepositoryTask"/>
<copyrepository
srcrepoconfigpath="${copy.src.repo.config}"
destrepoconfigpath="${copy.dest.repo.config}"
/>
</target>
<target name="index-repository" description="Index repository" depends="init">
<!-- <taskdef name="indexrepository" classpath="${classes.dir}" classname="org.wyona.yarep.tools.ant.IndexRepositoryTask"/> -->
<taskdef name="indexrepository" classpathref="classpath.run" classname="org.wyona.yarep.tools.ant.IndexRepositoryTask"/>
<indexrepository
repoconfigpath="${repo.config}"
/>
</target>
</project>