-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.xml
189 lines (166 loc) · 7.01 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
<?xml version="1.0" encoding="UTF-8"?>
<project name="GWT Ant Build" basedir="." default="deploy">
<property name="gwt.module.name" value="de.oose.taskboard.OoseTaskboard" />
<property name="jar.name" value="taskboard.jar" />
<property name="war.name" value="taskboard.war" />
<property name="src.dir" location="src" />
<property name="server.resources.dir" location="../war/${server.resources.name}" />
<property name="build.dir" location="war/WEB-INF/lib" />
<property name="dist.dir" location="dist" />
<property name="build.server.resources.dir" location="war/WEB-INF/classes/server_resources" />
<property name="lib.dir" location="war/WEB-INF/lib" />
<property name="gwt.client.dir" location="de/oose/taskboard/client" />
<!-- some properties for the tomcat -->
<!-- replace the tomcat download url with whatever you amy find appropriate -->
<property name="tomcat.download.url" value="http://mirror.softaculous.com/apache/tomcat/tomcat-7/v7.0.26/bin/apache-tomcat-7.0.26.zip"/>
<property name="tomcat.install.dir" value="tomcat"/>
<!-- the tomcat zip contains a toplevel directory, where everything is installed - so this must be adapted to each new tomcat version -->
<property name="tomcat.subdir" value="apache-tomcat-7.0.26"/>
<property name="tomcat.home" value="${tomcat.install.dir}/${tomcat.subdir}" />
<property name="tomcat.file" value="apache-tomcat-7.0.26.zip"/>
<!-- grab the test properties shared by this build and the ivy build -->
<property file="build/test.properties" />
<import file="gwt.compile.ant.xml" />
<path id="project.classpath">
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset>
</path>
<target name="prepare">
<mkdir dir="${build.dir}" />
<mkdir dir="${dist.dir}" />
</target>
<target name="clean" depends="tomcat-stop">
<delete dir="${build.dir}" />
<delete dir="${dist.dir}" />
<delete dir="${tomcat.install.dir}"/>
</target>
<!-- Compile the java source code using javac -->
<target name="compile" depends="prepare">
<javac srcdir="${src.dir}" destdir="${build.dir}" includeantruntime="false">
<classpath refid="project.classpath" />
</javac>
</target>
<!-- Invoke the GWT compiler to create the Javascript for us -->
<target name="gwt-compile" depends="compile">
<!-- See gwt.compile.ant.xml for gwt.compile task defination -->
<gwt.compile module="${gwt.module.name}" />
</target>
<!-- Package the compiled Java source into a JAR file -->
<target name="jar" depends="compile">
<jar jarfile="${lib.dir}/${jar.name}" basedir="${build.dir}/">
<!-- Don't wrap any of the client only code into the JAR -->
<exclude name="${gwt.client.dir}/**/*.class" />
</jar>
</target>
<!-- Copy the static server resources into the required
directory ready for packaging -->
<target name="copy-resources">
<!-- <copy todir="${build.server.resources.dir}" preservelastmodified="true">
<fileset dir="${server.resources.dir}"/>
</copy>
-->
</target>
<!-- Package the JAR file, Javascript, static resources
and external libraries into a WAR file -->
<target name="war" depends="gwt-compile, copy-resources">
<war basedir="war" destfile="${dist.dir}/${war.name}" webxml="war/WEB-INF/web.xml">
<exclude name="WEB-INF/**" />
<exclude name="${server.resources.name}/**" />
<include name="*.css"/>
<include name="*.html"/>
<include name="oosetaskboard/**"/>
<include name="images/**"/>
<webinf dir="war/WEB-INF/">
<include name="**/*.class"/>
<include name="classes/${server.resources.name}/**" />
<include name="**/*.xml" />
<include name="**/*.jar" />
<exclude name="**/gwt-dev.jar" />
<exclude name="**/gwt-user.jar" />
</webinf>
</war>
</target>
<target name="tomcat-check-installed" description="Checks if the tomcat needs to be installed">
<available file="{tomcat.home}" type="dir" property="tomcat.installed"/>
</target>
<target name="tomcat-install" depends="tomcat-check-installed" unless="tomcat.installed"
description="Download and install tomcat server">
<mkdir dir="${tomcat.install.dir}"/>
<echo>Installing Tomcat</echo>
<unzip dest="${tomcat.install.dir}" src="${tomcat.file}" overwrite="true"/>
<property name="tomcat.installed" value="true"/>
</target>
<path id="tomcat.class.path">
<fileset dir="${tomcat.home}/lib">
<include name="**/*.jar"/>
<include name="**/*.zip"/>
</fileset>
<pathelement location="${tomcat.home}/bin/bootstrap.jar"/>
<pathelement location="${tomcat.home}/bin/tomcat-juli.jar"/>
</path>
<target name="deploy" depends="war,tomcat-install"
description="Builds the webapp and deploys it in the local tomcat">
<sequential>
<antcall target="tomcat-stop"/>
<delete dir="${tomcat.home}/webapps/${dist.context}" failonerror="false"/>
<copy file="${dist.dir}/${war.name}" todir="${tomcat.home}/webapps"/>
<antcall target="tomcat-start"/>
</sequential>
</target>
<target name="tomcat-start" depends="tomcat-install"
description="Starts the local tomcat, if neccesary the task installs it and deploys the webapp">
<java classname="org.apache.catalina.startup.Bootstrap" fork="true"
classpathref="tomcat.class.path">
<jvmarg value="-Dcatalina.home=${tomcat.home}"/>
</java>
</target>
<target name="tomcat-stop" depends="tomcat-check-status" if="tomcat.started"
description="Checks if the tomcat is running and if it is it get's stopped">
<java classname="org.apache.catalina.startup.Bootstrap" fork="true"
classpathref="tomcat.class.path">
<jvmarg value="-Dcatalina.home=${tomcat.home}"/>
<arg line="stop"/>
</java>
<sleep seconds="5"/>
</target>
<target name="tomcat-check-status">
<condition property="tomcat.started">
<socket server="localhost" port="8080"/>
</condition>
</target>
<!-- the targets below this point deal with all the test stuff -->
<target name="test-execute" depends ="test-compile">
<java classname="${test.main.class}">
<classpath>
<pathelement path="${test.compile.dir}"/>
<path refid="project.test.classpath"/>
</classpath>
</java>
</target>
<!-- Compile the java source code using javac -->
<target name="test-compile" depends="test-prepare">
<echo>Compiling the test classes in ${test.src.dir} to ${test.compile.dir}</echo>
<javac srcdir="${test.src.dir}" destdir="${test.compile.dir}" includeantruntime="false" sourcepath="">
<classpath refid="project.test.classpath" />
</javac>
<!-- copy the logback configuration -->
<copy file="${test.src.dir}/logback.xml" todir="${test.compile.dir}"/>
</target>
<!-- clean up after yourself - if needed -->
<target name="test-clean" depends="test-prepare">
<delete dir="${test.compile.dir}" />
<delete file="${test.build.dir}/${test.target.jar}"/>
</target>
<target name="test-prepare">
<!-- in theory this should exist - but we wnat to get sure -->
<mkdir dir="${test.dir}"/>
<!-- create the test compile -->
<mkdir dir="${test.compile.dir}"/>
</target>
<path id="project.test.classpath">
<fileset dir="${test.lib.dir}">
<include name="**/*.jar" />
</fileset>
</path>
</project>