forked from MIT-Mobile/MIT-Mobile-for-Android
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ant-config.xml
88 lines (69 loc) · 3.68 KB
/
ant-config.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
<?xml version="1.0" encoding="UTF-8"?>
<project name="MITApp" default="config">
<property file="ant.properties" />
<loadproperties srcFile="project.properties" />
<loadproperties srcFile="local.properties" />
<import file="${sdk.dir}/tools/ant/build.xml" />
<available file=".git" type="dir" property="git.present"/>
<target name="git.revision" description="Store git revision in ${repository.version}" if="git.present">
<!-- Get Git properties on UNIX machines -->
<!-- ################################### -->
<!-- ################################### -->
<!-- Get git describe on UNIX machines -->
<exec executable="git" osfamily="unix" outputproperty="git.revision" failifexecutionfails="false" errorproperty="">
<arg value="describe"/>
</exec>
<!-- Get git SHA1 on UNIX machines -->
<exec executable="git" osfamily="unix" outputproperty="git.hash" failifexecutionfails="false" errorproperty="">
<arg value="log" />
<arg value="-1" />
<arg value="--pretty=format:%H" />
</exec>
<!-- Get Git properties on WINDOWS machines -->
<!-- ################################### -->
<!-- ################################### -->
<!-- Get Git describe on WINDOWS machines -->
<exec executable="git.cmd" osfamily="windows" outputproperty="git.revision" failifexecutionfails="false" errorproperty="git.error">
<arg value="describe" />
</exec>
<!-- Get Git SHA1 on WINDOWS machines -->
<exec executable="git.cmd" osfamily="windows" outputproperty="git.hash" failifexecutionfails="false" errorproperty="git.error">
<!-- <arg value="log -1 -pretty=format:%H" /> -->
<arg value="log" />
<arg value="-1" />
<arg value="--pretty=format:%H" />
</exec>
<!-- Check if git describe has been stored into property git.revision -->
<condition property="repository.version" value="${git.revision}" else="unknown">
<and>
<isset property="git.revision"/>
<length string="${git.revision}" trim="yes" length="0" when="greater"/>
</and>
</condition>
<!-- Check if git SHA1 has been stored into property git.hash -->
<condition property="repository.hash" value="${git.hash}" else="unknown">
<and>
<isset property="git.hash" />
<length string="${git.hash}" trim="yes" length="0" when="greater" />
</and>
</condition>
<echo message="The current git description :: ${repository.version}" />
<echo message="The most recent git hash :: ${repository.hash}" />
</target>
<!-- Write ant properties into Config.java -->
<target name="config" depends="git.revision" >
<property name="config-target-path" value="${source.dir}/edu/mit/mitmobile2/about" />
<!-- Copy file to new target location, replace keys with new values -->
<copy file="config/Config.java" todir="${config-target-path}" overwrite="true" encoding="utf-8">
<filterset>
<filter token="GIT.DESCRIBE" value="${repository.version}" />
</filterset>
<filterset>
<filter token="GIT.HASH" value="${repository.hash}" />
</filterset>
</copy>
<!-- Set new file to read only so it doesn't cause confusion. Will need to uncomment and implement a delete before the copy -->
<!-- <chmod file="${config-target-path}/Config.java" perm="-w" />
<attrib file="${config-target-path}/Config.java" readonly="true" /> -->
</target>
</project>