-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
executable file
·174 lines (157 loc) · 6.21 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
<?xml version="1.0" encoding="UTF-8"?>
<!--
Scala + JAVA + Antlr Build Script Written By Russell Cohen, 2013, modifed
from the original script by 6.035 TAs of yore.
This somewhat complex Ant script handles the necessary build dance to link
Antrl, Java and Scala together.
-->
<project name="ProjectName" default="build" basedir=".">
<description>Project Build Script</description>
<!-- targets -->
<target name="build" depends="package" description="Build whole project"/>
<target name="clean" depends="init" description="Remove previous build files">
<delete dir="${build.dir}" includeemptydirs="true" quiet="true"/>
<ant dir="parser" target="clean" />
</target>
<target name="init">
<property environment="env"/>
<!-- check for required tools -->
<fail message="Missing SCALA_HOME variable in OS environment">
<condition><isset property="${env.SCALA_HOME}"/></condition>
</fail>
<fail message="Missing JAVA_HOME variable in OS environment">
<condition><isset property="${env.JAVA_HOME}"/></condition>
</fail>
<!-- variables for paths and files -->
<property name="src.dir" location="${basedir}/src"/>
<property name="tests.dir" location="${basedir}/unittests"/>
<property name="lib.dir" location="${basedir}/lib"/>
<property name="build.dir" location="${basedir}/build"/>
<property name="build-classes.dir" location="${build.dir}/classes"/>
<property name="test-classes.dir" location="${build.dir}/test/classes"/>
<property name="build-lib.dir" location="${build.dir}/lib"/>
<property name="build-doc.dir" location="${build.dir}/doc"/>
<property name="java.dir" location="${env.JAVA_HOME}"/>
<property name="scala.dir" location="${env.SCALA_HOME}"/>
<property name="scala-library.jar" location="${scala.dir}/scala-library.jar"/>
<property name="scala-compiler.jar" location="${scala.dir}/scala-compiler.jar"/>
<property name="scala-reflect.jar" location="${scala.dir}/scala-reflect.jar"/>
<path id="project.classpath">
<pathelement location="${scala-library.jar}"/>
<pathelement location="${build-classes.dir}"/> <!-- used during recompilation -->
<pathelement location="${test-classes.dir}"/> <!-- used during recompilation -->
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
</fileset>
</path>
<path id="scala.classpath">
<pathelement location="${scala-compiler.jar}"/>
<pathelement location="${scala-library.jar}"/>
<pathelement location="${scala-reflect.jar}"/>
</path>
<!-- load scala's ant tasks -->
<taskdef resource="scala/tools/ant/antlib.xml" classpathref="scala.classpath"/>
<!-- print where this project will get scala and java from -->
<echo message="Init project"/>
<echo message=" with scala.dir = ${scala.dir}"/>
<echo message=" with java.dir = ${java.dir}"/>
<!-- check if any files has been modified since last build -->
<uptodate property="build.uptodate" targetfile="${build.dir}/build.done">
<srcfiles dir= "${src.dir}" includes="**"/>
<srcfiles dir= "${lib.dir}" includes="**"/>
</uptodate>
</target>
<target name="parser" depends="init">
<ant dir="parser" />
</target>
<target name="compile" depends="parser" unless="build.uptodate">
<mkdir dir="${build-classes.dir}"/>
<scalac
destdir="${build-classes.dir}"
classpathref="project.classpath"
deprecation="off"
unchecked="off">
<include name="**/*.scala"/>
<include name="**/*.java"/>
<src>
<pathelement location="${src.dir}"/>
</src>
</scalac>
<javac
destdir="${build-classes.dir}"
classpathref="project.classpath"
includeantruntime="false">
<include name="**/*.java"/>
<src><pathelement location="${src.dir}"/></src>
</javac>
</target>
<target name="compile-test" depends="compile" unless="tests.uptodate">
<mkdir dir="${test-classes.dir}"/>
<scalac
destdir="${test-classes.dir}"
classpathref="project.classpath"
deprecation="off"
unchecked="off">
<include name="**/*.scala"/>
<include name="**/*.java"/>
<src>
<pathelement location="${tests.dir}"/>
</src>
</scalac>
<javac
destdir="${test-classes.dir}"
classpathref="project.classpath"
includeantruntime="false">
<include name="**/*.java"/>
<src>
<pathelement location="${tests.dir}"/>
</src>
</javac>
<uptodate property="tests.uptodate" targetfile="${build.dir}/tests.done">
<srcfiles dir= "${tests.dir}" includes="**"/>
</uptodate>
</target>
<target name="test" depends="compile-test" unless="tests.uptodate">
<taskdef name="scalatest" classname="org.scalatest.tools.ScalaTestAntTask" classpathref="project.classpath">
<classpath>
<fileset dir="${scala.dir}">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
</fileset>
</classpath>
</taskdef>
<scalatest runpath="${test-classes.dir}" haltonfailure="true" fork="no">
<reporter type="stdout" />
</scalatest>
</target>
<target name="tar" depends="clean">
<delete file="${env.USER}-handin.tar.gz" />
<delete file="${env.USER}-handin.tar" />
<tar destfile="${env.USER}-handin.tar">
<tarfileset dir="."
prefix="${env.USER}-handin/">
<include name="**/*" />
<exclude name="*.tar" />
<exclude name="*.tar.gz" />
<exclude name="**/.git/**" />
</tarfileset>
</tar>
<gzip destfile="${env.USER}-handin.tar.gz"
src="${env.USER}-handin.tar" />
</target>
<target name="package" depends="compile" unless="build.uptodate">
<mkdir dir="${build-lib.dir}"/>
<jar destfile="${build-lib.dir}/project.jar">
<fileset dir="${build-classes.dir}"/>
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
</fileset>
</jar>
<jar destfile="${build-lib.dir}/project-src.jar">
<fileset dir="${src.dir}" includes="**/*.scala"/>
</jar>
<touch file="${build.dir}/build.done"/> <!-- mark build as up-to-date -->
</target>
</project>