summaryrefslogtreecommitdiffstats
path: root/build.xml
blob: 22f233602c5e5127d692a324a2db94d5896c5b19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?xml version="1.0" encoding="UTF-8"?>
<project name="gitblit" default="main" basedir=".">

	<!-- Project Properties -->
	<property name="project.jar" value="gitblit.jar" />
	<property name="project.mainclass" value="com.gitblit.Launcher" />	
	<property name="project.build.dir" value="${basedir}/build" />

	<target name="main">
			
		<!-- extract version number from source code -->
		<loadfile property="gb.version" srcfile="${basedir}/src/com/gitblit/Constants.java">
			<filterchain>
				<linecontains>
		        	<contains value="public final static String VERSION = "/>
		    	</linecontains>
				<striplinebreaks/>
				<tokenfilter>				    
					<replacestring from="public final static String VERSION = &quot;" to=""/>
					<replacestring from="&quot;;" to=""/>
					<trim />
				</tokenfilter>
			</filterchain>
		</loadfile>
		<echo>Building Git:Blit ${gb.version}</echo>
		
		<!-- copy required distribution files to project folder -->
		<copy todir="${basedir}" overwrite="false">
			<fileset dir="${basedir}/distrib">
				<include name="gitblit.properties" />
				<include name="users.properties" />
			</fileset>
		</copy>
		
		<!-- Compile the build tool and execute it.
			 This downloads missing compile-time dependencies from Maven. -->

		<delete dir="${project.build.dir}" />
		<mkdir dir="${project.build.dir}" />
		<javac srcdir="${basedir}/src" destdir="${project.build.dir}">
			<include name="com/gitblit/Build.java" />
			<include name="com/gitblit/Constants.java" />
			<include name="com/gitblit/utils/StringUtils.java" />
		</javac>
		<java classpath="${project.build.dir}" classname="com.gitblit.Build" />

		<!-- Compile Project -->
		<path id="master-classpath">
			<fileset dir="${basedir}/ext">
				<include name="*.jar" />
			</fileset>
		</path>
		<javac destdir="${project.build.dir}">
			<src path="${basedir}/src" />
			<classpath refid="master-classpath" />
		</javac>
		<copy todir="${project.build.dir}">
			<fileset dir="${basedir}/src" excludes="**/*.java,**/thumbs.db" />
		</copy>

		<!-- Build jar -->
		<delete file="${project.jar}" />
		<jar jarfile="${project.jar}">
			<fileset dir="${project.build.dir}">
				<include name="**/*" />
			</fileset>
			<manifest>
				<attribute name="Main-Class" value="${project.mainclass}" />
			</manifest>
		</jar>

		<!-- Delete the deploy folder -->
		<delete dir="${basedir}/deploy" />

		<!-- Create deployment folder structure -->
		<mkdir dir="${basedir}/deploy" />
		<copy todir="${basedir}/deploy" file="${project.jar}" />
		<copy todir="${basedir}/deploy">
			<fileset dir="${basedir}/distrib">
				<include name="**/*" />
			</fileset>
		</copy>

		<!-- Create Zip deployment -->
		<property name="distribution.zipfile" value="gitblit-${gb.version}.zip" />
		<zip destfile="${distribution.zipfile}">
			<fileset dir="${basedir}/deploy">
				<include name="**/*" />
			</fileset>
		</zip>

		<!-- Delete the deploy folder -->
		<delete dir="${basedir}/deploy" />

		<!-- Cleanup builds -->
		<delete>
			<fileset dir="${basedir}">
				<include name="${project.jar}" />
			</fileset>
		</delete>
	</target>
</project>