source: other-projects/trunk/anttasks/build.xml@ 20047

Last change on this file since 20047 was 20047, checked in by oranfry, 15 years ago

the deletechunkfromfile task now supports start and end tags on the same line, with content in between

File size: 4.7 KB
Line 
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 <jar
18 destfile="anttasks.jar"
19 basedir="classes"/>
20
21 </target>
22
23 <target name="clean">
24 <delete dir="classes"/>
25 <delete file="anttasks.jar"/>
26 </target>
27
28 <target name="check-libs" unless="libs.set">
29 <echo>Please set crypt.jar property to the path of the crypt.jar file</echo>
30 <echo>E.g., ant -Dcrypt.jar=/path/to/crypt.jar</echo>
31 <fail>paths to libs not set</fail>
32 </target>
33
34 <target name="test-setup">
35 <path id="test.classpath">
36 <pathelement path="anttasks.jar"/>
37 <pathelement path="${crypt.jar}"/>
38 </path>
39 <typedef name="dcff" classname="org.greenstone.anttasks.DeleteChunkFromFile" classpathref="test.classpath"/>
40 <typedef name="rsr" classname="org.greenstone.anttasks.RegexSearchReplace" classpathref="test.classpath"/>
41 <typedef name="gpv" classname="org.greenstone.anttasks.GetPropertyValue" classpathref="test.classpath"/>
42 <typedef name="sevenzip" classname="org.greenstone.anttasks.WindowsSevenZipWrapper" classpathref="test.classpath"/>
43 <mkdir dir="test"/>
44 </target>
45
46 <target name="test" depends="test-setup">
47 <antcall target="test-rsr"/>
48 <antcall target="test-dcff"/>
49 <antcall target="test-gpv"/>
50 </target>
51
52 <target name="test-rsr" depends="test-setup">
53
54 <!-- test 1 -->
55 <copy file="src/test/rsr.txt" tofile="test/rsr1.txt"/>
56 <rsr file="test/rsr1.txt" pattern="things" replacement="strings"/>
57
58 <!-- test 2 -->
59 <copy file="src/test/rsr.txt" tofile="test/rsr2.txt"/>
60 <rsr file="test/rsr2.txt">
61 <job pattern="things" replacement="objects"/>
62 <job pattern="Or" replacement="And"/>
63 </rsr>
64
65 <!-- test 3 -->
66 <copy file="src/test/rsr.txt" tofile="test/rsr3.txt"/>
67 <rsr file="test/rsr3.txt" pattern="@path@" replacement="C:\Program Files\Greenstone 2.80"/>
68 <rsr file="test/rsr3.txt" pattern="@path-with-winpath@" replacement="C:\Program Files\Greenstone 2.80" winPath="true"/>
69
70 <!-- test 4 -->
71 <copy file="src/test/rsr.txt" tofile="test/rsr4.txt"/>
72 <rsr file="test/rsr4.txt">
73 <job pattern="@path@" replacement="C:\Program Files\Greenstone 2.80"/>
74 <job pattern="@path-with-winpath@" replacement="C:\Program Files\Greenstone 2.80" winPath="true"/>
75 </rsr>
76
77 <!-- test 5 -->
78 <copy file="src/test/rsr.txt" tofile="test/rsr5-1.txt"/>
79 <copy file="src/test/rsr.txt" tofile="test/rsr5-2.txt"/>
80 <rsr>
81 <fileset dir="test" includes="rsr5-*"/>
82 <job pattern="@path@" replacement="C:\Program Files\Greenstone 2.80"/>
83 <job pattern="@path-with-winpath@" replacement="C:\Program Files\Greenstone 2.80" winPath="true"/>
84 </rsr>
85
86 <!-- test 6 -->
87 <copy file="src/test/rsr.txt" tofile="test/rsr6-1.txt"/>
88 <copy file="src/test/rsr.txt" tofile="test/rsr6-2.txt"/>
89 <copy file="src/test/rsr.txt" tofile="test/rsr6-3.txt"/>
90 <copy file="src/test/rsr.txt" tofile="test/rsr6-4.txt"/>
91 <rsr file="test/rsr6-1.txt" pattern="e" replacement="*" lines="8"/>
92 <rsr file="test/rsr6-2.txt" pattern="e" replacement="*" lines="4-9"/>
93 <rsr file="test/rsr6-3.txt" pattern="e" replacement="*" lines="-8"/>
94 <rsr file="test/rsr6-4.txt" pattern="e" replacement="*" lines="4-"/>
95
96 </target>
97
98 <target name="test-dcff" depends="test-setup">
99
100 <!-- test 1 -->
101 <copy file="src/test/dcff.txt" tofile="test/dcff1.txt"/>
102 <dcff file="test/dcff1.txt" startTag="The" endTag="brown" leaveTags="true"/>
103
104 <!-- test 2 -->
105 <copy file="src/test/dcff.txt" tofile="test/dcff2.txt"/>
106 <dcff file="test/dcff2.txt" startTag="quick" endTag="brown"/>
107
108 <!-- test 3 -->
109 <copy file="src/test/dcff.txt" tofile="test/dcff3.txt"/>
110 <dcff file="test/dcff3.txt" startTag="fox" leaveTags="true"/>
111
112 <!-- test 4 -->
113 <copy file="src/test/dcff.txt" tofile="test/dcff4.txt"/>
114 <dcff file="test/dcff4.txt" startTag="&lt;!--start--&gt;" endTag="&lt;!--end--&gt;"/>
115
116 </target>
117
118 <target name="test-gpv" depends="test-setup">
119
120 <!-- test 1 -->
121 <gpv propertiesFile="src/test/gpv.txt" propertyName="startmenu.path" outputProperty="gpv.startmenu.path"/>
122 <echo>startmenu.path = '${gpv.startmenu.path}'</echo>
123
124 <gpv propertiesFile="src/test/gpv.txt" propertyName="my.second.property" outputProperty="gpv.my.second.property"/>
125 <echo>my.second.property = '${gpv.my.second.property}'</echo>
126
127
128 </target>
129
130 <target name="test-win-sevenzip" depends="test-setup">
131
132 <!-- test 1 -->
133 <copy file="src/test/sevenzip.lzma" tofile="test/sevenzip1.lzma"/>
134 <sevenzip task="decode" input="test/sevenzip1.lzma" output="test/sevenzip1.comp"/>
135
136 </target>
137
138 <target name="test-clean">
139 <delete dir="test"/>
140 </target>
141
142</project>
Note: See TracBrowser for help on using the repository browser.