1 | <project name="compile-ant-tasks" default="compile">
|
---|
2 |
|
---|
3 | <condition property="libs.set">
|
---|
4 | <and>
|
---|
5 | <isset property="crypt.jar"/>
|
---|
6 | </and>
|
---|
7 | </condition>
|
---|
8 |
|
---|
9 | <target name="compile" depends="check-libs">
|
---|
10 |
|
---|
11 | <mkdir dir="classes"/>
|
---|
12 | <javac
|
---|
13 | srcdir="src/org/greenstone/anttasks"
|
---|
14 | destdir="classes"
|
---|
15 | classpath="${crypt.jar}"/>
|
---|
16 |
|
---|
17 | <mkdir dir="lib"/>
|
---|
18 | <jar
|
---|
19 | destfile="lib/anttasks.jar"
|
---|
20 | basedir="classes"/>
|
---|
21 |
|
---|
22 | </target>
|
---|
23 |
|
---|
24 | <target name="clean">
|
---|
25 | <delete dir="classes"/>
|
---|
26 | <delete dir="lib"/>
|
---|
27 | </target>
|
---|
28 |
|
---|
29 | <target name="check-libs" unless="libs.set">
|
---|
30 | <echo>Please set crypt.jar property to the path of the crypt.jar file</echo>
|
---|
31 | <echo>E.g., ant -Dcrypt.jar=/path/to/crypt.jar</echo>
|
---|
32 | <fail>paths to libs not set</fail>
|
---|
33 | </target>
|
---|
34 |
|
---|
35 | <target name="test-setup">
|
---|
36 | <path id="test.classpath">
|
---|
37 | <pathelement path="lib/anttasks.jar"/>
|
---|
38 | <pathelement path="${crypt.jar}"/>
|
---|
39 | </path>
|
---|
40 | <typedef name="dcff" classname="org.greenstone.anttasks.DeleteChunkFromFile" classpathref="test.classpath"/>
|
---|
41 | <typedef name="rsr" classname="org.greenstone.anttasks.RegexSearchReplace" classpathref="test.classpath"/>
|
---|
42 | <mkdir dir="test"/>
|
---|
43 | </target>
|
---|
44 |
|
---|
45 | <target name="test" depends="test-setup">
|
---|
46 | <antcall target="test-rsr"/>
|
---|
47 | </target>
|
---|
48 |
|
---|
49 | <target name="test-rsr" depends="test-setup">
|
---|
50 |
|
---|
51 | <echo file="test/rsr1.txt">This is a test of the rsr task
|
---|
52 | To see if it can replace things with other things
|
---|
53 | Or if those things
|
---|
54 | Stay the same things
|
---|
55 |
|
---|
56 | Or not
|
---|
57 |
|
---|
58 | Replace with a path
|
---|
59 | @path@
|
---|
60 |
|
---|
61 | Replace with a path, with winPath on
|
---|
62 | @path-with-winpath@
|
---|
63 |
|
---|
64 |
|
---|
65 | </echo>
|
---|
66 | <copy file="test/rsr1.txt" tofile="test/rsr2.txt"/>
|
---|
67 | <copy file="test/rsr1.txt" tofile="test/rsr3.txt"/>
|
---|
68 | <copy file="test/rsr1.txt" tofile="test/rsr4.txt"/>
|
---|
69 |
|
---|
70 | <rsr file="test/rsr1.txt" pattern="things" replacement="strings"/>
|
---|
71 |
|
---|
72 | <rsr file="test/rsr2.txt">
|
---|
73 | <job pattern="things" replacement="objects"/>
|
---|
74 | <job pattern="Or" replacement="And"/>
|
---|
75 | </rsr>
|
---|
76 |
|
---|
77 | <rsr file="test/rsr3.txt" pattern="@path@" replacement="C:\Program Files\Greenstone 2.80"/>
|
---|
78 | <rsr file="test/rsr3.txt" pattern="@path-with-winpath@" replacement="C:\Program Files\Greenstone 2.80" winPath="true"/>
|
---|
79 |
|
---|
80 | <rsr file="test/rsr4.txt">
|
---|
81 | <job pattern="@path@" replacement="C:\Program Files\Greenstone 2.80"/>
|
---|
82 | <job pattern="@path-with-winpath@" replacement="C:\Program Files\Greenstone 2.80" winPath="true"/>
|
---|
83 | </rsr>
|
---|
84 |
|
---|
85 | </target>
|
---|
86 |
|
---|
87 | <target name="test-clean">
|
---|
88 | <delete dir="test"/>
|
---|
89 | </target>
|
---|
90 |
|
---|
91 |
|
---|
92 |
|
---|
93 |
|
---|
94 |
|
---|
95 |
|
---|
96 | </project>
|
---|