-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.xml
221 lines (191 loc) · 8.4 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
<?xml version="1.0" encoding="UTF-8"?>
<!-- A valid XML document requires a declaration as the first line. -->
<!-- The @encoding attribute is optional, but if specified it should be correct. -->
<!-- The root element of an Ant build file.
Valid attributes are @name, @default, and @basedir.
@name = This sets the ant.project.name property. (Optional)
We are skipping it here to set it later in the properties file.
@default = The default target. The name of the target to run if none are specified
on the command-line. (Optional)
We are using the meta-target 'all' for configurability.
@basedir = The base directory for all relative paths. (Optional)
-->
<project default="all" basedir=".">
<!-- Load the properties file containing the project-specific configuration. -->
<loadproperties srcFile="build.properties"/>
<property environment="env"/>
<property name="x-jarfile" location="${dist}/${ant.project.name}.jar"/>
<taskdef resource="scala/tools/ant/antlib.xml">
<classpath>
<pathelement location="${env.SCALA_HOME}/lib/scala-compiler.jar"/>
<pathelement location="${env.SCALA_HOME}/lib/scala-library.jar"/>
</classpath>
</taskdef>
<!-- Initialization target. -->
<target name="init">
<!-- Initialize the timestamp properties. -->
<tstamp/>
<!-- Make sure the src and lib directories exist. -->
<mkdir dir="${src}"/>
<mkdir dir="${test}"/>
<mkdir dir="${lib}"/>
<!-- Create the build directory. -->
<mkdir dir="${build}"/>
</target>
<!-- Meta-target. Just specifies the default target(s) when none is specified on the command-line. -->
<target name="all" depends="jar, test"/>
<!-- Distribute target. Here we prepare for distribution to a customer. -->
<target name="dist" depends="clean, jar, scaladoc" />
<!-- Compile target. Here we compile the .scala files to .class files. -->
<target name="compile" depends="init,fsc">
<!-- Call scalac.
Compile the files in @srcdir and place the classes in @destdir.
@includeantruntime = Don't want Ant run-time libraries in the classpath.
@debug = Include debugging information in the .class files.
@debuglevel = Include line numbers, variable names, and lines of source.
-->
<scalac srcdir="${src}"
destdir="${build}"
>
<!-- Include these libraries in the classpath. -->
<classpath>
<pathelement location="${env.SCALA_HOME}/lib/scala-compiler.jar"/>
<pathelement location="${env.SCALA_HOME}/lib/scala-library.jar"/>
<pathelement path="${libs}"/>
<fileset dir="${lib}">
<include name="**/*.jar"/>
</fileset>
</classpath>
<include name="**/*.scala"/>
</scalac>
</target>
<!-- Fast compile. If this works it will make compiling unnecessary, but it's a lot faster. -->
<target name="fsc" depends="init">
<fsc srcdir="${src}"
destdir="${build}"
failonerror="false"
>
<!-- Include these libraries in the classpath. -->
<classpath>
<pathelement location="${env.SCALA_HOME}/lib/scala-compiler.jar"/>
<pathelement location="${env.SCALA_HOME}/lib/scala-library.jar"/>
<pathelement path="${libs}"/>
<fileset dir="${lib}">
<include name="**/*.jar"/>
</fileset>
</classpath>
<include name="**/*.scala"/>
</fsc>
</target>
<!-- Compile the unit tests. -->
<target name="compile-tests" depends="compile" if="junit.path">
<scalac srcdir="${test}"
destdir="${build}"
>
<classpath>
<pathelement location="${env.SCALA_HOME}/lib/scala-compiler.jar"/>
<pathelement location="${env.SCALA_HOME}/lib/scala-library.jar"/>
<pathelement path="${build}"/>
<pathelement path="${junit.path}"/>
<pathelement path="${libs}"/>
<fileset dir="${lib}">
<include name="**/*.jar"/>
</fileset>
</classpath>
<include name="**/*.scala"/>
</scalac>
</target>
<!-- Test target. Make sure all the unit tests pass. -->
<target name="test" depends="compile, compile-tests" if="junit.path">
<junit fork="yes" haltonfailure="yes">
<classpath>
<pathelement path="${build}"/>
<pathelement path="${junit.path}"/>
<pathelement path="${libs}"/>
<fileset dir="${lib}">
<include name="**/*.jar"/>
</fileset>
</classpath>
<!-- Format and report the test results to the console. -->
<formatter type="plain" usefile="no"/>
<!-- Consider all classes named Test* to be unit tests and run them. -->
<batchtest>
<fileset dir="${test}">
<include name="**/Test*.scala"/>
</fileset>
</batchtest>
</junit>
</target>
<!-- Make-jar target. Here we make the Jar file that will be distributed. -->
<target name="jar" depends="compile">
<!-- Create the distributable directory. -->
<mkdir dir="${dist}"/>
<!-- Create the lib sub directory for the third-party libraries we depend on. -->
<mkdir dir="${dist}/lib"/> <!-- this should be conditional on whether or not we have any libs -->
<!-- Copy the dependent libs to the lib folder.
@overwrite = Overwrite exiting (potentially older) versions.
@flatten = Don't create subdirectories in the @todir.
-->
<copy todir="${dist}/lib" overwrite="true" flatten="true">
<fileset dir="${lib}"/>
</copy>
<!-- Create a normalized Classpath to point to our libs -->
<pathconvert pathsep=" " property="x.classpath">
<fileset dir="${lib}"/>
<chainedmapper>
<flattenmapper/>
<globmapper from="*" to="lib/*"/>
</chainedmapper>
</pathconvert>
<!-- Create the Jar file for our project in the distributable directory. -->
<jar jarfile="${x-jarfile}">
<!-- Include compiled classes -->
<fileset dir="${build}"/>
<!-- Include source code, but exclude temporary editor files -->
<fileset dir="${src}" excludes="**/.*.swp **/*~"/>
<manifest>
<!-- Set's the Main class.
This is the class who's main() method will be called by default.
-->
<attribute name="Main-Class" value="${main}"/>
<!-- Set the Classpath to use when the Main-Class is executed. -->
<attribute name="Class-Path" value="${x.classpath} ${classpath}"/>
</manifest>
</jar>
</target>
<!-- Javadoc target. Generate the Javadoc for the project. -->
<target name="scaladoc" depends="init">
<!-- Create the directory for the project's documentation. -->
<mkdir dir="${scaladoc}"/>
<!-- Generate the Javadoc -->
<scaladoc
srcdir="${src}"
destdir="${scaladoc}"
deprecation="yes"
unchecked="yes"
>
<classpath>
<pathelement location="${env.SCALA_HOME}/lib/scala-compiler.jar"/>
<pathelement location="${env.SCALA_HOME}/lib/scala-library.jar"/>
<pathelement path="${libs}"/>
<fileset dir="${lib}">
<include name="**/*.jar"/>
</fileset>
</classpath>
<include name="**/*.scala"/>
</scaladoc>
</target>
<!-- Run target. Run the finished product. -->
<target name="run" depends="jar">
<!-- Run the compiled Jar file using the arguments and directory specified in the properties. -->
<java jar="${x-jarfile}" fork="true" dir="${run.dir}">
<arg line="${run.args}"/>
</java>
</target>
<!-- Clean target. Clean up all the generated files and directories. -->
<target name="clean">
<delete dir="${scaladoc}"/>
<delete dir="${dist}"/>
<delete dir="${build}"/>
</target>
</project>