James Moger
2011-06-28 d39680e9f54322ddcb40b00503a8ee30aee6c99c
commit | author | age
5fe7df 1 <?xml version="1.0" encoding="UTF-8"?>
85c2e6 2 <project name="gitblit" default="compile" basedir=".">
JM 3
4     <!-- Google Code upload task -->
5     <taskdef classname="net.bluecow.googlecode.ant.GoogleCodeUploadTask" classpath="${basedir}/tools/ant-googlecode-0.0.3.jar" name="gcupload"/>
5fe7df 6
JM 7     <!-- Project Properties -->
8     <property name="project.jar" value="gitblit.jar" />
dd7961 9     <property name="project.mainclass" value="com.gitblit.Launcher" />
5fe7df 10     <property name="project.build.dir" value="${basedir}/build" />
85c2e6 11     <property name="project.deploy.dir" value="${basedir}/deploy" />
JM 12     <property name="project.war.dir" value="${basedir}/war" />
13     <property name="project.site.dir" value="${basedir}/site" />
14     <property name="project.resources.dir" value="${basedir}/resources" />    
5fe7df 15
85c2e6 16     <!-- Load publication servers, paths, and credentials --> 
81f881 17     <loadproperties srcfile="${basedir}/build.properties" />
5450d0 18     
85c2e6 19     
JM 20     <!--
21         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22         Scrape the version info from code and setup the build properties 
23         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24     -->
5450d0 25     <target name="buildinfo">
JM 26     
f13c4c 27         <!-- extract Gitblit version number from source code -->
f98825 28         <loadfile property="gb.version" srcfile="${basedir}/src/com/gitblit/Constants.java">
JM 29             <filterchain>
30                 <linecontains>
2a7306 31                     <contains value="public static final String VERSION = " />
dd7961 32                 </linecontains>
JM 33                 <striplinebreaks />
34                 <tokenfilter>
2a7306 35                     <replacestring from="public static final String VERSION = &quot;" to="" />
a4d249 36                     <replacestring from="&quot;;" to="" />
JM 37                     <trim />
38                 </tokenfilter>
1f9dae 39             </filterchain>
a4d249 40         </loadfile>
d39680 41
JM 42         <!-- extract Gitblit version date from source code -->
43         <loadfile property="gb.versionDate" srcfile="${basedir}/src/com/gitblit/Constants.java">
44             <filterchain>
45                 <linecontains>
46                     <contains value="public static final String VERSION_DATE = " />
47                 </linecontains>
48                 <striplinebreaks />
49                 <tokenfilter>
50                     <replacestring from="public static final String VERSION_DATE = &quot;" to="" />
51                     <replacestring from="&quot;;" to="" />
52                     <trim />
53                 </tokenfilter>
54             </filterchain>
55         </loadfile>
56                     
a4d249 57         <!-- extract JGit version number from source code -->
JM 58         <loadfile property="jgit.version" srcfile="${basedir}/src/com/gitblit/Constants.java">
59             <filterchain>
60                 <linecontains>
2a7306 61                     <contains value="public static final String JGIT_VERSION = " />
a4d249 62                 </linecontains>
JM 63                 <striplinebreaks />
64                 <tokenfilter>
2a7306 65                     <replacestring from="public static final String JGIT_VERSION = &quot;" to="" />
dd7961 66                     <replacestring from="&quot;;" to="" />
f98825 67                     <trim />
JM 68                 </tokenfilter>
69             </filterchain>
85c2e6 70         </loadfile>    
5450d0 71         <property name="distribution.zipfile" value="gitblit-${gb.version}.zip" />
JM 72         <property name="distribution.warfile" value="gitblit-${gb.version}.war" />
73     </target>
74     
85c2e6 75     
JM 76     <!--
77         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
78         Compile
79         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
80     -->
81     <target name="compile" depends="buildinfo" description="Retrieves dependencies and compiles Gitblit from source">
dd7961 82
f98825 83         <!-- copy required distribution files to project folder -->
JM 84         <copy todir="${basedir}" overwrite="false">
85             <fileset dir="${basedir}/distrib">
86                 <include name="gitblit.properties" />
87                 <include name="users.properties" />
88             </fileset>
89         </copy>
dd7961 90
5fe7df 91         <!-- Compile the build tool and execute it.
JM 92              This downloads missing compile-time dependencies from Maven. -->
93
94         <delete dir="${project.build.dir}" />
95         <mkdir dir="${project.build.dir}" />
96         <javac srcdir="${basedir}/src" destdir="${project.build.dir}">
22fc5e 97             <include name="com/gitblit/build/Build.java" />            
155bf7 98             <include name="com/gitblit/Constants.java" />
5450d0 99             <include name="com/gitblit/utils/StringUtils.java" />            
5fe7df 100         </javac>
22fc5e 101         <java classpath="${project.build.dir}" classname="com.gitblit.build.Build" />
5fe7df 102
JM 103         <!-- Compile Project -->
104         <path id="master-classpath">
105             <fileset dir="${basedir}/ext">
106                 <include name="*.jar" />
107             </fileset>
108         </path>
81f881 109         <javac destdir="${project.build.dir}" failonerror="false">
5fe7df 110             <src path="${basedir}/src" />
JM 111             <classpath refid="master-classpath" />
112         </javac>
113         <copy todir="${project.build.dir}">
114             <fileset dir="${basedir}/src" excludes="**/*.java,**/thumbs.db" />
115         </copy>
85c2e6 116     </target>
JM 117
118     
119     <!--
120         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
121         Build Gitblit GO
122         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
123     -->
124     <target name="buildGO" depends="compile" description="Build Gitblit GO distribution">
125         
126         <echo>Building Gitblit GO ${gb.version}</echo>
127
128         <!-- Delete the deploy folder -->
129         <delete dir="${project.deploy.dir}" />
130
131         <!-- Create deployment folder structure -->
132         <mkdir dir="${project.deploy.dir}" />
133         <copy todir="${project.deploy.dir}">
134             <fileset dir="${basedir}/distrib">
135                 <include name="**/*" />
136             </fileset>
137         </copy>
5fe7df 138
JM 139         <!-- Build jar -->
85c2e6 140         <jar jarfile="${project.deploy.dir}/${project.jar}">
5fe7df 141             <fileset dir="${project.build.dir}">
JM 142                 <include name="**/*" />
143             </fileset>
5450d0 144             <fileset dir="${project.resources.dir}">
JM 145                 <exclude name="thumbs.db" />
146             </fileset>
5fe7df 147             <manifest>
JM 148                 <attribute name="Main-Class" value="${project.mainclass}" />
149             </manifest>
150         </jar>
151
85c2e6 152         <!-- Build the docs for the deploy -->
JM 153         <antcall target="buildDocs" inheritall="true" inheritrefs="true">
154             <param name="docs.output.dir" value="${project.deploy.dir}/docs" />
155         </antcall>
156         
157         <!-- Create Zip deployment -->        
158         <zip destfile="${distribution.zipfile}">
159             <fileset dir="${project.deploy.dir}">
160                 <include name="**/*" />
161             </fileset>
162         </zip>
163
164     </target>
165     
166     
167     <!--
168         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
169         Build Gitblit Docs which are bundled with GO and WAR downloads
170         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
171     -->
172     <target name="buildDocs">
173     <!-- Build Docs -->
174             <mkdir dir="${docs.output.dir}" />
175             <copy todir="${docs.output.dir}">
176                 <!-- Copy selected Gitblit resources -->
177                 <fileset dir="${project.resources.dir}">
178                     <include name="background.png" />
179                     <include name="gitblit.css" />
180                     <include name="markdown.css" />
181                     <include name="gitblt_25.png" />
182                     <include name="gitblt-favicon.png" />
183                     <include name="lock_go_16x16.png" />
184                     <include name="lock_pull_16x16.png" />
185                     <include name="shield_16x16.png" />
186                     <include name="cold_16x16.png" />
187                     <include name="bug_16x16.png" />
188                     <include name="book_16x16.png" />
189                     <include name="blank.png" />
190                 </fileset>
191
192                 <!-- Copy Doc images -->
193                 <fileset dir="${basedir}/docs">
194                     <include name="*.png" />
195                 </fileset>
196             </copy>
197
198             <!-- Copy google-code-prettify -->
199             <mkdir dir="${docs.output.dir}/prettify" />
200             <copy todir="${docs.output.dir}/prettify">
201                 <fileset dir="${basedir}/src/com/gitblit/wicket/pages/prettify">
202                     <exclude name="thumbs.db" />
203                 </fileset>
204             </copy>
205
206             <!-- Build deployment doc pages -->
22fc5e 207             <java classpath="${project.build.dir}" classname="com.gitblit.build.BuildSite">
85c2e6 208                 <classpath refid="master-classpath" />
JM 209                 <arg value="--sourceFolder" />
210                 <arg value="${basedir}/docs" />
211
212                 <arg value="--outputFolder" />
213                 <arg value="${docs.output.dir}" />
214
215                 <arg value="--pageHeader" />
216                 <arg value="${basedir}/docs/doc_header.html" />
217
218                 <arg value="--pageFooter" />
219                 <arg value="${basedir}/docs/doc_footer.html" />
220
221                 <arg value="--skip" />
222                 <arg value="screenshots" />
223
224                 <arg value="--skip" />
225                 <arg value="releases" />
226
227                 <arg value="--alias" />
228                 <arg value="index=overview" />
229
230                 <arg value="--alias" />
231                 <arg value="properties=gitblit.properties" />
232
233                 <arg value="--substitute" />
234                 <arg value="%VERSION%=${gb.version}" />
235
236                 <arg value="--substitute" />
237                 <arg value="%GO%=${distribution.zipfile}" />
238
239                 <arg value="--substitute" />
240                 <arg value="%WAR%=${distribution.warfile}" />
241
242                 <arg value="--substitute" />
d39680 243                 <arg value="%BUILDDATE%=${gb.versionDate}" />
85c2e6 244
JM 245                 <arg value="--substitute" />
246                 <arg value="%JGIT%=${jgit.version}" />
247
248                 <arg value="--load" />
249                 <arg value="%PROPERTIES%=${basedir}/distrib/gitblit.properties" />
250
251             </java>
252     </target>
253     
254                 
255     <!--
256         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
257         Build Gitblit WAR
258         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
259     -->
260     <target name="buildWAR" depends="compile" description="Build Gitblit WAR">
261         
262         <echo>Building Gitblit WAR ${gb.version}</echo>
263         
264         <delete dir="${project.war.dir}" />        
265
266         <!-- Copy web.xml and users.properties to WEB-INF -->
267         <copy todir="${project.war.dir}/WEB-INF">
268             <fileset dir="${basedir}/distrib">
269                  <include name="users.properties" />
270             </fileset>
271             <fileset dir="${basedir}/src/WEB-INF">
272                  <include name="web.xml" />
273             </fileset>
274         </copy>
275         
276         <!-- Build the docs for the WAR build -->
277         <antcall target="buildDocs" inheritall="true" inheritrefs="true">
278             <param name="docs.output.dir" value="${project.war.dir}/WEB-INF/docs" />
279         </antcall>
280         
281         <!-- Build the WAR web.xml from the prototype web.xml and gitblit.properties --> 
22fc5e 282         <java classpath="${project.build.dir}" classname="com.gitblit.build.BuildWebXml">
85c2e6 283             <classpath refid="master-classpath" />
JM 284             
285             <arg value="--sourceFile" />
286             <arg value="${basedir}/src/WEB-INF/web.xml" />
287                     
288             <arg value="--destinationFile" />
289             <arg value="${project.war.dir}/WEB-INF/web.xml" />
290             
291             <arg value="--propertiesFile" />
292             <arg value="${basedir}/distrib/gitblit.properties" />
293         </java>
294
295         <!-- Gitblit resources -->
296         <copy todir="${project.war.dir}">
297             <fileset dir="${project.resources.dir}">
298                 <exclude name="thumbs.db" />
299             </fileset>
300         </copy>
301         
302         <!-- Gitblit library dependencies -->
303         <mkdir dir="${project.war.dir}/WEB-INF/lib"/>
304         <copy todir="${project.war.dir}/WEB-INF/lib">
305             <fileset dir="${basedir}/ext">
306                 <exclude name="*-sources.jar" />
307                 <exclude name="*-javadoc.jar" />
308                 <exclude name="jcommander*.jar" />
309                 <exclude name="jetty*.jar" />
310                 <exclude name="junit*.jar" />
311                 <exclude name="servlet*.jar" />
312             </fileset>
313         </copy>
314
315         <!-- Gitblit classes -->
316         <mkdir dir="${project.war.dir}/WEB-INF/classes"/>
317         <copy todir="${project.war.dir}/WEB-INF/classes">
318             <fileset dir="${project.build.dir}">
319                 <exclude name="WEB-INF/web.xml" />
320                 <exclude name="com/gitblit/tests/" />
22fc5e 321                 <exclude name="com/gitblit/build/**" />
85c2e6 322                 <exclude name="com/gitblit/GitBlitServer*.class" />
JM 323                 <exclude name="com/gitblit/Launcher*.class" />
324                 <exclude name="com/gitblit/MakeCertificate*.class" />                
325             </fileset>
326         </copy>
327
328         <!-- Build the WAR file -->
329         <jar basedir="${project.war.dir}" destfile="${distribution.warfile}" compress="true" />
330     </target>
331
332     
333     <!-- 
334         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
335         Build the Gitblit Website
336         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
337     -->
338     <target name="buildSite" depends="compile" description="Build the Gitblit website">
339         
340         <echo>Building Gitblit Website ${gb.version}</echo>
341
dd7961 342         <!-- Build Site -->
85c2e6 343         <delete dir="${project.site.dir}" />
JM 344         <mkdir dir="${project.site.dir}" />
345         <copy todir="${project.site.dir}">
f13c4c 346             <!-- Copy selected Gitblit resources -->
5450d0 347             <fileset dir="${project.resources.dir}">
dd7961 348                 <include name="background.png" />
JM 349                 <include name="gitblit.css" />
350                 <include name="markdown.css" />
351                 <include name="gitblt_25.png" />
352                 <include name="gitblt-favicon.png" />
f90dc6 353                 <include name="lock_go_16x16.png" />
JM 354                 <include name="lock_pull_16x16.png" />
355                 <include name="shield_16x16.png" />
356                 <include name="cold_16x16.png" />
357                 <include name="bug_16x16.png" />
358                 <include name="book_16x16.png" />
359                 <include name="blank.png" />
dd7961 360             </fileset>
a4d249 361
f90dc6 362             <!-- Copy Doc images -->
dd7961 363             <fileset dir="${basedir}/docs">
f90dc6 364                 <include name="*.png" />
JM 365                 <include name="*.js" />
366             </fileset>
367         </copy>
a4d249 368
f90dc6 369         <!-- Copy Fancybox -->
85c2e6 370         <mkdir dir="${project.site.dir}/fancybox" />
JM 371         <copy todir="${project.site.dir}/fancybox">
a4d249 372             <fileset dir="${basedir}/docs/fancybox">
f90dc6 373                 <exclude name="thumbs.db" />
JM 374             </fileset>
375         </copy>
a4d249 376
1f9dae 377         <!-- Copy google-code-prettify -->
JM 378         <mkdir dir="${basedir}/src/com/gitblit/wicket/pages/prettify" />
85c2e6 379         <copy todir="${project.site.dir}/prettify">
1f9dae 380             <fileset dir="${basedir}/src/com/gitblit/wicket/pages/prettify">
JM 381                 <exclude name="thumbs.db" />
382             </fileset>
383         </copy>
384
24d08f 385         <!-- Generate thumbnails of screenshots -->
22fc5e 386         <java classpath="${project.build.dir}" classname="com.gitblit.build.BuildThumbnails">
24d08f 387             <classpath refid="master-classpath" />
JM 388                 
389             <arg value="--sourceFolder" />
390             <arg value="${basedir}/docs/screenshots" />
391         
392             <arg value="--destinationFolder" />
85c2e6 393             <arg value="${project.site.dir}/thumbs" />
24d08f 394             
JM 395             <arg value="--maximumDimension" />
396             <arg value="250" />
397         </java>
a4d249 398
f90dc6 399         <!-- Copy screenshots -->
85c2e6 400         <mkdir dir="${project.site.dir}/screenshots" />
JM 401         <copy todir="${project.site.dir}/screenshots">
f90dc6 402             <fileset dir="${basedir}/docs/screenshots">
JM 403                 <include name="*.png" />
404             </fileset>
405         </copy>
406
a4d249 407         <!-- Build site pages -->
22fc5e 408         <java classpath="${project.build.dir}" classname="com.gitblit.build.BuildSite">
dd7961 409             <classpath refid="master-classpath" />
JM 410             <arg value="--sourceFolder" />
411             <arg value="${basedir}/docs" />
a4d249 412
dd7961 413             <arg value="--outputFolder" />
85c2e6 414             <arg value="${project.site.dir}" />
dd7961 415
JM 416             <arg value="--pageHeader" />
81f881 417             <arg value="${basedir}/docs/site_header.html" />
dd7961 418
JM 419             <arg value="--pageFooter" />
81f881 420             <arg value="${basedir}/docs/site_footer.html" />
a4d249 421
e0054b 422             <arg value="--alias" />
JM 423             <arg value="index=overview" />
424fe1 424
1f9dae 425             <arg value="--alias" />
JM 426             <arg value="properties=gitblit.properties" />
a4d249 427
JM 428             <arg value="--substitute" />
429             <arg value="%VERSION%=${gb.version}" />
430
431             <arg value="--substitute" />
85c2e6 432             <arg value="%GO%=${distribution.zipfile}" />
JM 433
434             <arg value="--substitute" />
435             <arg value="%WAR%=${distribution.warfile}" />
a4d249 436
JM 437             <arg value="--substitute" />
d39680 438             <arg value="%BUILDDATE%=${gb.versionDate}" />
a4d249 439
JM 440             <arg value="--substitute" />
441             <arg value="%JGIT%=${jgit.version}" />
1f9dae 442
JM 443             <arg value="--load" />
444             <arg value="%PROPERTIES%=${basedir}/distrib/gitblit.properties" />
445
dd7961 446         </java>
85c2e6 447     </target>
81f881 448         
424fe1 449
85c2e6 450     <!--
JM 451         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
452         Compile from source, publish binaries, and build & deploy site
453         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
454     -->
455     <target name="buildAll" depends="buildGO,buildWAR,buildSite">        
1f9dae 456         <!-- Cleanup -->
2a7306 457         <delete dir="${project.build.dir}" />
85c2e6 458         <delete dir="${project.war.dir}" />
JM 459         <delete dir="${project.deploy.dir}" />
5fe7df 460     </target>
85c2e6 461                 
81f881 462     
85c2e6 463     <!-- 
JM 464         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
465         Publish binaries to Google Code
466         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
467     -->
468     <target name="publishBinaries" depends="buildGO,buildWAR" description="Publish the Gitblit binaries to Google Code">
469         
470         <echo>Uploading Gitblit ${gb.version} binaries</echo>
471         
472         <!-- Upload ZIP file -->
473         <gcupload 
474              username="${googlecode.user}" 
475              password="${googlecode.password}" 
476              projectname="gitblit" 
477              filename="${distribution.zipfile}" 
478              targetfilename="gitblit-${gb.version}.zip"
479              summary="Standalone, integrated Gitblit server v${gb.version}"
480              labels="Featured, Type-Package, OpSys-All" />
5450d0 481             
85c2e6 482         <!-- Upload WAR file -->
JM 483         <gcupload 
484              username="${googlecode.user}" 
485              password="${googlecode.password}" 
486              projectname="gitblit" 
487              filename="${distribution.warfile}" 
488              targetfilename="gitblit-${gb.version}.war"
489              summary="Gitblit WAR v${gb.version} for your servlet container"
490              labels="Featured, Type-Package, OpSys-All" />
5450d0 491     </target>
JM 492
493     
85c2e6 494     <!--
JM 495         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
496         Publish site to hosting service
497         You must add ext/commons-net-1.4.0.jar to your ANT classpath.
498         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
499     -->
500     <target name="publishSite" depends="buildSite" description="Publish the Gitblit site to a webserver (requires ext/commons-net-1.4.0.jar)" >
501         
502         <echo>Uploading Gitblit ${gb.version} website</echo>
503         
81f881 504         <ftp server="${ftp.server}"
JM 505             userid="${ftp.user}"
506             password="${ftp.password}"
507             remotedir="${ftp.dir}"
508             passive="true"
509             verbose="yes">
85c2e6 510         <fileset dir="${project.site.dir}" />
81f881 511         </ftp>
JM 512     </target>
85c2e6 513
81f881 514     
85c2e6 515     <!--
JM 516         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
517         Compile from source, publish binaries, and build & deploy site
518         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
519     -->
520     <target name="publishAll" depends="publishBinaries,publishSite">        
521         <!-- Cleanup -->
522         <delete dir="${project.build.dir}" />
523         <delete dir="${project.war.dir}" />
524         <delete dir="${project.deploy.dir}" />
525     </target>
5450d0 526 </project>