ref github page
[restunit.git] / build.xml
blob27a9aaba48e3963b529d9f13fefe3c5e4b6b65e2
1 <project name="restunit" default="compile" basedir=".">
3     <property environment="env" />
4     <property file="build.properties" />
6     <!-- PATHS -->
8     <path id="compile.classpath">
9         <fileset dir="${rt.lib.dir}"> <include name="*.jar"/> </fileset>
10         <fileset dir="${test.lib.dir}"> <include name="*.jar"/> </fileset>
11     </path>
13     <path id="test.compile.classpath">
14         <path refid="compile.classpath" />
15         <pathelement location="${classes.dir}" />
16     </path>
18     <path id="test.classpath">
19         <path refid="test.compile.classpath" />
20         <pathelement location="${test.classes.dir}" />
21     </path>
23     <!-- TASKDEFS -->
25     <taskdef resource="checkstyletask.properties"
26         classpath="${test.lib.dir}/checkstyle-all-4.4.jar" />
28     <taskdef name="testng" 
29         classpathref="compile.classpath"
30         classname="org.testng.TestNGAntTask" />
32     <!-- TARGETS -->
34     <target name="test" depends="checkstyle,deploy.test.war"
35         description="Runs tests">
36         <delete file="${testng.failed.xml}" />
37         <testng
38             sourcedir="${test.java.src.dir}"
39             classpathref="test.classpath"
40             parallel="tests"
41             threadCount="10"
42             outputdir="${test.output.dir}"
43             >
44             <jvmarg value="-Djava.util.logging.config.file=${conf.dir}/jdk.logging.properties" />
45             <classfileset dir="${test.classes.dir}" />
46         </testng>
47         <ant target="stop.winstone" />
48     </target>
50     <target name="test.failed" 
51         description="Runs Failed Tests"
52         depends="compile.test,deploy.test.war">
53         <testng
54             sourcedir="${test.java.src.dir}"
55             classpathref="test.classpath"
56             outputdir="${test.output.dir}"
57             >
58             <xmlfileset dir="${test.output.dir}" includes="testng-failed.xml"/>
59             <jvmarg value="-Djava.util.logging.config.file=${conf.dir}/jdk.logging.properties" />
60         </testng>
61         <ant target="stop.winstone" />
62     </target>
64     <target name="compile" 
65         description="Compiles all code">
66         <mkdir dir="${classes.dir}" />
67         <depend srcdir="${java.src.dir}"
68             destdir="${classes.dir}"
69             cache="${build.dir}/depcache"
70             closure="yes"/>
71         <javac destdir="${classes.dir}"
72             classpathref="compile.classpath"
73             debug="on">
74             <src path="${java.src.dir}"/>
75             <compilerarg line="-Xlint -Xlint:-serial -Xlint:-path" />
76         </javac>
77         <copy todir="${classes.dir}" file="${conf.dir}/log4j.properties" />
78     </target>
80     <target name="clean"
81         description="Remove all generated targets">
82         <delete dir="${build.dir}" />
83     </target>
85     <target name="javadoc"
86         description="Generates Javadoc"
87         >
88         <javadoc sourcepath="${java.src.dir}"
89             destdir="${javadoc.dir}"
90             classpathref="compile.classpath">
91             <link href="http://java.sun.com/j2se/1.5/docs/api/" />
92             <link href="http://java.sun.com/javaee/5/docs/api/" />
93             <link href="http://logging.apache.org/log4j/1.2/apidocs/" />
94             <link href="http://commons.apache.org/logging/apidocs/" />
95         </javadoc>
96     </target>
98     <target name="publish.javadoc" depends="javadoc"
99         description="Publishes javadoc to naildrivin5.com">
100         <scp verbose="true" sftp="true"
101             todir="davec@www.naildrivin5.com:/home/webadmin/naildrivin5.com/html/restunit/javadoc/" keyfile="/Users/davec/.ssh/id_dsa" passphrase="">
102             <fileset dir="${javadoc.dir}" />
103         </scp>
104     </target>
106     <!-- SUB TARGETS -->
108     <!-- compiles test code -->
109     <target name="compile.test" depends="compile">
110         <mkdir dir="${test.classes.dir}" />
111         <depend srcdir="${test.java.src.dir}"
112             destdir="${test.classes.dir}"
113             cache="${build.dir}/depcache"
114             closure="yes"/>
115         <javac destdir="${test.classes.dir}"
116             classpathref="test.compile.classpath"
117             debug="on">
118             <src path="${test.java.src.dir}"/>
119             <compilerarg line="-Xlint -Xlint:-serial -Xlint:-path" />
120         </javac>
121     </target>
123     <target name="checkstyle" depends="compile"
124         >
125         <checkstyle 
126             config="${conf.dir}/checkstyle.xml"
127             classpathref="compile.classpath"
128             >
129             <property key="checkstyle.header.file" value="${conf.dir}/java.header" />
130             <fileset dir="${java.src.dir}" includes="**/*.java" />
131         </checkstyle>
132     </target>
134     <target name="test.war" depends="compile.test">
135         <copy tofile="${build.dir}/log4j.properties" file="${conf.dir}/servlet.log4j.properties" />
136         <war
137             destfile="${test.war}"
138             update="yes"
139             duplicate="fail"
140             webxml="${test.java.src.dir}/com/gliffy/test/restunit/servlet/web.xml">
141             <lib dir="${rt.lib.dir}" />
142             <classes dir="${test.classes.dir}">
143                 <include name="**/*.class" />
144             </classes>
145             <classes dir="${build.dir}">
146                 <include name="log4j.properties" />
147             </classes>
148         </war>
149     </target>
151     <!-- deploy the test war and start Winstone -->
152     <target name="deploy.test.war" depends="test.war">
153         <java jar="${test.lib.dir}/winstone-0.9.10.jar"
154             fork="true"
155             spawn="true" >
156             <arg line="--warfile=${test.war} --logfile=winstone.log --httpPort=${winstone.httpPort} --controlPort=${winstone.controlPort} -ajp13Port=-1" />
157         </java>
158         <sleep seconds="1" />
159     </target>
161     <!-- Stop the winstone servlet container -->
162     <target name="stop.winstone">
163         <echo message="Stopping Winstone servlet container" />
164         <java classname="winstone.tools.WinstoneControl" classpath="${test.lib.dir}/winstone-0.9.10.jar">
165             <arg line="shutdown --host=localhost --controlPort=${winstone.controlPort}" />
166         </java>
167     </target>
169 </project>