forked from ReactionMechanismGenerator/RMG-Java
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.xml
executable file
·116 lines (106 loc) · 3.96 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
<!-- ANT build script for RMG -->
<project name="RMG">
<property name="src" location="source/RMG"/>
<property name="build" location="build/RMG"/>
<target name="compile" depends="versioninfo">
<javac srcdir="${src}" destdir="${build}" optimize="true" debug="true" includeantruntime="false" />
</target>
<target name="jar" depends="compile">
<jar destfile="bin/RMG.jar" basedir="${build}">
<manifest>
<attribute name="Main-Class" value="RMG"/>
</manifest>
</jar>
</target>
<target name="clean" description="delete all compiled classes">
<delete failonerror="false">
<fileset dir="${build}">
<include name="**/*.class"/>
<include name="*.class"/>
<include name="filter"/>
<include name="jing/param/VersionInfo.java"/>
</fileset>
<fileset dir=".">
<include name="bin/RMG.jar"/>
</fileset>
</delete>
</target>
<!-- all the following targets are just to get the Version Info into the log header -->
<target name="getHash" depends="inGitTest, HEADishashTarget, HEADisrefTarget" unless="inGit">
<!-- this target is only executed if you are not in a git repository.
If you ARE in a git repository then instead its dependencies
(HEADis...Target) will set these params -->
<property name="branchname" value="* Not in git repository"/>
<property name="versionhash" value="* Not in git repository"/>
</target>
<target name="inGitTest" description="Test if inside a git repository">
<condition property="inGit">
<available file=".git/HEAD" />
</condition>
</target>
<target name="isHEADhashTest" if="inGit">
<!-- if the HEAD contains a hash, then this will set the property HEADishash
otherwise the property will remain unset. This only runs if inGit -->
<condition property="HEADishash">
<length when="equal" length="41">
<fileset dir=".git" includes="HEAD">
<containsregexp expression="[0-9a-f]{40}"/>
</fileset>
</length>
</condition>
</target>
<target name="HEADishashTarget" depends="isHEADhashTest" if="HEADishash">
<echo>The HEAD is a hash</echo>
<loadfile property="versionhash" srcFile=".git/HEAD">
<filterchain>
<striplinebreaks/>
</filterchain>
</loadfile>
<echo>versionhash = "${versionhash}"</echo>
<property name="branchname" value="Not on a branch"/>
</target>
<target name="HEADisrefTarget" depends="isHEADhashTest" unless="HEADishash" if="inGit">
<echo>The HEAD is a ref</echo>
<loadfile property="headpath" srcFile=".git/HEAD" >
<filterchain>
<replacestring from="ref: " to=""/>
<striplinebreaks/>
</filterchain>
</loadfile>
<loadfile property="branchname" srcFile=".git/HEAD" >
<filterchain>
<replacestring from="ref: refs/heads/" to=""/>
<striplinebreaks/>
</filterchain>
</loadfile>
<echo>branchname = "${branchname}"</echo>
<loadfile property="versionhash" srcFile=".git/${headpath}">
<filterchain>
<striplinebreaks/>
</filterchain>
</loadfile>
<echo>versionhash = "${versionhash}"</echo>
</target>
<target name="versioninfo" depends="getHash">
<!-- set the time stamp -->
<tstamp>
<format property="buildtime" pattern="yyyy-MM-dd'T'HH:mm:ss"/>
</tstamp>
<!-- copy source file with filter -->
<copy file="${src}/jing/param/VersionInfo.java"
toFile="${build}/jing/param/VersionInfo.java"
overwrite="true" >
<filterset>
<filter token="builddate" value="${buildtime}"/>
<filter token="branchname" value="${branchname}"/>
<filter token="versionhash" value="${versionhash}"/>
</filterset>
</copy>
<!-- compile the single java file into a class -->
<javac srcdir="${build}/jing/param"
destdir="${build}"
includes="VersionInfo.java"
optimize="true" debug="true" includeantruntime="false">
</javac>
</target>
</project>