forked from mzymarcus/cis555-1
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.xml
executable file
·127 lines (118 loc) · 5.28 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
<?xml version="1.0"?>
<project name="webserver" default="run" basedir=".">
<property name="shared.root" location="${basedir}"/>
<property name="project.root" location="${basedir}"/>
<property name="build.dir" location="${project.root}"/>
<property name="build.target.dir" location="${project.root}${file.separator}target"/>
<property name="web-inf.dir" location="${build.target.dir}${file.separator}WEB-INF"/>
<property name="classes.dir" location="${web-inf.dir}${file.separator}classes"/>
<property name="web-inf.lib.dir" location="${web-inf.dir}${file.separator}lib"/>
<property name="test-classes.dir" location="${build.target.dir}${file.separator}test${file.separator}classes"/>
<property name="test-lib.dir" location="${build.target.dir}${file.separator}test${file.separator}lib"/>
<property name="src.main.dir" location="${build.dir}${file.separator}src${file.separator}"/>
<property name="inputlib.dir" location="${shared.root}${file.separator}lib"/>
<property name="src.test.dir" location="${build.dir}${file.separator}test"/>
<property name="resources.dir" location="${build.dir}${file.separator}resources"/>
<property name="conf.dir" location="${build.dir}${file.separator}conf"/>
<property name="main-class" value="edu.upenn.cis.cis455.webserver.HttpServer"/>
<path id="classpath">
<fileset dir="${inputlib.dir}" includes="**/*.jar"/>
</path>
<target name="clobber" description="create target directory and all the subdirectories">
<delete dir="${build.target.dir}"/>
<mkdir dir="${classes.dir}"/>
<mkdir dir="${web-inf.lib.dir}"/>
<mkdir dir="${test-classes.dir}"/>
<mkdir dir="${test-lib.dir}"/>
</target>
<target name="compilejavamain" description="compiles main Java source code">
<javac srcdir="${src.main.dir}${file.separator}" destdir="${classes.dir}" debug="on" deprecation="off" optimize="on" includeAntRuntime="no">
<classpath>
<fileset dir="${inputlib.dir}">
<include name="*.jar"/>
</fileset>
</classpath>
</javac>
</target>
<target name="compilejavatest" description="compiles test Java source code">
<javac srcdir="${src.test.dir}${file.separator}" destdir="${test-classes.dir}" debug="on" deprecation="off" optimize="on" includeAntRuntime="no">
<classpath>
<pathelement path="${classes.dir}" />
<fileset dir="${inputlib.dir}">
<include name="*.jar"/>
</fileset>
</classpath>
</javac>
</target>
<target name="clean" description="deletes all the compiled class files">
<delete failonerror="false" includeemptydirs="true">
<fileset dir="${classes.dir}">
<include name="**/*.class"/>
</fileset>
<fileset dir="${test-classes.dir}">
<include name="**/*.class"/>
</fileset>
</delete>
</target>
<target name="pack" description="Create an archive for submission">
<zip destfile="submit-hw1.zip">
<zipfileset dir="." excludes="target/**,extra/**,**/*.class,submit-hw1.zip"/>
</zip>
</target>
<target name="build" depends="clobber">
<antcall target="compilejavamain"/>
<jar destfile="${web-inf.lib.dir}${file.separator}webserver.jar" update="true">
<fileset dir="${classes.dir}">
<include name="**/*.class"/>
</fileset>
<manifest>
<attribute name="Main-Class" value="${main-class}"/>
</manifest>
</jar>
<copy file="${conf.dir}${file.separator}web.xml" tofile="${web-inf.dir}${file.separator}web.xml" overwrite="true" />
<copy todir="${classes.dir}" overwrite="true">
<fileset dir="${conf.dir}">
<include name="**"/>
<exclude name="test/**"/>
<exclude name="web.xml"/>
</fileset>
</copy>
<copy todir="${build.target.dir}" overwrite="true">
<fileset dir="${resources.dir}">
<include name="**"/>
</fileset>
</copy>
<copy todir="${web-inf.lib.dir}" overwrite="true">
<fileset dir="${inputlib.dir}">
<include name="*.jar"/>
</fileset>
</copy>
<antcall target="compilejavatest" />
<jar destfile="${test-lib.dir}${file.separator}webserver-test.jar" update="true">
<fileset dir="${test-classes.dir}">
<include name="**"/>
</fileset>
</jar>
<!-- <antcall target="cleanup"/> -->
</target>
<target name="run" depends="build">
<parallel>
<java classname="${main-class}" fork="true" timeout="10000">
<classpath>
<path refid="classpath"/>
<path location="${build.target.dir}${file.separator}WEB-INF${file.separator}lib${file.separator}${ant.project.name}.jar"/>
<path location="${resources.dir}"/>
</classpath>
</java>
<sequential>
<sleep milliseconds="500"/>
<exec executable="curl">
<arg line="http://localhost:8080/index.html"/>
</exec>
<exec executable="curl">
<arg line="http://localhost:8080/shutdown"/>
</exec>
</sequential>
</parallel>
</target>
</project>