-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.xml
139 lines (116 loc) · 5.36 KB
/
build.xml
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?xml version="1.0"?>
<project name="fastrf" default="deploy">
<property name="private.buildfile" value="build-resources/private/user-antbuild.properties"/>
<property file="${private.buildfile}"/>
<property file="build-resources/antbuild.properties"/>
<property name="version.file" value="fastrf-version.txt"/>
<property name="version.file.dev" value="version/${version.file}"/>
<touch file="${private.buildfile}" mkdirs="true"/>
<fail message="${line.separator}================[ ERROR ] ==============${line.separator}
You must specify the software.dir property in the file ${private.buildfile}${line.separator}
If you are running eclipse you should right click on this project and hit refresh,
so that the file appears.${line.separator}
${line.separator}
You should then put the following two lines in the file:${line.separator}
software.dir=[path to place completed packages]${line.separator}
buildnumberpath=[path to store build numbers]${line.separator}
#Windows users should use \\ or / as path seperators.
">
<condition>
<not>
<isset property="software.dir"/>
</not>
</condition>
</fail>
<mkdir dir="${software.dir}"/>
<mkdir dir="${buildnumberpath}"/>
<mkdir dir="lib"/> <!-- Doesn't store anything currently, but if it doesn't exist build will fail. Git won't sync an empty folder either-->
<path id="compile.classpath">
<fileset dir="lib" id="lib">
<include name="*.jar"/>
</fileset>
</path>
<target name="git-status-init" description="Initialize Git variables">
<echo>If this next call fails, it means you haven't installed git and/or it's not in your PATH</echo>
<exec executable="git" outputproperty="git.branch">
<arg value="rev-parse"/>
<arg value="--abbrev-ref"/>
<arg value="HEAD"/>
</exec>
<exec executable="git" outputproperty="git.commit">
<arg value="rev-parse"/>
<arg value="HEAD"/>
</exec>
<exec executable="git" outputproperty="git.shortcommit">
<arg value="rev-parse"/>
<arg value="--short=12"/>
<arg value="HEAD"/>
</exec>
<exec executable="git" resultproperty="git.dirty" outputproperty="git.dirty.output">
<arg value="diff"/>
<arg value="--exit-code"/>
</exec>
<echo>Git properties loaded, branch: ${git.branch}
commit: ${git.commit}
shortcommit: ${git.shortcommit}
dirty: ${git.dirty}</echo>
</target>
<target name="init" depends="git-status-init">
<mkdir dir="build/classes/"/>
<mkdir dir="dist"/>
</target>
<target name="clean">
<delete dir="build"/>
<delete dir="dist"/>
</target>
<target name="compile" depends="init">
<javac srcdir="src" destdir="build/classes" debug="true" target="1.7" source="1.7">
<classpath refid="compile.classpath"/>
</javac>
</target>
<target name="archive" depends="compile">
<buildnumber file="${buildnumberpath}/buildnumber-${ant.project.name}"/>
<property name="version.string" value="v${version.major}.${version.minor}.${version.revision}${version.beta}-${git.branch}-${build.number}"/>
<property name="version.devstring" value="v${version.major}.${version.minor}.${version.revision}dev-${git.branch}-${build.number}"/>
<echo file="${version.file.dev}">${version.devstring} (${git.shortcommit})</echo>
<echo file="build/classes/${version.file}">${version.string} (${git.shortcommit})</echo>
<property name="outputfilename" value="${ant.project.name}-${version.string}"/>
<jar destfile="dist/${ant.project.name}.jar" basedir="build/classes"/>
<echo file="dist/git-hashes.txt" append="false">${ant.project.name} ${git.commit} ${git.dirty}${line.separator}</echo>
<echo file="dist/git-hashes.tex" append="false">${ant.project.name} & ${version.string} & ${git.commit} & ${git.dirty} \\${line.separator}\hline${line.separator}</echo>
<copy todir="dist/">
<fileset refid="lib"/>
</copy>
<jar destfile="dist/fastrf.jar" basedir="build/classes"/>
<jar destfile="dist/fastrf-src.jar">
<fileset dir="src/">
<include name="**/*.java"/>
</fileset>
</jar>
</target>
<target name="zip" depends="archive" description="Makes tarball for this release">
<fail message="Cannot deploy a build for the git master branch if it is dirty, please commit all changes">
<condition>
<and>
<equals arg1="${git.branch}" arg2="master" casesensitive="false" trim="true"/>
<equals arg1="${git.dirty}" arg2="1" casesensitive="false" trim="true"/>
</and>
</condition>
</fail>
<tar destFile="${software.dir}${file.separator}${outputfilename}.tar.gz" longfile="gnu" compression="gzip">
<tarfileset dir="dist/" filemode="755" dirmode="755" prefix="${outputfilename}/">
<include name="**/*"/>
<exclude name="${lastdeployfile}"/>
<exclude name="mysql-worker"/>
</tarfileset>
</tar>
</target>
<target name="deploy-release" depends="zip" description="untars tarball in software.dir and creates symlink">
<untar src="${software.dir}${file.separator}${outputfilename}.tar.gz" dest="${software.dir}" compression="gzip"/>
<propertyfile file="${software.dir}${file.separator}${ant.project.name}-${git.branch}.latest" comment="Contains location of most recent ${ant.project.name}">
<entry key="${ant.project.name}.location" value="${software.dir}${file.separator}${outputfilename}"/>
</propertyfile>
<echo>Untar Successful to ${software.dir}/${outputfilename}</echo>
</target>
<target name="deploy" depends="zip, deploy-release"/>
</project>