root/trunk/dailybuild.xml

Revision 55, 8.9 kB (checked in by jdalbey, 1 year ago)

fix dailybuild to put test classes in same build folder.

Line 
1 <!-- =================================================================== -->
2 <!--     Daily Build script                                              -->
3 <!-- =================================================================== -->
4 <project name="trafficjampuzzle" default="publish" basedir=".">
5    <target name="init">
6       <!-- Define properties for maintainability -->
7       <property name="app" value="TrafficJamApp" />
8       <property name="pkg" value="trafficjampuzzle" />
9       <property name="sourceDir" value="src" />
10       <property name="buildDir" value="build" />
11       <property name="distDir"  location="dist"/>
12       <property name="testDir"  location="test"/>
13       <property name="webDir" value="${user.home}/www/${app}/" />
14       <property name="classpath" value="." />
15       <!-- Create the time stamp -->
16       <tstamp>
17         <format property="timestamp" pattern="MM/dd/yyyy hh:mm aa" />
18       </tstamp>
19       <!-- Create the build output log file -->
20       <property name="build.log.dir" location="${webDir}/Daily"/>
21       <mkdir dir="${build.log.dir}"/>
22       <property name="build.log.filename" value="build_${DSTAMP}_${TSTAMP}.log"/>
23       <record name="${build.log.dir}/${build.log.filename}"
24               loglevel="verbose" append="false"/>
25       <echo message="Build logged to ${build.log.filename}"/>
26       <!-- Declare the checkstyle task -->
27       <taskdef resource="checkstyletask.properties">
28        <classpath>
29                <pathelement location="lib/checkstyle-all-4.4.jar"/>
30                <pathelement location="lib/308checks.jar"/>
31        </classpath>
32        </taskdef>
33    </target>
34
35    <!-- =================================================================== -->
36    <!-- Remove old build directories                                        -->
37    <!-- =================================================================== -->
38    <target name="clean" depends="init">
39          <echo>Removing build and dist directories</echo>
40             <delete dir="${buildDir}"  failonerror="false"/>
41             <delete dir="${distDir}"  failonerror="false"/>
42    </target>
43
44    <!-- =================================================================== -->
45    <!-- Obtain current sources from svn repository                          -->
46    <!-- =================================================================== -->
47    <target name="update" depends="clean">
48            <echo>Updating source files from repository</echo>
49             <exec executable="svn">
50               <arg value="update"/>
51               <arg value="."/>
52             </exec>
53    </target>
54
55    <!-- =================================================================== -->
56    <!-- Create a property for the current svn revision                      -->
57    <!-- =================================================================== -->
58    <target name="revision" depends="update,init">
59     <exec outputproperty="build.current.revision" executable="svnversion">
60         <arg line="-n" />
61         </exec>
62    </target>
63        
64    <!-- =================================================================== -->
65    <!-- Compile the source code                                             -->
66    <!-- =================================================================== -->
67    <target name="compile" depends="update,revision">
68     <echo>Compiling all application source and junit test files</echo>
69     <!-- Put the revision number into the source code -->
70         <replace file="${sourceDir}/${pkg}/${app}.java"
71              value="${build.current.revision}">
72             <replacetoken>RevisionNumber</replacetoken>
73         </replace>
74        
75     <!-- Create the needed build directories -->
76     <mkdir dir="${buildDir}"/>
77     <mkdir dir="${buildDir}/classes"/>
78     <mkdir dir="${distDir}"/>
79
80     <!-- Compile sources  -->
81     <javac srcdir="${sourceDir}" destdir="${buildDir}/classes"
82            includes="${pkg}/*"
83            fork="true"
84            target="1.5"
85            listfiles="yes"
86            deprecation="yes"
87            failonerror="false" />
88     <javac srcdir="${testDir}" destdir="${buildDir}/classes"
89            includes="${pkg}/*"
90            classpath="${buildDir}/classes "
91            fork="true"
92            target="1.5"
93            deprecation="yes"
94            failonerror="false" />
95    </target>
96
97    <!-- =================================================================== -->
98    <!-- Check for coding style conformance.                                 -->
99    <!-- =================================================================== -->
100    <target name="style" depends="compile">
101      <checkstyle config="lib/308style.xml"
102                 failOnViolation="false">
103        <fileset dir="${sourceDir}/${pkg}" includes="**/*.java"/>
104      </checkstyle>
105    </target>
106
107    <!-- =================================================================== -->
108    <!-- Copy media files needed for the JAR                                 -->
109    <!-- =================================================================== -->
110    <target name="copyresources" depends="update,compile">
111           <copy todir="${buildDir}/classes/${pkg}/resources">
112             <fileset dir="${sourceDir}/${pkg}/resources/">
113               <include name="*"/>
114             </fileset>
115           </copy>
116    </target>
117
118    <!-- =================================================================== -->
119    <!-- Check for a successful compile                                      -->
120    <!-- =================================================================== -->
121    <target name="compile.check" depends="compile">
122       <condition property="compileok">
123             <available file="${buildDir}/classes/${pkg}/${app}.class"/>
124       </condition>
125    </target>
126
127    <!-- =================================================================== -->
128    <!-- Make the JAR file                                                   -->
129    <!-- =================================================================== -->
130    <target name="jar" depends="compile.check,init,revision,copyresources"
131            if="compileok">
132     <jar destfile="${distDir}/${app}_r${build.current.revision}.jar"
133          basedir="${buildDir}/classes"
134          manifest="manifest.mf"
135          includes="${pkg}/ "/>
136     <!-- Copy the jar to the public web folder -->
137         <copy file="${distDir}/${app}_r${build.current.revision}.jar"
138           todir="${webDir}/Daily" />
139     <!-- make jar public read -->
140     <chmod file="${webDir}/" perm="a+rx"  type="dir"/>
141     <chmod file="${webDir}/Daily/" perm="a+rx"  type="dir"/>
142 <!--     <chmod dir="${webDir}/Daily/" perm="a+r" includes="**/*"/> -->
143     <chmod file="${webDir}/Daily/${app}_r${build.current.revision}.jar"
144            perm="a+r" type="file"/>
145    </target>
146    
147    <!-- =================================================================== -->
148    <!-- Make the javadocs                                                   -->
149    <!-- =================================================================== -->
150    <target name="docs" depends="jar,style">
151     <javadoc destdir="${distDir}/javadoc"
152              sourcepath="${sourceDir}"
153              windowtitle="Traffic Jam r${build.current.revision}"
154              private="true" nohelp="true"
155              nodeprecated="true" nodeprecatedlist="true"
156              version="true" author="true"
157              overview="${sourceDir}/overview.html"  />
158     <!-- Copy the docs to the public web folder -->
159         <copy todir="${webDir}/Javadoc">
160             <fileset dir="${distDir}/javadoc"/>
161         </copy>
162     <!-- make javadocs public read -->
163     <chmod file="${webDir}/Javadoc/" perm="a+rx" type="dir"/>
164     <chmod dir="${webDir}/Javadoc/" perm="a+rx" type="both"
165            includes="**/*"/>
166    </target>
167
168    <!-- =================================================================== -->
169    <!-- Publish the build report by appending HTML to the existing page.    -->
170    <!-- =================================================================== -->
171    <target name="publish.1" depends="docs,init,revision">
172     <echo file="${webDir}/Daily/index.html"
173           append="yes">
174       &lt;TR&gt;
175                 &lt;TD&gt;${timestamp}&lt;/TD&gt;
176                 &lt;TD&gt;${build.current.revision}&lt;/TD&gt;
177                 &lt;TD&gt;???&lt;/TD&gt;
178                 &lt;TD&gt;&lt;A HREF="${build.log.filename}"&gt;
179                 Build Output&lt;/A&gt;&lt;/TD&gt;
180                 &lt;TD&gt;
181     </echo>
182    </target>
183    <!-- Only include a link to the JAR if the compile succeeded -->
184    <target name="publish.2" depends="publish.1,compile.check"
185            if="compileok">
186     <echo file="${webDir}/Daily/index.html"
187           append="yes">
188                 &lt;A HREF="${app}_r${build.current.revision}.jar"&gt;
189                 ${app}_r${build.current.revision}.jar&lt;/A&gt;
190     </echo>
191    </target>
192    <target name="publish" depends="publish.2">
193     <echo file="${webDir}/Daily/index.html"
194           append="yes">
195                &lt;/TD&gt;
196       &lt;/TR&gt;
197     </echo>
198     <!-- make report page and build log public read -->
199     <chmod file="${webDir}/Daily/index.html" perm="a+r"/>
200     <chmod file="${build.log.dir}/${build.log.filename}"
201            perm="a+r" type="file"/>
202    </target>
203
204    
205 </project>
206
Note: See TracBrowser for help on using the browser.